Created
August 4, 2022 17:12
-
-
Save goodbyegangster/0e383aa97b4ae15eb1b2dedf8c323116 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from datetime import datetime, timedelta | |
from textwrap import dedent | |
from airflow import DAG | |
from airflow.decorators import task | |
# define default arguments for operators. | |
default_args = { | |
"retries": 1, | |
"retry_delay": timedelta(minutes=5), | |
} | |
# instantiate a DAG. | |
with DAG( | |
"sample_test_dag", | |
default_args=default_args, | |
description="A sample test DAG", | |
schedule_interval=timedelta(days=1), | |
start_date=datetime(2022, 8, 1), | |
end_date=datetime(2022, 12, 31), | |
catchup=False, | |
tags=["sample"], | |
) as dag: | |
# add documentation to a DAG. | |
dag.doc_md = __doc__ | |
dag.doc_md = dedent( | |
"""This is a sample test DAG.""" | |
) | |
# define the task 1. | |
@task | |
def get_version() -> str: | |
import sys | |
print(f"print: {sys.version}") | |
return sys.version | |
get_version.doc_md = dedent( | |
"""This is a sample python task: get_version.""" | |
) | |
# define the task 2. | |
@task | |
def print_version(ver: str) -> None: | |
print(f"receive: {ver}") | |
return | |
print_version.doc_md = dedent( | |
"""This is a sample python task: print_version.""" | |
) | |
# setting up dependencies. | |
version = get_version() | |
print_version(version) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment