Reputation: 3108
Im planning to use an airflow operator inside a function and then call it from a different task. For me, the task ran successfully, but it didn't trigger the operator inside the function.
def func():
t1 = BashOperator(
task_id='print_date',
bash_command='touch /tmp/aaaaaaaaaaaaa'
)
t1
main_dag = DAG(
'bhuvitest',
default_args=args,
description='A simple tutorial DAG',
schedule_interval=timedelta(days=1),
catchup=False
)
bhuvitest = PythonOperator(
task_id='python_task',
python_callable=func,
dag = main_dag)
Upvotes: 0
Views: 4862
Reputation: 2936
The following should work instead of t1
:
t1.execute(dict())
The airflow.operators documentation can give more details.
Upvotes: 2