本文介绍了气流:如何在非PythonOperator中使用xcom_push和xcom_pull的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我看到很多关于如何在Airflow中将 xcom_push 和 xcom_pull 与PythonOperators结合使用的示例。
I see a lot of examples on how to use xcom_push and xcom_pull with PythonOperators in Airflow.
我需要从 non-PythonOperator 类执行 xcom_pull ,并且不能找到方法。
I need to do xcom_pull from a non-PythonOperator class and couldn't find how to do it.
任何指针或示例都会受到赞赏!
Any pointer or example will be appreciated!
推荐答案您可以从模板字段中访问XCom变量。例如,要从XCom中进行读取:
You can access XCom variables from within templated fields. For example, to read from XCom:
myOperator = MyOperator( message="Operation result: {{ task_instance.xcom_pull(task_ids=['task1', 'task2'], key='result_status') }}", ...也可以不指定任务,以在一个具有相同键名的DagRun中获得所有XCom推送
It is also possible to not specify task to get all XCom pushes within one DagRun with the same key name
myOperator = MyOperator( message="Warning status: {{ task_instance.xcom_pull(task_ids=None, key='warning_status') }}", ...将返回数组。
更多推荐
气流:如何在非PythonOperator中使用xcom
发布评论