fix: set permissive for all option in carry_out_calculation

This commit is contained in:
egarette@silique.fr 2025-12-23 20:00:00 +01:00
parent b7d97275e3
commit e39b8106be
5 changed files with 65 additions and 4 deletions

View file

@ -1032,6 +1032,22 @@ def test_requires_dyndescription_in_dyn():
# assert not list_sessions() # assert not list_sessions()
def test_requires_dyndescription_in_dyn_hidden():
str1 = StrOption('str1', '', "val", properties=('hidden',))
st = StrOption('st', '', Calculation(calc_value, Params(ParamOption(str1))))
dod = DynOptionDescription('dod', '', [str1, st], identifiers=Calculation(return_list))
od = OptionDescription('od', '', [dod])
od2 = OptionDescription('od', '', [od])
cfg = Config(od2)
cfg.property.read_write()
assert cfg.option('od.dodval1.st').value.get() is 'val'
assert cfg.option('od.dodval2.st').value.get() is 'val'
#
with pytest.raises(PropertiesOptionError):
cfg.option('od.dodval1.str1').value.get()
def calc_value_not_same(param, condition, expected, default, identifier): def calc_value_not_same(param, condition, expected, default, identifier):
if identifier == 'val1': if identifier == 'val1':
index = 0 index = 0

View file

@ -126,6 +126,22 @@ class CommonTiramisu(TiramisuHelp):
_validate_properties = True _validate_properties = True
def _set_subconfig(self) -> None: def _set_subconfig(self) -> None:
if self._subconfig:
if id(self._subconfig.config_bag) != id(self._config_bag):
subconfig = self._subconfig
self._subconfig = subconfig.__class__(option=subconfig.option,
index=subconfig.index,
path=subconfig.path,
config_bag=self._config_bag,
parent=subconfig.parent,
identifiers=subconfig.identifiers,
true_path=subconfig.true_path,
properties=subconfig.properties,
validate_properties=False,
check_dynamic_without_identifiers=False,
)
else:
self._subconfig._length = None
if not self._subconfig: if not self._subconfig:
try: try:
self._subconfig = self._config_bag.context.get_sub_config( self._subconfig = self._config_bag.context.get_sub_config(
@ -1390,6 +1406,20 @@ class TiramisuContextValue(TiramisuConfig, _TiramisuODGet):
root, root,
only_mandatory=True, only_mandatory=True,
): ):
if id(subconfig.config_bag) != id(config_bag):
subconfig = subconfig.__class__(option=subconfig.option,
index=subconfig.index,
path=subconfig.path,
config_bag=config_bag,
parent=subconfig.parent,
identifiers=subconfig.identifiers,
true_path=subconfig.true_path,
properties=subconfig.properties,
validate_properties=False,
check_dynamic_without_identifiers=False,
)
else:
subconfig._length = None
options.append( options.append(
TiramisuOption( TiramisuOption(
subconfig.path, subconfig.path,

View file

@ -862,6 +862,17 @@ def carry_out_calculation(
kwargs = {} kwargs = {}
config_bag = config_bag.copy() config_bag = config_bag.copy()
config_bag.set_permissive() config_bag.set_permissive()
subconfig = subconfig.__class__(option=subconfig.option,
index=subconfig.index,
path=subconfig.path,
config_bag=config_bag,
parent=subconfig.parent,
identifiers=subconfig.identifiers,
true_path=subconfig.true_path,
properties=subconfig.properties,
validate_properties=False,
check_dynamic_without_identifiers=False,
)
if callback_params: if callback_params:
for key, param in chain( for key, param in chain(
fake_items(callback_params.args), callback_params.kwargs.items() fake_items(callback_params.args), callback_params.kwargs.items()

View file

@ -512,7 +512,7 @@ class SubConfig:
option, option,
index, index,
path, path,
self.config_bag, config_bag,
self, self,
identifiers, identifiers,
properties=properties, properties=properties,
@ -562,8 +562,10 @@ class SubConfig:
self.identifiers, self.identifiers,
validate_properties=False, validate_properties=False,
) )
self._length = len(cconfig_bag.context.get_value(subconfig)) #FIXME
return self._length #self._length = len(cconfig_bag.context.get_value(subconfig))
length = len(cconfig_bag.context.get_value(subconfig))
return length
def get_common_child( def get_common_child(
self, self,
@ -638,6 +640,7 @@ class SubConfig:
validate_properties, validate_properties,
true_path=true_path, true_path=true_path,
check_dynamic_without_identifiers=check_dynamic_without_identifiers, check_dynamic_without_identifiers=check_dynamic_without_identifiers,
config_bag=config_bag,
) )
) )
parents = new_parents parents = new_parents
@ -649,6 +652,7 @@ class SubConfig:
index, index,
validate_properties, validate_properties,
check_dynamic_without_identifiers=check_dynamic_without_identifiers, check_dynamic_without_identifiers=check_dynamic_without_identifiers,
config_bag=config_bag,
) )
except PropertiesOptionError as err: except PropertiesOptionError as err:
ret = err ret = err

View file

@ -335,7 +335,7 @@ class Values:
subconfig, subconfig,
value, value,
) )
parent._length = len(value) # parent._length = len(value)
leader.follower_force_store_value( leader.follower_force_store_value(
value, value,
parent, parent,