Last active
September 17, 2020 05:48
-
-
Save agalea91/734cc17e9e840ffb29e3abf6a82dacbf to your computer and use it in GitHub Desktop.
For medium blog post: Airflow Dynamic DAGs - Python Globals
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
def create_dag(symbol): | |
with DAG( | |
"email_{}_price".format(symbol.lower()), | |
default_args={"start_date": "2020-01-01"}, | |
schedule_interval="0 0 * * *", | |
) as dag: | |
get_price_task = PythonOperator( | |
task_id="get_price", | |
python_callable=get_price, | |
op_kwargs=dict( | |
symbol="BTC", | |
), | |
) | |
email_price_task = PythonOperator( | |
task_id="email_price", | |
python_callable=email_price, | |
) | |
( | |
get_price_task | |
>> email_price_task | |
) | |
return dag | |
for symbol in ("BTC", "ETH", "LTC", "XLM"): | |
dag = create_dag(symbol=symbol) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment