I have three tasks, 1. AddEMRStep 2. Sensor 3. SQLstep. I just want it to be created for two environments.
with dag:
run_this_task = PythonOperator(
task_id = "run_this",
python_callable=push_to_xcom,
provide_context=True,
retries=10,
retry_delay=timedelta(seconds=1)
)
run_this_task2 = PythonOperator(
task_id = "run_this2",
python_callable=run_this_func,
provide_context=True
)
run_this_task >> run_this_task2
Now I need to create these dags for multiple environments
I am trying to do soemthing like this
envs = ["stg","prod"]
How can i use a for loop to make it like this
with dag:
run_this_task_stg = PythonOperator(
task_id = "run_this_task_stg",
python_callable=push_to_xcom,
provide_context=True,
retries=10,
retry_delay=timedelta(seconds=1)
)
run_this_task2_stg = PythonOperator(
task_id = "run_this_task2_stg",
python_callable=run_this_func,
provide_context=True
)
run_this_task_prod = PythonOperator(
task_id = "run_this_task_prod",
python_callable=push_to_xcom,
provide_context=True,
retries=10,
retry_delay=timedelta(seconds=1)
)
run_this_task2_prod = PythonOperator(
task_id = "run_this_task2_prod",
python_callable=run_this_func,
provide_context=True
)
start >> run_this_task_stg >> run_this_task2_stg
start >> run_this_task_prod >> run_this_task2_prod
