You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2020/12/31 13:56:54 UTC

[GitHub] [airflow] jmelot commented on a change in pull request #13297: Use DAG context manager in examples (#12894)

jmelot commented on a change in pull request #13297:
URL: https://github.com/apache/airflow/pull/13297#discussion_r550488423



##########
File path: airflow/example_dags/example_bash_operator.py
##########
@@ -29,47 +29,43 @@
     'owner': 'airflow',
 }
 
-dag = DAG(
+with DAG(
     dag_id='example_bash_operator',
     default_args=args,
     schedule_interval='0 0 * * *',
     start_date=days_ago(2),
     dagrun_timeout=timedelta(minutes=60),
     tags=['example', 'example2'],
     params={"example_key": "example_value"},
-)
+) as dag:
 
-run_this_last = DummyOperator(
-    task_id='run_this_last',
-    dag=dag,
-)
+    run_this_last = DummyOperator(
+        task_id='run_this_last',
+    )
+
+    # [START howto_operator_bash]
+    run_this = BashOperator(

Review comment:
       Thanks for the example, done! I went ahead and made this change in some other examples I hadn't modified as well (like in kubernetes.rst) that had similar indent issues.
   
   While I was looking at this, I noticed that further down in the bash.rst (and probably other documentation files), the context manager is not used in code blocks that were written directly into the documentation, like in the last example [here](https://github.com/apache/airflow/blob/96150401c1344e818d91084da057824afd630781/docs/apache-airflow/howto/operator/bash.rst). I could update the documentation wherever this occurs if you thought that made sense (wasn't sure if it would be too far out of the scope of the original issue, though).




----------------------------------------------------------------
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:
users@infra.apache.org