我试图通过修改pipeline options将运行时参数用作instructed in the docs来将Cloud Dataflow "Wordcount" python示例转换为模板化版本:
def run(argv=None):
"""Main entry point; defines and runs the wordcount pipeline."""
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',
default='gs://dataflow-samples/shakespeare/kinglear.txt',
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'])
p = beam.Pipeline(options=pipeline_options)
wordcount_options = pipeline_options.view_as(WordcountTemplatedOptions)
# Read the text file[pattern] into a PCollection.
etc. etc.
问题是创建和暂存模板......执行command时,输出为:
INFO:root:Starting the size estimation of the input
INFO:oauth2client.transport:Attempting refresh to obtain initial access_token
INFO:oauth2client.client:Refreshing access_token
INFO:root:Finished the size estimation of the input at 1 files. Estimation took 0.288088083267 seconds
INFO:oauth2client.transport:Attempting refresh to obtain initial access_token
INFO:oauth2client.client:Refreshing access_token
INFO:root:Starting finalize_write threads with num_shards: 1, batches: 1, num_threads: 1
INFO:root:Renamed 1 shards in 0.13 seconds.
INFO:root:number of empty lines: 1663
INFO:root:average word length: 4
并且template_location下没有生成的文件(gs:// [YOUR_BUCKET_NAME] / templates / mytemplate)...
我以为命令试图用“默认”输入文件从桌面执行数据流,所以我删除了--input参数中的“default”行,但是我收到了这个错误:
raise BeamIOError('Unable to get the Filesystem', {path: e})
apache_beam.io.filesystem.BeamIOError: Unable to get the Filesystem with exceptions {None: AttributeError("'NoneType' object has no attribute 'strip'",)}
没有官方的python数据流模板样本(我能找到的唯一片段是this one,看起来非常像上面的内容) .
我错过了什么吗?
谢谢!