Skip to content

Instantly share code, notes, and snippets.

@agalea91
Last active September 17, 2020 05:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save agalea91/734cc17e9e840ffb29e3abf6a82dacbf to your computer and use it in GitHub Desktop.
Save agalea91/734cc17e9e840ffb29e3abf6a82dacbf to your computer and use it in GitHub Desktop.
For medium blog post: Airflow Dynamic DAGs - Python Globals
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