From 1bf7a48c1e9225de387537aa399df3a48f56dbf7 Mon Sep 17 00:00:00 2001 From: Maxime Boissonneault Date: Thu, 9 Feb 2023 13:54:01 +0000 Subject: [PATCH 1/5] added a test to raise an EasyBuildError if a value with a template is replaced by a value without template --- easybuild/framework/easyconfig/easyconfig.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/easybuild/framework/easyconfig/easyconfig.py b/easybuild/framework/easyconfig/easyconfig.py index 4d8fc2d782..0537e89a77 100644 --- a/easybuild/framework/easyconfig/easyconfig.py +++ b/easybuild/framework/easyconfig/easyconfig.py @@ -1780,6 +1780,10 @@ def get_ref(self, key): def __setitem__(self, key, value): """Set value of specified easyconfig parameter (help text & co is left untouched)""" if key in self._config: + # raise an error if we are replacing a value with templates by a value with templates resolved + if "%(" in self._config[key][0] and not "%(" in value: + raise EasyBuildError("Replacing value of templated parameter '%s' with a value with templates + resolved. Old value: %s, new value: %s" % (key, self._config[key][0], value)) self._config[key][0] = value else: raise EasyBuildError("Use of unknown easyconfig parameter '%s' when setting parameter value to '%s'", From 04148e81d3c24a5877a200438b0a577f1ddd5593 Mon Sep 17 00:00:00 2001 From: Maxime Boissonneault Date: Thu, 9 Feb 2023 13:56:42 +0000 Subject: [PATCH 2/5] appeasing hound --- easybuild/framework/easyconfig/easyconfig.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/easybuild/framework/easyconfig/easyconfig.py b/easybuild/framework/easyconfig/easyconfig.py index 0537e89a77..f89cb607c0 100644 --- a/easybuild/framework/easyconfig/easyconfig.py +++ b/easybuild/framework/easyconfig/easyconfig.py @@ -1781,9 +1781,9 @@ def __setitem__(self, key, value): """Set value of specified easyconfig parameter (help text & co is left untouched)""" if key in self._config: # raise an error if we are replacing a value with templates by a value with templates resolved - if "%(" in self._config[key][0] and not "%(" in value: - raise EasyBuildError("Replacing value of templated parameter '%s' with a value with templates - resolved. Old value: %s, new value: %s" % (key, self._config[key][0], value)) + if "%(" in self._config[key][0] and "%(" not in value: + raise EasyBuildError("Replacing value of templated parameter '%s' with a value with templates" + "resolved. Old value: %s, new value: %s" % (key, self._config[key][0], value)) self._config[key][0] = value else: raise EasyBuildError("Use of unknown easyconfig parameter '%s' when setting parameter value to '%s'", From e1308a56bed8446e87d189eae78d4ff88733a8b0 Mon Sep 17 00:00:00 2001 From: Maxime Boissonneault Date: Thu, 9 Feb 2023 14:17:34 +0000 Subject: [PATCH 3/5] handle non-string elements --- easybuild/framework/easyconfig/easyconfig.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/easybuild/framework/easyconfig/easyconfig.py b/easybuild/framework/easyconfig/easyconfig.py index f89cb607c0..d4ab49f3da 100644 --- a/easybuild/framework/easyconfig/easyconfig.py +++ b/easybuild/framework/easyconfig/easyconfig.py @@ -1781,7 +1781,7 @@ def __setitem__(self, key, value): """Set value of specified easyconfig parameter (help text & co is left untouched)""" if key in self._config: # raise an error if we are replacing a value with templates by a value with templates resolved - if "%(" in self._config[key][0] and "%(" not in value: + if "%(" in str(self._config[key][0]) and "%(" not in str(value): raise EasyBuildError("Replacing value of templated parameter '%s' with a value with templates" "resolved. Old value: %s, new value: %s" % (key, self._config[key][0], value)) self._config[key][0] = value From c3da536af5bf0c5ef2d3a12de072bc2e0dbd3f09 Mon Sep 17 00:00:00 2001 From: Maxime Boissonneault Date: Thu, 9 Feb 2023 15:00:53 +0000 Subject: [PATCH 4/5] maybe raising an EasyBuildError is too strong. Replacing with a warning in the logs --- easybuild/framework/easyconfig/easyconfig.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/easybuild/framework/easyconfig/easyconfig.py b/easybuild/framework/easyconfig/easyconfig.py index d4ab49f3da..619c58598f 100644 --- a/easybuild/framework/easyconfig/easyconfig.py +++ b/easybuild/framework/easyconfig/easyconfig.py @@ -1782,8 +1782,8 @@ def __setitem__(self, key, value): if key in self._config: # raise an error if we are replacing a value with templates by a value with templates resolved if "%(" in str(self._config[key][0]) and "%(" not in str(value): - raise EasyBuildError("Replacing value of templated parameter '%s' with a value with templates" - "resolved. Old value: %s, new value: %s" % (key, self._config[key][0], value)) + self.log.warning("Replacing value of templated parameter '%s' with a value with templates" + "resolved. Old value: %s, new value: %s" % (key, self._config[key][0], value)) self._config[key][0] = value else: raise EasyBuildError("Use of unknown easyconfig parameter '%s' when setting parameter value to '%s'", From 2e5357563ecea0db0826fc49ba8805737fdba0a3 Mon Sep 17 00:00:00 2001 From: Maxime Boissonneault Date: Thu, 16 Feb 2023 16:31:36 +0000 Subject: [PATCH 5/5] correct comment --- easybuild/framework/easyconfig/easyconfig.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/easybuild/framework/easyconfig/easyconfig.py b/easybuild/framework/easyconfig/easyconfig.py index 619c58598f..728e7f32a8 100644 --- a/easybuild/framework/easyconfig/easyconfig.py +++ b/easybuild/framework/easyconfig/easyconfig.py @@ -1780,7 +1780,7 @@ def get_ref(self, key): def __setitem__(self, key, value): """Set value of specified easyconfig parameter (help text & co is left untouched)""" if key in self._config: - # raise an error if we are replacing a value with templates by a value with templates resolved + # display a warning if we are replacing a value with templates by a value with templates resolved if "%(" in str(self._config[key][0]) and "%(" not in str(value): self.log.warning("Replacing value of templated parameter '%s' with a value with templates" "resolved. Old value: %s, new value: %s" % (key, self._config[key][0], value))