>> 操作员如何在 Airflow 中定义任务依赖关系?
How >> operator defines task dependencies in Airflow?
我正在阅读 Apache Airflow 教程 https://github.com/hgrif/airflow-tutorial 并遇到了定义任务依赖项的部分。
with DAG('airflow_tutorial_v01',
default_args=default_args,
schedule_interval='0 * * * *',
) as dag:
print_hello = BashOperator(task_id='print_hello',
bash_command='echo "hello"')
sleep = BashOperator(task_id='sleep',
bash_command='sleep 5')
print_world = PythonOperator(task_id='print_world',
python_callable=print_world)
print_hello >> sleep >> print_world
让我困惑的是
print_hello >> sleep >> print_world
>>在Python中是什么意思?我知道按位运算符,但无法与此处的代码相关。
Airflow 将工作流表示为有向无环图。工作流是必须并行或顺序执行的任意数量的任务。 “>>”是 Airflow 语法,用于设置另一个任务的下游。
深入 incubator-airflow 项目回购,airflow
目录中的 models.py
定义了很多 Airflow 高级抽象的行为。如果您愿意,可以深入研究其他 classes,但能够回答您问题的是 BaseOperator class。 Airflow 中的所有运算符都继承自 BaseOperator。 BaseOperator class 的 __rshift__
方法在设置任务或另一个 DAG 下游的上下文中实现 Python 右移逻辑运算符。
查看实现 here。
我正在阅读 Apache Airflow 教程 https://github.com/hgrif/airflow-tutorial 并遇到了定义任务依赖项的部分。
with DAG('airflow_tutorial_v01',
default_args=default_args,
schedule_interval='0 * * * *',
) as dag:
print_hello = BashOperator(task_id='print_hello',
bash_command='echo "hello"')
sleep = BashOperator(task_id='sleep',
bash_command='sleep 5')
print_world = PythonOperator(task_id='print_world',
python_callable=print_world)
print_hello >> sleep >> print_world
让我困惑的是
print_hello >> sleep >> print_world
>>在Python中是什么意思?我知道按位运算符,但无法与此处的代码相关。
Airflow 将工作流表示为有向无环图。工作流是必须并行或顺序执行的任意数量的任务。 “>>”是 Airflow 语法,用于设置另一个任务的下游。
深入 incubator-airflow 项目回购,airflow
目录中的 models.py
定义了很多 Airflow 高级抽象的行为。如果您愿意,可以深入研究其他 classes,但能够回答您问题的是 BaseOperator class。 Airflow 中的所有运算符都继承自 BaseOperator。 BaseOperator class 的 __rshift__
方法在设置任务或另一个 DAG 下游的上下文中实现 Python 右移逻辑运算符。
查看实现 here。