diff --git a/VERSION b/VERSION index e9acec7..e7468c7 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.0.75 +1.0.76 diff --git a/autosubmitconfigparser/config/configcommon.py b/autosubmitconfigparser/config/configcommon.py index 22a4f66..5c5126d 100644 --- a/autosubmitconfigparser/config/configcommon.py +++ b/autosubmitconfigparser/config/configcommon.py @@ -552,6 +552,20 @@ def _normalize_wrappers_section(data_fixed: dict) -> None: data_fixed["WRAPPERS"][wrapper]["JOBS_IN_WRAPPER"] = jobs_in_wrapper.upper() data_fixed["WRAPPERS"][wrapper]["TYPE"] = str(wrapper_data.get("TYPE", "vertical")).lower() + @staticmethod + def _normalize_notify_on(data_fixed: dict, job_section) -> None: + """ + Normalize the NOTIFY_ON section to a consistent format. + """ + notify_on = data_fixed["JOBS"][job_section].get("NOTIFY_ON", "") + if notify_on: + if type(notify_on) is str: + if "," in notify_on: + notify_on = notify_on.split(",") + else: + notify_on = notify_on.split() + data_fixed["JOBS"][job_section]["NOTIFY_ON"] = [status.strip(" ").upper() for status in notify_on] + def _normalize_jobs_section(self, data_fixed: dict, must_exists: bool ) -> None: for job, job_data in data_fixed.get("JOBS", {}).items(): if "DEPENDENCIES" in job_data or must_exists: @@ -575,6 +589,8 @@ def _normalize_jobs_section(self, data_fixed: dict, must_exists: bool ) -> None: if "ADDITIONAL_FILES" not in data_fixed["JOBS"][job] and must_exists: data_fixed["JOBS"][job]["ADDITIONAL_FILES"] = [] + self._normalize_notify_on(data_fixed, job) + @staticmethod def _normalize_dependencies(dependencies: Union[str, dict]) -> dict: """ diff --git a/test/unit/test_normalize_variables.py b/test/unit/test_normalize_variables.py index 8528782..84a5bd8 100644 --- a/test/unit/test_normalize_variables.py +++ b/test/unit/test_normalize_variables.py @@ -282,6 +282,94 @@ True, id="dependencies_status" ), + pytest.param( + { + "JOBS": { + "job1": { + "FILE": "FILE1", + "NOTIFY_ON": ["running", "COmpLETED"] + } + } + }, + { + 'JOBS': { + 'JOB1': { + 'FILE': 'FILE1', + 'ADDITIONAL_FILES': [], + 'DEPENDENCIES': {}, + 'NOTIFY_ON': ['RUNNING', 'COMPLETED'], + }, + } + }, + True, + id="notify_on_list" + ), + pytest.param( + { + "JOBS": { + "job1": { + "FILE": "FILE1", + "NOTIFY_ON": "running, COmpLETED" + } + } + }, + { + 'JOBS': { + 'JOB1': { + 'FILE': 'FILE1', + 'ADDITIONAL_FILES': [], + 'DEPENDENCIES': {}, + 'NOTIFY_ON': ['RUNNING', 'COMPLETED'], + }, + } + }, + True, + id="notify_on_string_with_," + ), + pytest.param( + { + "JOBS": { + "job1": { + "FILE": "FILE1", + "NOTIFY_ON": "running COmpLETED" + } + } + }, + { + 'JOBS': { + 'JOB1': { + 'FILE': 'FILE1', + 'ADDITIONAL_FILES': [], + 'DEPENDENCIES': {}, + 'NOTIFY_ON': ['RUNNING', 'COMPLETED'], + }, + } + }, + True, + id="notify_on_string_without_," + ), + pytest.param( + { + "JOBS": { + "job1": { + "FILE": "FILE1", + "NOTIFY_ON": "running" + } + } + }, + { + 'JOBS': { + 'JOB1': { + 'FILE': 'FILE1', + 'ADDITIONAL_FILES': [], + 'DEPENDENCIES': {}, + 'NOTIFY_ON': ['RUNNING'], + }, + } + }, + True, + id="notify_on_string_single" + ), ]) def test_normalize_variables(autosubmit_config, data, expected_data, must_exists): as_conf = autosubmit_config(expid='t000', experiment_data=data)