From dcff0ca749f44dbebde986aca02d18d99a20fd0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Beltr=C3=A1n=20Mora?= <94113100+dbeltrankyl@users.noreply.github.com> Date: Thu, 28 Nov 2024 14:35:10 +0100 Subject: [PATCH] Fix a bug when normalized function is called with already normalized data ( when there are multiple files this can happen) (#55) --- autosubmitconfigparser/config/configcommon.py | 15 ++++++++------- test/unit/test_deep_normalize.py | 2 ++ test/unit/test_normalize_variables.py | 2 ++ 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/autosubmitconfigparser/config/configcommon.py b/autosubmitconfigparser/config/configcommon.py index 3e2bc94..fc56c9e 100644 --- a/autosubmitconfigparser/config/configcommon.py +++ b/autosubmitconfigparser/config/configcommon.py @@ -600,13 +600,14 @@ def _normalize_dependencies(dependencies: Union[str, dict]) -> dict: aux_dependencies[dependency.upper()] = dependency_data if type(dependency_data) is dict and dependency_data.get("STATUS", None): dependency_data["STATUS"] = dependency_data["STATUS"].upper() - if dependency_data["STATUS"][-1] == "?": - dependency_data["STATUS"] = dependency_data["STATUS"][:-1] - dependency_data["ANY_FINAL_STATUS_IS_VALID"] = True - elif dependency_data["STATUS"] not in ["READY", "DELAYED", "PREPARED", "SKIPPED", "FAILED", "COMPLETED"]: # May change in future issues. - dependency_data["ANY_FINAL_STATUS_IS_VALID"] = True - else: - dependency_data["ANY_FINAL_STATUS_IS_VALID"] = False + if not dependency_data.get("ANY_FINAL_STATUS_IS_VALID", False): + if dependency_data["STATUS"][-1] == "?": + dependency_data["STATUS"] = dependency_data["STATUS"][:-1] + dependency_data["ANY_FINAL_STATUS_IS_VALID"] = True + elif dependency_data["STATUS"] not in ["READY", "DELAYED", "PREPARED", "SKIPPED", "FAILED", "COMPLETED"]: # May change in future issues. + dependency_data["ANY_FINAL_STATUS_IS_VALID"] = True + else: + dependency_data["ANY_FINAL_STATUS_IS_VALID"] = False return aux_dependencies diff --git a/test/unit/test_deep_normalize.py b/test/unit/test_deep_normalize.py index c45b115..4d095c5 100644 --- a/test/unit/test_deep_normalize.py +++ b/test/unit/test_deep_normalize.py @@ -69,3 +69,5 @@ def test_normalize_variables(autosubmit_config, data, expected_data): as_conf = autosubmit_config(expid='t000', experiment_data=data) normalized_data = as_conf.deep_normalize(data) assert normalized_data == expected_data + normalized_data = as_conf.deep_normalize(normalized_data) + assert normalized_data == expected_data diff --git a/test/unit/test_normalize_variables.py b/test/unit/test_normalize_variables.py index 8053ac9..8528782 100644 --- a/test/unit/test_normalize_variables.py +++ b/test/unit/test_normalize_variables.py @@ -287,3 +287,5 @@ def test_normalize_variables(autosubmit_config, data, expected_data, must_exists as_conf = autosubmit_config(expid='t000', experiment_data=data) normalized_data = as_conf.normalize_variables(data, must_exists=must_exists) assert normalized_data == expected_data + normalized_data = as_conf.normalize_variables(normalized_data, must_exists=must_exists) + assert normalized_data == expected_data