python生成Java模板代码_无法在Python中生成模板化数据流

我试图通过修改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,看起来非常像上面的内容) .

我错过了什么吗?

谢谢!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值