Created
November 17, 2020 18:11
-
-
Save lakshay-arora/01ec1629a04fce2142810c5a4f4ee0ba 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 timedelta | |
# The DAG object; we'll need this to instantiate a DAG | |
from airflow import DAG | |
# Operators; we need this to operate! | |
from airflow.operators.bash_operator import BashOperator | |
from airflow.utils.dates import days_ago |
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
# You can override them on a per-task basis during operator initialization | |
default_args = { | |
'owner': 'lakshay', | |
'depends_on_past': False, | |
'start_date': days_ago(2), | |
'email': ['[email protected]'], | |
'email_on_failure': False, | |
'email_on_retry': False, | |
'retries': 1, | |
'retry_delay': timedelta(minutes=5), | |
# 'queue': 'bash_queue', | |
# 'pool': 'backfill', | |
# 'priority_weight': 10, | |
# 'end_date': datetime(2016, 1, 1), | |
# 'wait_for_downstream': False, | |
# 'dag': dag, | |
# 'sla': timedelta(hours=2), | |
# 'execution_timeout': timedelta(seconds=300), | |
# 'on_failure_callback': some_function, | |
# 'on_success_callback': some_other_function, | |
# 'on_retry_callback': another_function, | |
# 'sla_miss_callback': yet_another_function, | |
# 'trigger_rule': 'all_success' | |
} |
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
# define the DAG | |
dag = DAG( | |
'live_cricket_scores', | |
default_args=default_args, | |
description='First example to get Live Cricket Scores', | |
schedule_interval=timedelta(days=1), | |
) |
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
# define the first task | |
t1 = BashOperator( | |
task_id='print', | |
bash_command='echo Getting Live Cricket Scores!!!', | |
dag=dag, | |
) | |
# define the second task | |
t2 = BashOperator( | |
task_id='get_cricket_scores', | |
bash_command='cricket scores', | |
dag=dag, | |
) | |
# task pipeline | |
t1 >> t2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment