josh-fell commented on a change in pull request #18278:
URL: https://github.com/apache/airflow/pull/18278#discussion_r710448830
##########
File path: airflow/providers/apache/kylin/example_dags/example_kylin_dag.py
##########
@@ -21,110 +21,92 @@
The tasks below include kylin build, refresh, merge operation.
"""
from airflow import DAG
-from airflow.operators.python import PythonOperator
from airflow.providers.apache.kylin.operators.kylin_cube import
KylinCubeOperator
from airflow.utils.dates import days_ago
dag = DAG(
dag_id='example_kylin_operator',
schedule_interval=None,
start_date=days_ago(1),
+ default_args={'kylin_conn_id': 'kylin_default', 'project': 'learn_kylin',
'cube': 'kylin_sales_cube'},
tags=['example'],
)
-def gen_build_time(**kwargs):
[email protected]
+def gen_build_time():
"""
- Gen build time and push to xcom
- :param kwargs:
- :return:
+ Gen build time and push to xcom (with key of "return_value")
+ :return: A dict with build time values.
"""
- ti = kwargs['ti']
- ti.xcom_push(key='date_start', value='1325347200000')
- ti.xcom_push(key='date_end', value='1325433600000')
+ return {'date_start': '1325347200000', 'date_end': '1325433600000'}
-gen_build_time_task = PythonOperator(python_callable=gen_build_time,
task_id='gen_build_time', dag=dag)
+gen_build_time_task = gen_build_time()
+date_start = gen_build_time_task['date_start']
+date_end = gen_build_time_task['date_end']
build_task1 = KylinCubeOperator(
task_id="kylin_build_1",
- kylin_conn_id='kylin_default',
- project='learn_kylin',
- cube='kylin_sales_cube',
command='build',
- start_time=gen_build_time_task.output['date_start'],
- end_time=gen_build_time_task.output['date_end'],
+ start_time=date_start,
+ end_time=date_end,
Review comment:
Good point. The variable names are rather generic and may be instigating
the need to refer back to their values. We updated example DAGs that use a
shared operator `.output` to declare a variable first rather than writing
`op.output` in multiple places. Perhaps for consistency the latter option would
be better.
@turbaszek WDYT?
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]