Google cloud platform apache_beam[gcp]-侧输入到ParDo
我无法找到使用apache_beam[gcp]2.4.0版本的ParDo函数添加边输入的正确方法 我的管道是Google cloud platform apache_beam[gcp]-侧输入到ParDo,google-cloud-platform,google-cloud-dataflow,apache-beam,app-engine-flexible,Google Cloud Platform,Google Cloud Dataflow,Apache Beam,App Engine Flexible,我无法找到使用apache_beam[gcp]2.4.0版本的ParDo函数添加边输入的正确方法 我的管道是 pipeline | "Load" >> ReadFromText("query.txt") | "Count Words" >> CountWordsTransform() class CountWordsTransform(beam.PTransform): def expand(self, p_collection):
pipeline
| "Load" >> ReadFromText("query.txt")
| "Count Words" >> CountWordsTransform()
class CountWordsTransform(beam.PTransform):
def expand(self, p_collection):
anotherPipleline = beam.Pipeline(runner="DataflowRunner", argv=[
"--staging_location", ("%s/staging" % gcs_path),
"--temp_location", ("%s/temp" % gcs_path),
"--output", ("%s/output" % gcs_path),
"--setup_file", "./setup.py"
])
value2 = anotherPipleline | 'create2' >> Create([("a", 1), ("b", 2), ("c", 3)])
return (p_collection
| "Split" >> (beam.ParDo(FindWords(), beam.pvalue.AsDict(value2))))
FindWords()类定义为:
class FindWords(beam.DoFn):
def process(self, element, values):
import re as regex
return regex.findall(r"[A-Za-z\']+", element)
我收到以下错误:
'NoneType' object has no attribute 'parts'
您正在复合转换中创建一个单独的管道来创建端输入-这将导致问题,因为集合不应跨不同的管道共享 相反,您可以尝试在同一管道中创建边输入,并将其作为参数传递给变换 例如
通过上面的2.4.0测试,您正在复合转换中创建一个单独的管道来创建端输入-这将导致问题,因为集合不应在不同的管道中共享 相反,您可以尝试在同一管道中创建边输入,并将其作为参数传递给变换 例如
以上使用2.4.0测试错误仅在apache_beam[gcp]版本2.3.0及以上版本出现。beam版本2.2.0无错误。错误仅在apache_beam[gcp]版本2.3.0及以上版本出现。beam版本2.2.0无错误。
values = pipeline | "Get pcol for side input" >> beam.Create([("a", 1), ("b", 2), ("c", 3)])
pipeline
| "Load" >> beam.io.ReadFromText('gs://bucket/words.txt')
| "Count Words" >> CountWordsTransform(values)
class CountWordsTransform(beam.PTransform):
def __init__(self, values):
self.values = values
def expand(self, p_collection):
return p_collection | "Split" >> (beam.ParDo(FindWords(), beam.pvalue.AsDict(self.values)))