从 Dataflow 作业的 Google 存储中删除文件

delete file from Google Storage from a Dataflow job

我在 python 3.7 中有一个使用 apache-beam 制作的数据流,我在其中处理一个文件,然后我必须删除它。该文件来自 google 存储桶,问题是当我使用 DataflowRunner 运行器时我的工作不起作用,因为 google-cloud-storage API 没有安装在Google 数据流 python 3.7 环境。你们知道吗,我怎么能在不使用这个 API 的情况下删除我的数据流中的这个文件?我看过 apache_beam 模块,例如 https://beam.apache.org/releases/pydoc/2.22.0/apache_beam.io.filesystem.html,但我不知道如何使用它,也没有找到关于如何使用此模块的教程或示例。

我认为您无法删除 while 运行 数据流作业。数据流作业完成后,您必须删除该文件。我通常推荐某种编排,例如 apache airflow 或 Google Cloud Composer。

您可以按如下方式在气流中制作 DAG -

这里,

“自定义 DAG 工作流”将包含数据流作业。
“自定义 Python 代码”将具有 python 代码以删除文件

参考 - https://github.com/GoogleCloudPlatform/professional-services/tree/master/examples/cloud-composer-examples/composer_dataflow_examples