-
-
Save BoHuang2018/fde3a019189f4af45303069a193dba12 to your computer and use it in GitHub Desktop.
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
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