【发布时间】:2018-05-30 19:09:35
【问题描述】:
我有一个可以在本地执行而不会出现任何错误的管道。我曾经在本地运行的管道中遇到此错误
'Clients have non-trivial state that is local and unpickleable.'
PicklingError: Pickling client objects is explicitly not supported.
我相信我通过降级到 apache-beam=2.3.0 解决了这个问题 然后在本地它将完美运行。
现在我正在使用 DataflowRunner 并且在 requirements.txt 文件中我有以下依赖项
apache-beam==2.3.0
google-cloud-bigquery==1.1.0
google-cloud-core==0.28.1
google-cloud-datastore==1.6.0
google-cloud-storage==1.10.0
protobuf==3.5.2.post1
pytz==2013.7
但我又遇到了这个可怕的错误
'Clients have non-trivial state that is local and unpickleable.'
PicklingError: Pickling client objects is explicitly not supported.
为什么它给了我 DataflowRunner 而不是 DirectRunner 的错误?他们不应该使用相同的依赖项/环境吗? 任何帮助,将不胜感激。
我已经读到这是解决它的方法,但是当我尝试它时,我仍然得到同样的错误
class MyDoFn(beam.DoFn):
def start_bundle(self, process_context):
self._dsclient = datastore.Client()
def process(self, context, *args, **kwargs):
# do stuff with self._dsclient
来自https://github.com/GoogleCloudPlatform/google-cloud-python/issues/3191
我之前在本地修复此问题的参考帖子:
Using start_bundle() in apache-beam job not working. Unpickleable storage.Client()
提前致谢!
【问题讨论】:
-
你有堆栈跟踪吗?
-
DirectRunner 旨在在部署之前验证您的管道,并确保其在各种 Beam runner 中的稳健性。因此,如果 DataflowRunner 与 DirectRunner 在相同的 Beam 版本上运行,它应该可以在 DataflowRunner 上运行。你能分享一份堆栈跟踪或作业日志吗?
-
在尝试从管道将数据写入 BigQuery 表时,我在 Dataflow 上遇到了类似的问题,尽管它是从 DirectRunner 运行的。有没有人在从 Dataflow 写入 BigQuery 时遇到过类似的问题。
标签: python google-cloud-dataflow pickle apache-beam