簡體   English   中英

Google數據流顯示AttributeError:“模塊”對象沒有屬性“讀取”

[英]Google Dataflow shows AttributeError: 'module' object has no attribute 'Read'

我正在使用Google Cloud進行測試,我按照指南對BigQuery進行了測試。 https://cloud.google.com/solutions/using-cloud-dataflow-for-batch-predictions-with-tensorflow

當我運行腳本時:

python prediction/run.py \
--runner DataflowRunner \
--project $PROJECT \
--staging_location $BUCKET/staging \
--temp_location $BUCKET/temp \
--job_name $PROJECT-prediction-bq \
--setup_file prediction/setup.py \
--model $BUCKET/model \
--source bq \
--input $PROJECT:mnist.images \
--output $PROJECT:mnist.predict

表明

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'**

看起來apache_beam軟件包不包含屬性“ Read”。 我認為Google在github中提供的示例可能是錯誤的。 您可以查看第98行的代碼。

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

有沒有人使用本指南進行測試?

沒錯,代碼中有一個小錯誤。 在第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本身。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM