Skip to content

Instantly share code, notes, and snippets.

@ifuller1
Created November 11, 2018 20:01
Show Gist options
  • Save ifuller1/83b0eb582c6d3aa314cee1ee16b7ee48 to your computer and use it in GitHub Desktop.
Save ifuller1/83b0eb582c6d3aa314cee1ee16b7ee48 to your computer and use it in GitHub Desktop.
import logging
import datetime
from airflow import DAG
from airflow import models
from airflow.operators.python_operator import PythonOperator
YESTERDAY = datetime.datetime.combine(
datetime.datetime.today() - datetime.timedelta(1),
datetime.datetime.min.time())
def say_hello_method(**_context):
logging.info('Hello Cloud Composer!')
DEFAULT_ARGS = {
# Setting start date as yesterday starts the DAG immediately when it is
# detected in the Cloud Storage bucket.
'start_date': YESTERDAY,
'email_on_failure': False,
'email_on_retry': False,
'retries': 2,
'retry_delay': datetime.timedelta(minutes=1),
'project_id': models.Variable.get('gcp_project')
}
with DAG('example',
default_args=DEFAULT_ARGS,
schedule_interval=datetime.timedelta(minutes=20),
catchup=False
) as dag:
say_hello_task = PythonOperator(
task_id='say_hello',
python_callable=say_hello_method,
provide_context=True
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment