This is an automated email from the ASF dual-hosted git repository.

ephraimanierobi pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/main by this push:
     new de9b02f  Updating the Elasticsearch example DAG to use the TaskFlow 
API (#18565)
de9b02f is described below

commit de9b02f797931efbd081996b4f81ba14ca76a17d
Author: Josh Fell <48934154+josh-f...@users.noreply.github.com>
AuthorDate: Tue Sep 28 04:42:52 2021 -0400

    Updating the Elasticsearch example DAG to use the TaskFlow API (#18565)
---
 .../example_dags/example_elasticsearch_query.py         | 17 ++++-------------
 1 file changed, 4 insertions(+), 13 deletions(-)

diff --git 
a/airflow/providers/elasticsearch/example_dags/example_elasticsearch_query.py 
b/airflow/providers/elasticsearch/example_dags/example_elasticsearch_query.py
index b0efea7..d4a7b10 100644
--- 
a/airflow/providers/elasticsearch/example_dags/example_elasticsearch_query.py
+++ 
b/airflow/providers/elasticsearch/example_dags/example_elasticsearch_query.py
@@ -18,10 +18,11 @@
 from datetime import datetime, timedelta
 
 from airflow import DAG
-from airflow.operators.python import PythonOperator
+from airflow.decorators import task
 from airflow.providers.elasticsearch.hooks.elasticsearch import 
ElasticsearchHook
 
 
+@task(task_id='es_print_tables')
 def show_tables():
     """
     show_tables queries elasticsearch to list available tables
@@ -36,24 +37,14 @@ def show_tables():
     return True
 
 
-# Default settings applied to all tasks
-default_args = {
-    'owner': 'airflow',
-    'depends_on_past': False,
-    'email_on_failure': False,
-    'email_on_retry': False,
-    'retries': 1,
-    'retry_delay': timedelta(minutes=5),
-}
-
 # Using a DAG context manager, you don't have to specify the dag property of 
each task
 with DAG(
     'elasticsearch_dag',
     start_date=datetime(2021, 8, 30),
     max_active_runs=1,
     schedule_interval=timedelta(days=1),
-    default_args=default_args,
+    default_args={'retries': 1},  # Default setting applied to all tasks
     catchup=False,
 ) as dag:
 
-    es_tables = PythonOperator(task_id='es_print_tables', 
python_callable=show_tables)
+    show_tables()

Reply via email to