我正在嘗試創(chuàng)建一個數(shù)據(jù)流模板,該模板將輸入?yún)?shù)作為.遵循文檔中的示例RuntimeValueimport reimport apache_beam as beamfrom apache_beam.io import ReadFromTextfrom apache_beam.io import WriteToTextfrom apache_beam.options.pipeline_options import PipelineOptions# [START example_wordcount_templated]class WordcountTemplatedOptions(PipelineOptions): @classmethod def _add_argparse_args(cls, parser): # Use add_value_provider_argument for arguments to be templatable # Use add_argument as usual for non-templatable arguments parser.add_value_provider_argument( '--input', help='Path of the file to read from') parser.add_argument( '--output', required=True, help='Output file to write results to.')pipeline_options = PipelineOptions(['--output', 'some/output_path'])with beam.Pipeline(options=pipeline_options) as p: wordcount_options = pipeline_options.view_as(WordcountTemplatedOptions) lines = p | 'Read' >> ReadFromText(wordcount_options.input)# [END example_wordcount_templated](直接取自官方代碼段)在嘗試使用以下命令創(chuàng)建模板時(填寫詳細信息)時會出現(xiàn)以下錯誤: python -m examples.mymodule \ --runner DataflowRunner \ --project YOUR_PROJECT_ID \ --staging_location gs://YOUR_BUCKET_NAME/staging \ --temp_location gs://YOUR_BUCKET_NAME/temp \ --template_location gs://YOUR_BUCKET_NAME/templates/YOUR_TEMPLATE_NAME File "lib/python3.7/site-packages/apache_beam/options/value_provider.py", line 139, in _f raise error.RuntimeValueProviderError('%s not accessible' % obj)apache_beam.error.RuntimeValueProviderError: RuntimeValueProvider(option: input, type: str, default_value: None) not accessible 文檔還指出:某些 I/O 連接器包含接受 ValueProvider 對象的方法。若要確定對 I/O 連接器及其方法的支持,請參閱連接器的 API 參考文檔。以下 I/O 連接器接受運行時參數(shù):基于文件的 IO:textio、avroio、tfrecordio我不確定為什么示例代碼會給出錯誤。有人可以幫我嗎?對于它的價值,我正在使用:apache-beam = {extras = ["gcp"], version = "^2.19.0"}
1 回答

牧羊人nacy
TA貢獻1862條經驗 獲得超7個贊
這已經固定在光束中,截至2020年4月15日發(fā)布。0.20.0
使用 beam.io 操作(例如運行時值提供程序)只是工作正常。如果您遇到與問題相同的錯誤,請嘗試升級您的梁依賴版本。beam.io.ReadFromText(wordcount_options.input)
添加回答
舉報
0/150
提交
取消