【问题标题】:Send the output of one task to another task in airflow将一项任务的输出发送到气流中的另一项任务
【发布时间】:2020-07-23 18:11:57
【问题描述】:

我正在使用气流,我想将任务 1 的函数的输出传递给任务 2。


def create_dag(dag_id,
               schedule,
               default_args):
    def getData(**kwargs):
        res = requests.post('https://dummyURL')
        return res.json())  
    def sendAlert(**kwargs):
        requests.post('https://dummyURL', params = "here i want to send res.json() from task 1")

    dag = DAG(dag_id,
                  schedule_interval=schedule,
                  default_args=default_args)

    with dag:
        t1 = PythonOperator(task_id='task1',python_callable=getData,provide_context=True,dag=dag)
        t2 = PythonOperator(task_id='task2',python_callable=sendAlert,provide_context=True,dag=dag)
    return dag

【问题讨论】:

    标签: python-3.x airflow-scheduler airflow


    【解决方案1】:

    查看xcom's,只要你要传递的数据比较小就是最好的选择。

    【讨论】:

      猜你喜欢
      • 2023-01-24
      • 2023-01-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-03-28
      • 2015-11-01
      相关资源
      最近更新 更多