turbaszek commented on a change in pull request #10587:
URL: https://github.com/apache/airflow/pull/10587#discussion_r508861073
##########
File path: docs/concepts.rst
##########
@@ -162,6 +162,31 @@ Example DAG with decorated style
html_content=email_info['body']
)
+DAG decorator
+-------------
+
+.. versionadded:: 2.0.0
+
+In addition to creating DAGs using context managed, in Airflow 2.0 you can
also create DAGs from a function.
+DAG decorator creates a DAG generator function. This function when called
returns a DAG.
+
+DAG decorator also sets up the parameters you have in the function as DAG
params. This allows you to parametrize
+your DAGs and set the parameters when triggering the DAG manually. See
+:ref:`Passing Parameters when triggering dags <dagrun:parameters>` to learn
how to pass parameters when triggering DAGs.
+
+Example DAG with decorator:
+
+.. exampleinclude:: /../airflow/example_dags/example_dag_decorator.py
+ :language: python
+ :dedent: 4
+ :start-after: [START dag_decorator_usage]
+ :end-before: [END dag_decorator_usage]
+
+.. note:: Note that Airflow will only load DAGs that appear in``globals()``.
Which means you need to make sure to have
+ a variable for your returned DAG in the module scope. Otherwise Airflow
won't detect your decorated DAG. In addition,
+ you may want to make your dag variable named ``DAG`` such that Airflow
doesn't skip this module when the
+ ``DAG_DISCOVERY_SAFE_MODE`` is activated.
Review comment:
Apart from this warning it would be good to add something like:
```
This will work:
dag = yout_dag_function()
but this will not:
yout_dag_function()
```
The system DAG should be runnable by `pytest
tests/core/test_example_dags_system.py -k example_dag_decorator`
----------------------------------------------------------------
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]