Skip to content

Instantly share code, notes, and snippets.

@NicholasTurner23
Forked from lakshay-arora/airflow_import.py
Created November 20, 2020 07:37
Show Gist options
  • Save NicholasTurner23/48b08b27540ffd370c724ac67b03ff96 to your computer and use it in GitHub Desktop.
Save NicholasTurner23/48b08b27540ffd370c724ac67b03ff96 to your computer and use it in GitHub Desktop.
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
# 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'
}
# 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),
)
# 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