Last active
December 3, 2019 07:55
-
-
Save chenhan1218/b6e6502aada94a402f51bb02b811e585 to your computer and use it in GitHub Desktop.
Airflow print context
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 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