ephraimbuddy commented on issue #17686:
URL: https://github.com/apache/airflow/issues/17686#issuecomment-931725335
I made a bunch of mistakes trying to make this work until I looked at the
non-taskflow example.
This should work for taskflow:
```python
from datetime import datetime, timedelta
from airflow.decorators import dag
from airflow.decorators import task
def get_run_date():
return '01-01-2021'
default_args = {
'owner': 'airflow',
'depends_on_past': False,
'email_on_failure': False,
'email_on_retry': False,
'retries': 1,
'retry_delay': timedelta(minutes=5)
}
@dag(default_args=default_args,
schedule_interval=None,
start_date=datetime(2021, 8, 1),
dagrun_timeout=timedelta(hours=4),
max_active_runs=1)
def xcomm_taskflow_dag():
@task()
def set_date():
date ="1-2-21"
return date
@task()
def xcomm_task2(**kwargs):
date=kwargs['ti'].xcom_pull(task_ids="set_date")
print(f"xcomm_task2:{date}")
@task()
def xcomm_task3(**kwargs):
date=kwargs['ti'].xcom_pull(task_ids="set_date")
print(f"xcomm_task3:{date}")
set_date() >> xcomm_task2() >> xcomm_task3()
xcomm_taskflow_dag=xcomm_taskflow_dag()
```
--
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]