我正在尝试将包含 proto 定义 (_pb2) 的 Apache Beam 作业部署到 Google Dataflow,但是我收到了一个酸洗错误:
_pickle.PicklingError: Can't pickle <class 'test_pb2.Example'>: import of module 'test_pb2' failed [while running 'Convert to Proto']
Run Code Online (Sandbox Code Playgroud)
我的项目结构遵循本文档中建议的方法和juliaset 示例:
root/
main.py
setup.py
pipeline/
__init__.py
pipeline.py
test_pb2.py
input.txt
proto/
test.proto
Run Code Online (Sandbox Code Playgroud)
test_pb2 是使用 test.proto 中的 protoc 生成的,用于转换,将 dict 转换为 proto。
main.py 的内容:
import logging
from pipeline import pipeline
if __name__ == '__main__':
logging.getLogger().setLevel(logging.INFO)
pipeline.run()
Run Code Online (Sandbox Code Playgroud)
pipeline.py 的内容:
from __future__ import absolute_import
import apache_beam as beam
import argparse
from apache_beam.options.pipeline_options import PipelineOptions …Run Code Online (Sandbox Code Playgroud) python protocol-buffers python-3.x google-cloud-dataflow apache-beam