You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2021/07/21 18:12:14 UTC

[GitHub] [airflow] josh-fell commented on a change in pull request #16869: Updating Apache example DAGs to use XComArgs

josh-fell commented on a change in pull request #16869:
URL: https://github.com/apache/airflow/pull/16869#discussion_r674218931



##########
File path: airflow/providers/apache/kylin/example_dags/example_kylin_dag.py
##########
@@ -57,8 +52,8 @@ def gen_build_time(**kwargs):
     project='learn_kylin',
     cube='kylin_sales_cube',
     command='build',
-    start_time="{{ task_instance.xcom_pull(task_ids='gen_build_time',key='date_start') }}",
-    end_time="{{ task_instance.xcom_pull(task_ids='gen_build_time',key='date_end') }}",
+    start_time=gen_build_time_task.output['date_start'],
+    end_time=gen_build_time_task.output['date_end'],

Review comment:
       Not specifically with Kylin since I don't have a Kylin integration handy but this test functions as expected:
   
   ```python
   def gen_build_time(**kwargs):
       """
       Gen build time and push to xcom
       :param kwargs:
       :return:
       """
       ti = kwargs["ti"]
       ti.xcom_push(key="date_start", value="1325347200000")
       ti.xcom_push(key="date_end", value="1325433600000")
   
   
   def print_stuff(date_start, date_end):
       print(date_start)
       print(date_end)
   
   
   dag = DAG("mwe", start_date=days_ago(14))
   
   with dag:
       op = PythonOperator(task_id="gen_build_time", python_callable=gen_build_time)
       op2 = PythonOperator(
           task_id="print_stuff",
           python_callable=print_stuff,
           op_kwargs={"date_start": op.output["date_start"], "date_end": op.output["date_end"]},
       )
   ```
   
   ![image](https://user-images.githubusercontent.com/48934154/126538640-67b81e31-9517-41aa-b23f-ba1fa91e74fa.png)
   




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org