patricker commented on code in PR #24452:
URL: https://github.com/apache/airflow/pull/24452#discussion_r898213762
##########
docs/apache-airflow/dag-run.rst:
##########
@@ -265,8 +265,32 @@ Example of a parameterized DAG:
dag=dag,
)
+Example of a parameterized DAG that reads the configuration from the context:
+
+.. code-block:: python
+
+ import pendulum
+
+ from airflow import DAG
+ from airflow.operators.python import PythonOperator
+
+ dag = DAG(
+ "example_parameterized_dag",
+ schedule_interval=None,
+ start_date=pendulum.datetime(2021, 1, 1, tz="UTC"),
+ catchup=False,
+ )
+
+ def print_conf(**context):
+ conf1 = context['dag_run'].conf['conf1']
+ print(conf1)
+
+ parameterized_task = PythonOperator(
+ task_id="parameterized_task",
+ python_callable=print_conf,
+ dag=dag,
+ )
-**Note**: The parameters from ``dag_run.conf`` can only be used in a template
field of an operator.
Review Comment:
I put it back in as-is. Now that there is more than one example, it has the
context of being with a parameterized DAG example, so i think it makes more
sense.
--
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]