Google Dataflow显示了AttributeError:'模块'对象没有属性' Read'

时间:2017-06-27 08:36:30

标签: python tensorflow apache-beam

我正在使用谷歌云进行测试,我按照指南对BigQuery运行测试。 https://cloud.google.com/solutions/using-cloud-dataflow-for-batch-predictions-with-tensorflow

当我运行脚本时:

Traceback (most recent call last):
  File "prediction/run.py", line 23, in <module>
    predict.run()
  File "/home/ahuoo_com/dataflow-prediction-example/prediction/modules/predict.py", line 98, in run
    images = p | 'ReadFromBQ' >> beam.Read(beam.io.BigQuerySource(known_args.input))
**AttributeError: 'module' object has no attribute 'Read'**

显示

which python

看起来apache_beam包不包含属性&#39; Read&#39;。我认为在github中提供的google示例可能是错误的。您可以查看第98行的代码。

https://github.com/GoogleCloudPlatform/dataflow-prediction-example/blob/master/prediction/modules/predict.py

是否有人使用本指南进行测试?

1 个答案:

答案 0 :(得分:0)

你是对的,代码中有一个小错误。在98行,其中显示:

images = p | 'ReadFromBQ' >> beam.Read(beam.io.BigQuerySource(known_args.input))

应该是:

images = p | 'ReadFromBQ' >> beam.io.Read(beam.io.BigQuerySource(known_args.input))

此外,在100行显示:

predictions | 'WriteToBQ' >> beam.Write(beam.io.BigQuerySink(...))

它也应该像:

predictions | 'WriteToBQ' >> beam.io.Write(beam.io.BigQuerySink(...))

PCollection读取/写入资源来自io模块,而不是apache_beam本身。