yuqian90 commented on issue #12757: URL: https://github.com/apache/airflow/issues/12757#issuecomment-739147569
Thanks @kaxil and @ielizarov. This issue can be reproduced with a simpler example like this. I put up a fix in https://github.com/apache/airflow/pull/12829 ```python from airflow import DAG from airflow.operators.dummy_operator import DummyOperator from airflow.utils.dates import days_ago dag = DAG(dag_id='example_graph_view_issue', start_date=days_ago(2)) op1 = DummyOperator(task_id='op1', dag=dag) op2 = DummyOperator(task_id='op2') op1 >> op2 ``` While this is indeed an inconsistent behaviour and the fix is straightforward, I wonder why we wanted to support ambiguous usage like this. It would be much cleaner for the user to set the dag properly for each task. Or they can also use context manager to create the DAG to avoid this issue. I find the following much cleaner: ```python from airflow import DAG from airflow.operators.dummy_operator import DummyOperator from airflow.utils.dates import days_ago with DAG(dag_id='example_graph_view_issue', start_date=days_ago(2)) as dag: op1 = DummyOperator(task_id='op1') op2 = DummyOperator(task_id='op2') op1 >> op2 ``` ---------------------------------------------------------------- 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: [email protected]
