【发布时间】:2021-06-06 06:44:26
【问题描述】:
有谁知道下面的代码有什么问题:
本质上,我正在调用 TriggerDagRunOperator,并且我正在尝试基于 XCOM Pull 将一些 conf 传递给它。
触发 DAG:
def _should_trigger(**_):
return {'Message': 'Hello World'}
should_trigger = PythonOperator(
task_id="should_trigger",
python_callable=_should_trigger,
provide_context=True,
)
trigger_bar_dag = TriggerDagRunOperator(
task_id="trigger_bar_dag",
trigger_dag_id="bar",
conf={"payload": "{{ task_instance.xcom_pull('should_trigger') }}"},
)
目标 DAG:
@dag(dag_id="bar",
default_args=default_args,
schedule_interval=None
)
def tasks():
run_this = PythonOperator(
task_id="run_this",
python_callable=run_this_func,
provide_context=True)
由于某种原因,在 run_this_func 中,我得到了有效载荷:无。我似乎无法通过来自 xcom 拉取的 conf 流传递值。有谁知道如何做到这一点。我还尝试了不同的 xcom pull 变体,例如: ti.xcom_pull(key='return_value', task_ids=['should_trigger']) 无济于事。
谢谢,
【问题讨论】:
-
run_this_func函数是什么?
标签: airflow