Skip to content

Commit

Permalink
Updating the InfluxDB example DAG to use the TaskFlow API (#18596)
Browse files Browse the repository at this point in the history
  • Loading branch information
josh-fell committed Sep 29, 2021
1 parent ffd3cbd commit e845275
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions airflow/providers/influxdb/example_dags/example_influxdb.py
Expand Up @@ -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}")
Expand All @@ -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()

0 comments on commit e845275

Please sign in to comment.