我正在尝试使用自定义累加器类,如Spark documentation。如果我在本地定义类,这是可行的,但是当我尝试在另一个模块中定义它并使用sc.addPyFile
导入文件时,我得到一个ImportError
。在
当在rdd.foreach
中导入一个helper函数时,我也遇到了同样的问题,我可以通过在中执行import
按照this SO question来解决这个问题。但是,相同的修复对于自定义累加器不起作用(我也不希望它这样做)。在
扩展/累加器.py公司名称:
class ArrayAccumulatorParam(pyspark.AccumulatorParam):
def zero(self, initialValue):
return numpy.zeros(initialValue.shape)
def addInPlace(self, a, b):
a += b
return a
跑/count.py公司名称:
^{pr2}$错误:
ImportError: No module named extensions.accumulators
目前没有回答
相关问题 更多 >
编程相关推荐