From d71f454bb78655d83de79cbc067742290927912d Mon Sep 17 00:00:00 2001 From: tm689 <tm689@cam.ac.uk> Date: Mon, 20 May 2024 14:34:20 +0100 Subject: [PATCH] feat: handle different source gen config files based on group name. --- ews/coordinator/processor_surveys.py | 11 +++++++++-- .../configs/config_EastAfrica_fc_live.json | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/ews/coordinator/processor_surveys.py b/ews/coordinator/processor_surveys.py index ffc2355..30ab67b 100644 --- a/ews/coordinator/processor_surveys.py +++ b/ews/coordinator/processor_surveys.py @@ -327,8 +327,15 @@ class ProcessorSurveys(ProcessorBase): output_directory = f"{jobPath}/source_gen/{group_name}" Path(output_directory).mkdir(parents=True, exist_ok=True) + if 'SourcesConfigs' in config['Survey'] and group_name in config['Survey']['SourcesConfigs']: + logger.info(f"Running source gen for {group_name} group wih config {config['Survey']['SourcesConfigs'][group_name]}") + sources_config = config['Survey']['SourcesConfigs'][group_name] + else: + logger.info(f"Running source gen for {group_name} group wih default config {config['Survey']['SourcesConfigDefault']}") + sources_config = config['Survey']['SourcesConfigDefault'] + sources_path = run_case( - config_path = config['Survey']['SourcesConfigFilename'], + config_path = sources_config, survey_path = group_surveys_filepath, survey_format = config['Survey']['SurveyFormat'], surveyor_name_col = config['Survey']['SurveyorNameCol'], @@ -367,7 +374,7 @@ class ProcessorSurveys(ProcessorBase): Path(output_directory).mkdir(parents=True, exist_ok=True) sources_path = run_case( - config_path = config['Survey']['SourcesConfigFilename'], + config_path = config['Survey']['SourcesConfigDefault'], survey_path = processed_surveys_filepath, survey_format = config['Survey']['SurveyFormat'], surveyor_name_col = config['Survey']['SurveyorNameCol'], diff --git a/tests/test_data/test_deployment/regions/EastAfrica/resources/coordinator/configs/config_EastAfrica_fc_live.json b/tests/test_data/test_deployment/regions/EastAfrica/resources/coordinator/configs/config_EastAfrica_fc_live.json index 10881b4..2df9315 100644 --- a/tests/test_data/test_deployment/regions/EastAfrica/resources/coordinator/configs/config_EastAfrica_fc_live.json +++ b/tests/test_data/test_deployment/regions/EastAfrica/resources/coordinator/configs/config_EastAfrica_fc_live.json @@ -47,7 +47,7 @@ "SurveyFormat" : "ODK", "SurveyorNameCol" : "surveyor_infromation-surveyor_name", "SourcesRegionName" : "EastAfrica", - "SourcesConfigFilename" : "../../test_data/test_deployment/regions/EastAfrica/resources/source_gen/configs/config_EastAfrica_mapspam2017.json" + "SourcesConfigDefault" : "../../test_data/test_deployment/regions/EastAfrica/resources/source_gen/configs/config_EastAfrica_mapspam2017.json" }, "Environment" : { "ServerPathTemplate" : "/storage/sftp/metofficeupload/upload/Ethiopia/fromMO/daily_name/", -- GitLab