Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file.
Empty file.
25 changes: 25 additions & 0 deletions airflow/dags/example_dags/print/dag.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
"""Example DAG demonstrating the usage of the BashOperator."""
from __future__ import annotations

import logging
from datetime import datetime

from airflow.decorators import dag
from example_dags.print.tasks import print_context, print_finish, print_params

logger = logging.getLogger(__name__)


@dag(
schedule="@daily",
start_date=datetime(2021, 12, 1),
catchup=False,
dag_id="print",
)
def taskflow():
r1 = print_context()
r2 = print_params(r1)
print_finish(r2)


taskflow()
3 changes: 3 additions & 0 deletions airflow/dags/example_dags/print/tasks/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from .print_context import print_context
from .print_finish import print_finish
from .print_params import print_params
12 changes: 12 additions & 0 deletions airflow/dags/example_dags/print/tasks/print_context.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import logging
from pprint import pformat

from airflow.decorators import task

logger = logging.getLogger(__name__)


@task
def print_context(**context) -> dict:
logger.info("PARAMS: " + pformat(context))
return context.get("params", {}) or {"empty": True}
10 changes: 10 additions & 0 deletions airflow/dags/example_dags/print/tasks/print_finish.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import logging

from airflow.decorators import task

logger = logging.getLogger(__name__)


@task
def print_finish(data: str):
logger.info(data.upper())
16 changes: 16 additions & 0 deletions airflow/dags/example_dags/print/tasks/print_params.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import logging
from pprint import pformat

from airflow.decorators import task

logger = logging.getLogger(__name__)


@task
def print_params(data: dict, **kwargs) -> str:
logger.info("PARAMS: " + pformat(data))
logger.info("KWARGS: " + pformat(kwargs))
return "finish"


""
31 changes: 0 additions & 31 deletions airflow/dags/print_operator.py

This file was deleted.