diff --git a/airflow/example_dags/example_trigger_target_dag.py b/airflow/example_dags/example_trigger_target_dag.py index cb9a0147d3..9d548813b1 100644 --- a/airflow/example_dags/example_trigger_target_dag.py +++ b/airflow/example_dags/example_trigger_target_dag.py @@ -1,6 +1,6 @@ -from airflow.operators import * +from airflow.operators import BashOperator, PythonOperator from airflow.models import DAG -from datetime import date, datetime, time, timedelta +from datetime import datetime import pprint pp = pprint.PrettyPrinter(indent=4) @@ -41,3 +41,9 @@ run_this = PythonOperator( provide_context=True, python_callable=run_this_func, dag=dag) + +# You can also access the DagRun object in templates +bash_task = BashOperator( + task_id="bash_task", + bash_command='echo "Here is the message: {{ dag_run.conf["message"] if dag_run else "" }}" ', + dag=dag) diff --git a/docs/code.rst b/docs/code.rst index ed3b62bf49..f3db3e6e2d 100644 --- a/docs/code.rst +++ b/docs/code.rst @@ -135,7 +135,7 @@ Variable Description represents the content of your ``airflow.cfg`` ``run_id`` the ``run_id`` of the current DAG run -``dag_run`` a reference to the DAG run object +``dag_run`` a reference to the DagRun object ``test_mode`` whether the task instance was called using the CLI's test subcommand ================================= ==================================== diff --git a/docs/installation.rst b/docs/installation.rst index 351b58353b..03b305acfc 100644 --- a/docs/installation.rst +++ b/docs/installation.rst @@ -247,12 +247,15 @@ For any queries/bugs on `MesosExecutor`, please contact `@kapil-malik