Skip to content

Instantly share code, notes, and snippets.

@BoHuang2018
Forked from tameem92/multitenany_snippet.py
Last active April 7, 2022 20:36
Show Gist options
  • Save BoHuang2018/fde3a019189f4af45303069a193dba12 to your computer and use it in GitHub Desktop.
Save BoHuang2018/fde3a019189f4af45303069a193dba12 to your computer and use it in GitHub Desktop.
VERSION='v1.0.3'
# DAG Factory
factory = DAGFactory(config.environment)
the_first_dag = factory.create('Module_1').build()
process_messages_dag = factory.create('Module_2').build()
def create_main_dag(dag_id, org_config):
with DAG(dag_id=f'main_{VERSION}',
default_args=default_args,
...
) as dag:
# Reconfigure the dag object as a subdag
# under our main dag
task_1 = SubDagOperator(
task_id='task_1',
subdag=sub_dag_1,
)
task_2 = SubDagOperator(
task_id='task_2',
subdag=sub_dag_2,
)
return dag
# Loop over dynamic config and auto generate
# dags for each client.
for client_config in client_configs:
parsed_client_config = config.parse_config(client_config)
main_dag_id = f"{client_config['identifier']}_main_{VERSION}"
globals()[main_dag_id] = create_main_dag(
main_dag_id,
parsed_client_config
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment