Skip to content

Instantly share code, notes, and snippets.

@duyet
Last active February 25, 2020 17:12
Show Gist options
  • Save duyet/30b94f3b02b64b6dd4abc071d6665a86 to your computer and use it in GitHub Desktop.
Save duyet/30b94f3b02b64b6dd4abc071d6665a86 to your computer and use it in GitHub Desktop.
from datetime import datetime
from airflow.models import DAG
from airflow.operators.dummy_operator import DummyOperator
from airflow.operators.python_operator import PythonOperator
DAG_OWNER = '[email protected]'
DAG_ID = 'dag_name'
SCHEDULE_INTERVAL = '@weekly'
default_args = {
'owner': DAG_OWNER,
'start_date': datetime(2020, 1, 1),
'executor_config': {
'KubernetesExecutor': {
'request_memory': '512Mi',
'limit_memory': '1Gi',
'request_cpu': '500m',
'limit_cpu': '1000m'
}
},
'retries': 3,
}
def python_task_callable(**kwargs):
pass
def create_dag():
dag = DAG(DAG_ID, default_args=default_args,
schedule_interval=SCHEDULE_INTERVAL)
start = DummyOperator(task_id='start', dag=dag)
python_task = PythonOperator(task_id='python_task',
provide_context=True,
python_callable=python_task_callable,
dag=dag)
complete = DummyOperator(task_id='complete', dag=dag)
start >> python_task >> complete
return dag
globals()[DAG_ID] = create_dag()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment