Skip to content

Commit 5dc97e5

Browse files
committed
Move parse_model_dict forward to ensure the multiconstructor models are expanded before validation
1 parent 1bfc066 commit 5dc97e5

File tree

3 files changed

+213
-179
lines changed

3 files changed

+213
-179
lines changed

flow360/component/simulation/services.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -478,14 +478,22 @@ def validate_model( # pylint: disable=too-many-locals
478478
updated_param_as_dict
479479
)
480480

481+
project_length_unit_dict = updated_param_as_dict.get(
482+
"private_attribute_asset_cache", {}
483+
).get("project_length_unit", None)
484+
parse_model_info = ParamsValidationInfo(
485+
{"private_attribute_asset_cache": {"project_length_unit": project_length_unit_dict}},
486+
[],
487+
)
488+
with ValidationContext(levels=validation_levels_to_use, info=parse_model_info):
489+
# Multi-constructor model support
490+
updated_param_as_dict = parse_model_dict(updated_param_as_dict, globals())
491+
481492
additional_info = ParamsValidationInfo(
482493
param_as_dict=updated_param_as_dict,
483494
referenced_expressions=referenced_expressions,
484495
)
485-
486496
with ValidationContext(levels=validation_levels_to_use, info=additional_info):
487-
# Multi-constructor model support
488-
updated_param_as_dict = parse_model_dict(updated_param_as_dict, globals())
489497
validated_param = SimulationParams(file_content=updated_param_as_dict)
490498
except pd.ValidationError as err:
491499
validation_errors = err.errors()

0 commit comments

Comments
 (0)