You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by po...@apache.org on 2021/09/29 15:44:49 UTC

[airflow] branch main updated: Updating the InfluxDB example DAG to use the TaskFlow API (#18596)

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

potiuk 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 e845275  Updating the InfluxDB example DAG to use the TaskFlow API (#18596)
e845275 is described below

commit e84527509e50f37dbbfb9c0698647a03c1a42c71
Author: Josh Fell <48...@users.noreply.github.com>
AuthorDate: Wed Sep 29 11:44:25 2021 -0400

    Updating the InfluxDB example DAG to use the TaskFlow API (#18596)
---
 .../providers/influxdb/example_dags/example_influxdb.py    | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/airflow/providers/influxdb/example_dags/example_influxdb.py b/airflow/providers/influxdb/example_dags/example_influxdb.py
index 73a4698..a6c160e 100644
--- a/airflow/providers/influxdb/example_dags/example_influxdb.py
+++ b/airflow/providers/influxdb/example_dags/example_influxdb.py
@@ -15,15 +15,17 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from datetime import datetime
+
+from airflow.decorators import task
 from airflow.models.dag import DAG
-from airflow.operators.python import PythonOperator
 from airflow.providers.influxdb.hooks.influxdb import InfluxDBHook
-from airflow.utils.dates import days_ago
 
 
+@task(task_id="influxdb_task")
 def test_influxdb_hook():
     bucket_name = 'test-influx'
-    influxdb_hook = InfluxDBHook("influxdb_default")
+    influxdb_hook = InfluxDBHook()
     client = influxdb_hook.get_conn()
     print(client)
     print(f"Organization name {influxdb_hook.org_name}")
@@ -48,10 +50,8 @@ def test_influxdb_hook():
 with DAG(
     dag_id='influxdb_example_dag',
     schedule_interval=None,
-    start_date=days_ago(2),
+    start_date=datetime(2021, 1, 1),
     max_active_runs=1,
     tags=['example'],
 ) as dag:
-    influxdb_task = PythonOperator(task_id="influxdb_task", python_callable=test_influxdb_hook)
-
-    influxdb_task
+    test_influxdb_hook()