Skip to content

Commit 36fc16b

Browse files
authored
Move parse root item type function to python client (#1152)
1 parent 6343e7f commit 36fc16b

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

flow360/component/simulation/services.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -909,3 +909,21 @@ def get_default_report_config() -> dict:
909909
return get_default_report_summary_template().model_dump(
910910
exclude_none=True,
911911
)
912+
913+
914+
def _parse_root_item_type_from_simulation_json(*, param_as_dict: dict):
915+
"""Deduct the root item entity type from simulation.json"""
916+
try:
917+
entity_info_type = param_as_dict["private_attribute_asset_cache"]["project_entity_info"][
918+
"type_name"
919+
]
920+
if entity_info_type == "GeometryEntityInfo":
921+
return "Geometry"
922+
if entity_info_type == "SurfaceMeshEntityInfo":
923+
return "SurfaceMesh"
924+
if entity_info_type == "VolumeMeshEntityInfo":
925+
return "VolumeMesh"
926+
raise ValueError(f"[INTERNAL] Invalid type of the entity info found: {entity_info_type}")
927+
except KeyError:
928+
# pylint:disable = raise-missing-from
929+
raise ValueError("[INTERNAL] Failed to get the root item from the simulation.json!!!")

0 commit comments

Comments
 (0)