气流:如何在非PythonOperator中使用xcom_push和xcom_pull

时间:2018-07-29 14:34:52

标签: airflow

我看到了很多关于如何在Airflow中将xcom_pushxcom_pull与PythonOperators结合使用的示例。

我需要从 non-PythonOperator 类执行xcom_pull,但是找不到如何做。

任何指针或示例将不胜感激!

2 个答案:

答案 0 :(得分:3)

您可以从模板字段中访问XCom变量。例如,要阅读XCom:

es

也可能不指定任务,以在一个具有相同键名的DagRun中获得所有XCom推送

myOperator = MyOperator(
    message="Operation result: {{ task_instance.xcom_pull(task_ids=['task1', 'task2'], key='result_status') }}",
    ...

将返回一个数组。

答案 1 :(得分:0)

要推送:

Index out of range

拉动:

self.xcom_push(context, key, value)
相关问题