This however is not working properly and I should admit that it is my first time working with python. Any help would be very useful. I have put together a test DAG to do the following but it does not work :
- run task t1 and return a value
- run task t2 if value from 1 is ALL_SUCCESS
from datetime import datetime
from airflow.models import DAG
from airflow.operators.bash_operator import BashOperator
def set_trigger(taskid, **kwargs):
xcomValue = {{ task_instance.xcom_pull(task_ids=taskid) }}
print( xcomValue, " <------- LOOK HERE XCOM VAR")
if(xcomValue == "0"):
return TriggerRule.ALL_SUCCESS
return TriggerRule.ALL_FAILED
dag = DAG(dag_id="example_bash_operator", schedule_interval=None, start_date=datetime(2018, 12, 31) ) as dag:
t1 = BashOperator(
task_id="t1",
bash_command='do something && echo 0 ',
dag=dag
)
t2 = BashOperator(
task_id="t2",
bash_command='do something else here ',
trigger_rule=set_trigger,
dag=dag,
)
t1 >> t2
```