fix: set permissive for all option in carry_out_calculation
This commit is contained in:
parent
b7d97275e3
commit
e39b8106be
5 changed files with 65 additions and 4 deletions
|
|
@ -1032,6 +1032,22 @@ def test_requires_dyndescription_in_dyn():
|
|||
# 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):
|
||||
if identifier == 'val1':
|
||||
index = 0
|
||||
|
|
|
|||
|
|
@ -126,6 +126,22 @@ class CommonTiramisu(TiramisuHelp):
|
|||
_validate_properties = True
|
||||
|
||||
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:
|
||||
try:
|
||||
self._subconfig = self._config_bag.context.get_sub_config(
|
||||
|
|
@ -1390,6 +1406,20 @@ class TiramisuContextValue(TiramisuConfig, _TiramisuODGet):
|
|||
root,
|
||||
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(
|
||||
TiramisuOption(
|
||||
subconfig.path,
|
||||
|
|
|
|||
|
|
@ -862,6 +862,17 @@ def carry_out_calculation(
|
|||
kwargs = {}
|
||||
config_bag = config_bag.copy()
|
||||
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:
|
||||
for key, param in chain(
|
||||
fake_items(callback_params.args), callback_params.kwargs.items()
|
||||
|
|
|
|||
|
|
@ -512,7 +512,7 @@ class SubConfig:
|
|||
option,
|
||||
index,
|
||||
path,
|
||||
self.config_bag,
|
||||
config_bag,
|
||||
self,
|
||||
identifiers,
|
||||
properties=properties,
|
||||
|
|
@ -562,8 +562,10 @@ class SubConfig:
|
|||
self.identifiers,
|
||||
validate_properties=False,
|
||||
)
|
||||
self._length = len(cconfig_bag.context.get_value(subconfig))
|
||||
return self._length
|
||||
#FIXME
|
||||
#self._length = len(cconfig_bag.context.get_value(subconfig))
|
||||
length = len(cconfig_bag.context.get_value(subconfig))
|
||||
return length
|
||||
|
||||
def get_common_child(
|
||||
self,
|
||||
|
|
@ -638,6 +640,7 @@ class SubConfig:
|
|||
validate_properties,
|
||||
true_path=true_path,
|
||||
check_dynamic_without_identifiers=check_dynamic_without_identifiers,
|
||||
config_bag=config_bag,
|
||||
)
|
||||
)
|
||||
parents = new_parents
|
||||
|
|
@ -649,6 +652,7 @@ class SubConfig:
|
|||
index,
|
||||
validate_properties,
|
||||
check_dynamic_without_identifiers=check_dynamic_without_identifiers,
|
||||
config_bag=config_bag,
|
||||
)
|
||||
except PropertiesOptionError as err:
|
||||
ret = err
|
||||
|
|
|
|||
|
|
@ -335,7 +335,7 @@ class Values:
|
|||
subconfig,
|
||||
value,
|
||||
)
|
||||
parent._length = len(value)
|
||||
# parent._length = len(value)
|
||||
leader.follower_force_store_value(
|
||||
value,
|
||||
parent,
|
||||
|
|
|
|||
Loading…
Reference in a new issue