气流:如何在非PythonOperator中使用xcom

编程入门 行业动态 更新时间:2024-10-21 03:31:40
本文介绍了气流:如何在非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

本文发布于:2023-11-23 19:52:17,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1622685.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:气流   如何在   xcom   PythonOperator

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!