云数据流 python3 作业未解决依赖关系

Cloud dataflow python3 job not solving dependencies

我有一个简单的 apache beam 项目使用 python 3 来转换一些数据并写入大查询,它使用一个名为 texstat 的包,如果我 运行 在本地一切正常,但是当我运行 在数据流上出现以下错误:

NameError: name 'textstat' is not defined [while running 'generatedPtransform-441']

这是我当前的 setup.py 文件:

import setuptools

REQUIRED_PACKAGES = ['textstat==0.5.6']
PACKAGE_NAME = 'my_package'
PACKAGE_VERSION = '0.0.1'


setuptools.setup(
    name=PACKAGE_NAME,
    version=PACKAGE_VERSION,
    description='Example project',
    install_requires=REQUIRED_PACKAGES,
    packages=setuptools.find_packages(),
)

这是我的管道参数

pipeline_args = [
    '--project={}'.format('etl-example'),
    '--runner={}'.format('Dataflow'),
    '--temp_location=gs://dataflowtemporal/',
    '--setup_file=./setup.py',
]

我运行就是这样

pipeline_options = PipelineOptions(pipeline_args)
pipeline_options.view_as(StandardOptions).streaming = True
pipeline = beam.Pipeline(options=pipeline_options)
...
pipeline.run()

在运行完成工作之前,我也在终端上尝试了运行这个:

python setup.py sdist --formats=gztar

但我得到了相同的结果,即没有找到 texstat。 我尝试的另一件事是没有 setup.py 而只有参数

--requirements_file=./requirements.txt

但还是找不到 texstat

此时我不知道还能尝试什么。

一般是因为你的DoFn没有在本地导入库。

或者您可以尝试 --save_main_session 选项,如 https://cloud.google.com/dataflow/docs/resources/faq

中所述