Does this only apply to DAGfiles? Eg https://airflow.apache.org/docs/apache-airflow/1.10.12/concepts.html#scope
You can use a `__del__` method that warns on collection - like an unawaited coroutine Also if you're in control of importing the dagfile you can record all created dags and report any that are missing from the globals of the module On Fri, Apr 29, 2022, 7:45 AM Malthe <[email protected]> wrote: > On Fri, 29 Apr 2022 at 06:38, Thomas Grainger <[email protected]> wrote: > > Can you show a run-able example of the successful and unsuccessful usage > of `with DAG(): ... `? > > from airflow import DAG > > # correct: > dag = DAG("my_dag") > > # incorrect: > DAG("my_dag") > > The with construct really has nothing to do with it, but it is a > common source of confusion: > > # incorrect > with DAG("my_dag"): > ... > > It is less obvious (to some) in this way that the entire DAG will not > be picked up. You will in fact have to write: > > # correct > with DAG("my_dag") as dag: > ... > > This way, you're capturing the DAG in the top-level scope which is the > requirement. >
_______________________________________________ Python-Dev mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-dev.python.org/ Message archived at https://mail.python.org/archives/list/[email protected]/message/PC3ZTY3COHM3XDOPO3KWWC3NYVCQ7SNH/ Code of Conduct: http://python.org/psf/codeofconduct/
