我可以在PythonOperator中使用宏吗?我试着跟着,但我无法得到渲染的宏!Airflow Python运算符中的宏
dag = DAG(
'temp',
default_args=default_args,
description='temp dag',
schedule_interval=timedelta(days=1))
def temp_def(a, b, **kwargs):
print '{{ds}}'
print '{{execution_date}}'
print 'a=%s, b=%s, kwargs=%s' % (str(a), str(b), str(kwargs))
ds = '{{ ds }}'
mm = '{{ execution_date }}'
t1 = PythonOperator(
task_id='temp_task',
python_callable=temp_def,
op_args=[mm , ds],
provide_context=False,
dag=dag)
我们可以标记这是正确的答案吗?因为它是正确的答案 –
为了向后兼容,你可以像这样'template_fields':'template_fields = PythonOperator.template_fields +('op_args',)''。顺便说一句,我打开了一个[JIRA来添加'op_args'和'op_kwargs'到'PythonOperator'模板字段](https://issues.apache.org/jira/browse/AIRFLOW-1814) –