Skip to content

Commit

Permalink
Get specific case objects via CaseCollection, so that we also get the…
Browse files Browse the repository at this point in the history
… overview data.
  • Loading branch information
rwiker committed Dec 4, 2023
1 parent 8fe6dc6 commit 7f9ddf3
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/fmu/sumo/explorer/explorer.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,11 @@ def get_case_by_uuid(self, uuid: str) -> Case:
Returns:
Case: case object
"""
metadata = self._utils.get_object(uuid, _CASE_FIELDS)
return Case(self._sumo, metadata, self._pit)
cases = self.cases.filter(uuid=uuid)
if len(cases) == 0:
raise Exception(f"Document not found: {uuid}")

return cases[0]

async def get_case_by_uuid_async(self, uuid: str) -> Case:
"""Get case object by uuid
Expand All @@ -126,8 +129,11 @@ async def get_case_by_uuid_async(self, uuid: str) -> Case:
Returns:
Case: case object
"""
metadata = await self._utils.get_object_async(uuid, _CASE_FIELDS)
return Case(self._sumo, metadata, self._pit)
cases = self.cases.filter(uuid=uuid)
if await cases.length_async() == 0:
raise Exception(f"Document not found: {uuid}")

return await cases.getitem_async(0)

def get_surface_by_uuid(self, uuid: str) -> Surface:
"""Get surface object by uuid
Expand Down

0 comments on commit 7f9ddf3

Please sign in to comment.