Skip to content

Instantly share code, notes, and snippets.

@chenhan1218
Last active December 3, 2019 07:55
Show Gist options
  • Save chenhan1218/b6e6502aada94a402f51bb02b811e585 to your computer and use it in GitHub Desktop.
Save chenhan1218/b6e6502aada94a402f51bb02b811e585 to your computer and use it in GitHub Desktop.
Airflow print context
from datetime import datetime, timedelta
from airflow import DAG
from airflow.operators.dummy_operator import DummyOperator
from airflow.operators.python_operator import PythonOperator
default_args = {
"depends_on_past": False,
"start_date": datetime(2019, 8, 1),
}
def f1(tzinfo: datetime.tzinfo = None, **context):
for key in context:
print((key, context[key]))
with DAG(
"echo_context", catchup=False, default_args=default_args, schedule_interval="@daily"
) as dag:
t1 = PythonOperator(task_id="t1", provide_context=True, python_callable=f1, dag=dag)
t2 = DummyOperator(task_id="t2", dag=dag)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment