You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2019/07/04 13:50:46 UTC
[GitHub] [airflow] ashb commented on issue #4291: [AIRFLOW-1488] Add the
TriggeredDagRunSensor operator
ashb commented on issue #4291: [AIRFLOW-1488] Add the TriggeredDagRunSensor operator
URL: https://github.com/apache/airflow/pull/4291#issuecomment-508489699
So the example you have in your dag
```python
def triggerchild():
dr = trigger_dag(TEST_DAG_CHILD)
return [dr.run_id]
t0 = PythonOperator(python_callable=triggerchild,
provide_context=True,
task_id='trigger_child')
t1 = TriggeredDagRunSensor(
task_id='sense_child',
trigger_task_id='trigger_child',
timeout=15,
poke_interval=1,
)
t2 = BashOperator(
task_id='do_stuff',
bash_command="echo 'finished'",
)
```
Can be written using the existing operators like this: The execution_date must already be unique (to the millisecond) for a dag.
```python
UNIQUE_EXEC_DATE = datetime(...)
def triggerchild(context, dro):
dro.run_id = "{}_{}".format(TEST_DAG_CHILD, UNIQUE_EXEC_DATE.isoformat())
return dro
t0 = TriggerDagRunOperator(
python_callable=triggerchild,
execution_date=UNIQUE_EXEC_DATE,
task_id='trigger_child')
t1 = ExternalTaskSensor(
task_id='sense_child',
execution_date_fn=lambda: UNIQUE_EXEC_DATE,
external_dag_id=
timeout=15,
poke_interval=1,
)
t2 = BashOperator(
task_id='do_stuff',
bash_command="echo 'finished'",
)
```
I don't think we need a whole separate operator that is very similar to the existing ones. Adding `external_run_id` to the existing ExternalTaskSensor would be a better change I think.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services