diff --git a/test/test_duplicate_config.py b/test/test_duplicate_config.py index 4c042fc..f745fbc 100644 --- a/test/test_duplicate_config.py +++ b/test/test_duplicate_config.py @@ -3,7 +3,7 @@ from .autopath import do_autopath do_autopath() from tiramisu.setting import groups -from tiramisu import Config +from tiramisu import Config, MetaConfig from tiramisu import ChoiceOption, BoolOption, IntOption, \ StrOption, OptionDescription from .test_state import _diff_opts, _diff_conf @@ -72,3 +72,14 @@ def test_copy_force_store_value(): conf.option('creole.general.wantref').value.set(True) assert to_tuple(conf.value.exportation()) == (('creole.general.wantref',), (None,), (True,), ('user',)) assert to_tuple(conf2.value.exportation()) == (('creole.general.wantref',), (None,), (False,), ('forced',)) + + +def test_copy_force_store_value_metaconfig(): + descr = make_description() + meta = MetaConfig([], optiondescription=descr) + conf = meta.config.new(session_id='conf') + assert to_tuple(conf.value.exportation()) == (('creole.general.wantref',), (None,), (False,), ('forced',)) + assert to_tuple(meta.value.exportation()) == (('creole.general.wantref',), (None,), (False,), ('forced',)) + conf.option('creole.general.wantref').value.set(True) + assert to_tuple(conf.value.exportation()) == (('creole.general.wantref',), (None,), (True,), ('user',)) + assert to_tuple(meta.value.exportation()) == (('creole.general.wantref',), (None,), (False,), ('forced',)) diff --git a/tiramisu/api.py b/tiramisu/api.py index 44d4731..d7377e5 100644 --- a/tiramisu/api.py +++ b/tiramisu/api.py @@ -997,8 +997,10 @@ class TiramisuContextConfig(TiramisuContext): def _c_meta(self): return Config(self.config_bag.context.cfgimpl_get_meta()) - def _m_new(self, name): - return Config(self.config_bag.context.new_config(name)) + def _m_new(self, + session_id, + persistent=False): + return Config(self.config_bag.context.new_config(session_id=session_id, persistent=persistent)) def _m_list(self): return self._g_list() diff --git a/tiramisu/config.py b/tiramisu/config.py index 9b83096..4a27cb7 100644 --- a/tiramisu/config.py +++ b/tiramisu/config.py @@ -770,7 +770,7 @@ class KernelConfig(_CommonConfig): weakref.ref(self), ConfigBag(self), None) - if _duplicate is False and (force_settings is None or force_values is None): + if None in [force_settings, force_values]: self._impl_build_all_caches() self._impl_name = session_id @@ -986,12 +986,14 @@ class KernelMetaConfig(KernelGroupConfig): if not _duplicate: new_children = [] for child_session_id in children: + if not isinstance(child_session_id, str): + raise TypeError(_('MetaConfig with optiondescription must have ' + 'string has child, not {}').format(child_session_id)) new_children.append(KernelConfig(optiondescription, persistent=persistent, session_id=child_session_id)) children = new_children - else: - descr = optiondescription + descr = optiondescription for child in children: if not isinstance(child, _CommonConfig): try: @@ -1016,6 +1018,7 @@ class KernelMetaConfig(KernelGroupConfig): force_values=force_values, storage=storage, _descr=descr) + self._impl_build_all_caches() def set_value(self, path,