Skip to content

Commit

Permalink
fix(): Add support for None as rooot item to allow empty validaiton c…
Browse files Browse the repository at this point in the history
…ontext (#635)
  • Loading branch information
benflexcompute committed Jan 2, 2025
1 parent 72059e8 commit 7077fad
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions flow360/component/simulation/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ def _intersect_validation_levels(requested_levels, avaliable_levels):
def validate_model(
*,
params_as_dict,
root_item_type: Literal["Geometry", "VolumeMesh"],
root_item_type: Union[Literal["Geometry", "VolumeMesh"], None],
validation_level: Union[
Literal["SurfaceMesh", "VolumeMesh", "Case", "All"], list, None
] = ALL, # Fix implicit string concatenation
Expand All @@ -243,8 +243,8 @@ def validate_model(
----------
params_as_dict : dict
The parameters dictionary to validate.
root_item_type : Literal["Geometry", "VolumeMesh"]
The root item type for validation.
root_item_type : Union[Literal["Geometry", "VolumeMesh"], None],
The root item type for validation. If None then no context-aware validation is performed.
validation_level : Literal["SurfaceMesh", "VolumeMesh", "Case", "All"] or a list of literals, optional
The validation level, default is ALL. Also a list can be provided, eg: ["SurfaceMesh", "VolumeMesh"]
Expand Down Expand Up @@ -492,8 +492,10 @@ def _get_mesh_unit(params_as_dict: dict) -> str:

def _determine_validation_level(
up_to: Literal["SurfaceMesh", "VolumeMesh", "Case"],
root_item_type: Literal["Geometry", "VolumeMesh"],
root_item_type: Union[Literal["Geometry", "VolumeMesh"], None],
) -> list:
if root_item_type is None:
return None
all_lvls = ["Geometry", "SurfaceMesh", "VolumeMesh", "Case"]
return all_lvls[all_lvls.index(root_item_type) + 1 : all_lvls.index(up_to) + 1]

Expand Down

0 comments on commit 7077fad

Please sign in to comment.