From 3f9fd65f1790de7a31cc3472a1677480eea88cfd Mon Sep 17 00:00:00 2001 From: econdami Date: Fri, 6 Dec 2024 16:52:43 +0100 Subject: [PATCH 1/3] capsul adaptation for populse_db --- capsul/engine/settings.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/capsul/engine/settings.py b/capsul/engine/settings.py index e50a3037..de370e95 100644 --- a/capsul/engine/settings.py +++ b/capsul/engine/settings.py @@ -273,10 +273,8 @@ def export_config_dict(self, environment=None): env_conf = {} for module in modules: mod_conf = {} - for config in session.configs(module, env): - id = "%s-%s" % (config._id, env) - doc = data[session.collection_name(module)][id] - items = dict(doc._items()) + for cf_i, config in enumerate(session.configs(module, env)): + items = data[session.collection_name(module)].get()[cf_i] if "config_id" in items: items["config_id"] = items["config_id"][: -len(env) - 1] mod_conf[config._id] = items From 99464d072a90ef5a3699c2a19c04104786327bd3 Mon Sep 17 00:00:00 2001 From: econdami Date: Mon, 9 Dec 2024 13:24:59 +0100 Subject: [PATCH 2/3] Changes requested in PR: https://github.com/populse/capsul/pull/366 --- capsul/engine/settings.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/capsul/engine/settings.py b/capsul/engine/settings.py index de370e95..58ac7da9 100644 --- a/capsul/engine/settings.py +++ b/capsul/engine/settings.py @@ -273,8 +273,10 @@ def export_config_dict(self, environment=None): env_conf = {} for module in modules: mod_conf = {} - for cf_i, config in enumerate(session.configs(module, env)): - items = data[session.collection_name(module)].get()[cf_i] + for config in session.configs(module, env): + id = f"{config._id}-{env}" + doc = data[session.collection_name(module)][id] + items = dict(doc.get()) if "config_id" in items: items["config_id"] = items["config_id"][: -len(env) - 1] mod_conf[config._id] = items From 3fe4271f9786c0518c300db05bb75e61997ab0e7 Mon Sep 17 00:00:00 2001 From: econdami Date: Mon, 9 Dec 2024 14:10:49 +0100 Subject: [PATCH 3/3] final change for PR: https://github.com/populse/capsul/pull/366 --- capsul/engine/settings.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/capsul/engine/settings.py b/capsul/engine/settings.py index 58ac7da9..4a1b9f47 100644 --- a/capsul/engine/settings.py +++ b/capsul/engine/settings.py @@ -275,11 +275,10 @@ def export_config_dict(self, environment=None): mod_conf = {} for config in session.configs(module, env): id = f"{config._id}-{env}" - doc = data[session.collection_name(module)][id] - items = dict(doc.get()) - if "config_id" in items: - items["config_id"] = items["config_id"][: -len(env) - 1] - mod_conf[config._id] = items + doc = data[session.collection_name(module)][id].get() + if "config_id" in doc: + doc["config_id"] = doc["config_id"][: -len(env) - 1] + mod_conf[config._id] = doc if mod_conf: env_conf[module] = mod_conf