apacheairflow中BeamRunPythonPipelineOperator与DataFlowPythonOperator的区别是什么?
创始人
2024-09-05 10:00:16
0

BeamRunPythonPipelineOperator和DataFlowPythonOperator都是用于在Airflow中运行基于Python的Apache Beam pipeline的Operator。 但是,它们之间存在一些重要的区别。

BeamRunPythonPipelineOperator(BRP)可以在本地或任何支持Beam的环境中运行Beam pipeline。 因此,它可以在任何支持Python和Beam的环境中运行。 而DataFlowPythonOperator(DFP)则在Google Cloud Platform的Dataflow环境中运行Beam pipeline。

BRP示例代码:

from airflow.contrib.operators.beam_runner_operator import BeamRunPythonPipelineOperator from my_package import DoSomething

beam_pipeline = DoSomething()

t1 = BeamRunPythonPipelineOperator( task_id='run_beam_pipeline', py_file='/path/to/python/code', runner='DirectRunner', pipeline=beam_pipeline )

DFP示例代码:

from airflow.contrib.operators.dataflow_operator import DataFlowPythonOperator from my_package import DoSomething

beam_pipeline = DoSomething()

t1 = DataFlowPythonOperator( task_id='run_beam_pipeline', py_file='/path/to/python/code', dataflow_default_options={ 'project': 'my-gcp-project', 'zone': 'us-central1-f', 'tempLocation': 'gs://my-gcs-bucket/tmp', 'stagingLocation': 'gs://my-gcs-bucket/staging' }, py_options=['-m'], py_requirements=['pandas==1.0.1'], # optional py_interpreter='python3', py_system_site_packages=False, pipeline_options={ 'runner': 'DataFlowRunner', 'job_name': 'my-dataflow-job' }, pipeline=beam_pipeline )

因此,BRP和DFP之间的差异在于他们运行Beam pipeline的环境。 BeamRunPythonPipelineOperator在任何支持Beam的环境中都可以运行Beam pipeline,而DataFlowPythonOperator仅能在Google Cloud Platform的Dataflow环境中运行Beam pipeline。

相关内容

热门资讯

安装了Anaconda之后找不... 在安装Anaconda后,如果找不到Jupyter Notebook,可以尝试以下解决方法:检查环境...
安装安卓应用时出现“Play ... 在安装安卓应用时出现“Play Protect 警告弹窗”的原因是Google Play Prote...
安卓系统怎么连不上carlif... 安卓系统无法连接CarLife的原因及解决方法随着智能手机的普及,CarLife这一车载互联功能为驾...
避免在粘贴双引号时向VS 20... 在粘贴双引号时向VS 2022添加反斜杠的问题通常是由于编辑器的自动转义功能引起的。为了避免这个问题...
iwatch怎么连接安卓系统,... 你有没有想过,那款时尚又实用的iWatch,竟然只能和iPhone好上好?别急,今天就来给你揭秘,怎...
安装apache-beam==... 出现此错误可能是因为用户的Python版本太低,而apache-beam==2.34.0需要更高的P...
iqoo安卓14系统怎么升级系... 亲爱的iQOO手机用户们,是不是觉得你的手机系统有点儿落伍了呢?别急,今天就来手把手教你如何升级到最...
vivo安卓系统取消更新系统,... 亲爱的vivo手机用户们,你们是不是也遇到了这样的烦恼:手机里突然冒出一个更新提示,点开一看,哇,新...
Android Recycle... 要在Android RecyclerView中实现滑动卡片效果,可以按照以下步骤进行操作:首先,在项...
安卓系统连接荣耀手表,操作指南... 亲爱的手机控们,是不是最近入手了一款酷炫的荣耀手表,却不知道怎么和安卓手机完美“牵手”呢?别急,今天...