Skip to content

Commit ef7be29

Browse files
allow empty entity info
1 parent 58c718c commit ef7be29

File tree

2 files changed

+23
-13
lines changed

2 files changed

+23
-13
lines changed

flow360/component/geometry.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -366,11 +366,12 @@ def _get_default_geometry_accuracy(simulation_dict: dict) -> LengthType.Positive
366366
# pylint: disable=no-member
367367
return LengthType.validate(simulation_dict["meshing"]["defaults"]["geometry_accuracy"])
368368

369-
self.default_settings["geometry_accuracy"] = (
370-
self._entity_info.default_geometry_accuracy
371-
if self._entity_info.default_geometry_accuracy
372-
else _get_default_geometry_accuracy(simulation_dict=simulation_dict)
373-
)
369+
if self._entity_info is not None:
370+
self.default_settings["geometry_accuracy"] = (
371+
self._entity_info.default_geometry_accuracy
372+
if self._entity_info.default_geometry_accuracy
373+
else _get_default_geometry_accuracy(simulation_dict=simulation_dict)
374+
)
374375

375376
@classmethod
376377
# pylint: disable=redefined-builtin
@@ -415,7 +416,7 @@ def show_available_groupings(self, verbose_mode: bool = False):
415416

416417
@classmethod
417418
def from_local_storage(
418-
cls, geometry_id: str = None, local_storage_path="", meta_data: GeometryMeta = None
419+
cls, geometry_id: str = None, local_storage_path="", meta_data: GeometryMeta = None, allow_missing_entity_info = False
419420
) -> Geometry:
420421
"""
421422
Parameters
@@ -433,7 +434,7 @@ def from_local_storage(
433434
"""
434435

435436
return super()._from_local_storage(
436-
asset_id=geometry_id, local_storage_path=local_storage_path, meta_data=meta_data
437+
asset_id=geometry_id, local_storage_path=local_storage_path, meta_data=meta_data, allow_missing_entity_info = allow_missing_entity_info
437438
)
438439

439440
def _show_available_entity_groups(

flow360/component/simulation/web/asset_base.py

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ def _from_supplied_entity_info(
130130
cls,
131131
simulation_dict: dict,
132132
asset_obj: AssetBase,
133+
allow_missing_entity_info: Boolean,
133134
):
134135
# pylint: disable=protected-access
135136
simulation_dict, forward_compatibility_mode = SimulationParams._update_param_dict(
@@ -142,9 +143,13 @@ def _from_supplied_entity_info(
142143
asset_cache = simulation_dict["private_attribute_asset_cache"]
143144

144145
if "project_entity_info" not in asset_cache:
145-
raise KeyError(
146-
"[Internal] Could not find project_entity_info in the asset's simulation settings."
147-
)
146+
if allow_missing_entity_info:
147+
return asset_obj
148+
else:
149+
raise KeyError(
150+
"[Internal] Could not find project_entity_info in the asset's simulation settings."
151+
)
152+
148153
entity_info_dict = asset_cache["project_entity_info"]
149154
entity_info_dict = SimulationParams._sanitize_params_dict(entity_info_dict)
150155
# pylint: disable=protected-access
@@ -302,7 +307,7 @@ def from_file(
302307

303308
@classmethod
304309
def _from_local_storage(
305-
cls, asset_id: str = None, local_storage_path="", meta_data: AssetMetaBaseModelV2 = None
310+
cls, asset_id: str = None, local_storage_path="", meta_data: AssetMetaBaseModelV2 = None, allow_missing_entity_info = False
306311
):
307312
"""
308313
Create asset from local storage
@@ -317,8 +322,12 @@ def _from_local_storage(
317322
params_dict = json.load(f)
318323

319324
asset_obj = cls(asset_id)
320-
# asset_obj = cls._from_supplied_entity_info(params_dict, cls(asset_id))
321-
# asset_obj.get_dynamic_default_settings(params_dict)
325+
asset_obj = cls._from_supplied_entity_info(
326+
simulation_dict=params_dict,
327+
asset_obj = cls(asset_id),
328+
allow_missing_entity_info = allow_missing_entity_info
329+
)
330+
asset_obj.get_dynamic_default_settings(params_dict)
322331

323332
# pylint: disable=protected-access
324333
if not hasattr(asset_obj, "_webapi"):

0 commit comments

Comments
 (0)