Skip to content

Commit

Permalink
Merge remote-tracking branch 'equinor/main' into 3d-viewer-and-inters…
Browse files Browse the repository at this point in the history
…ection
  • Loading branch information
rubenthoms committed Jun 17, 2024
2 parents 81b6a4f + 9919ac5 commit e0c3e42
Show file tree
Hide file tree
Showing 19 changed files with 50 additions and 28 deletions.
6 changes: 3 additions & 3 deletions backend_py/primary/primary/routers/explore.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ async def get_ensembles(
case_uuid: str = Path(description="Sumo case uuid"),
) -> List[EnsembleInfo]:
"""Get list of ensembles for a case"""
case_inspector = await CaseInspector.from_case_uuid_async(authenticated_user.get_sumo_access_token(), case_uuid)
case_inspector = CaseInspector.from_case_uuid(authenticated_user.get_sumo_access_token(), case_uuid)
iteration_info_arr = await case_inspector.get_iterations_async()

print(iteration_info_arr)
Expand All @@ -87,8 +87,8 @@ async def get_ensemble_details(
) -> EnsembleDetails:
"""Get more detailed information for an ensemble"""

case_inspector = await CaseInspector.from_case_uuid_async(authenticated_user.get_sumo_access_token(), case_uuid)
case_name = case_inspector.get_case_name()
case_inspector = CaseInspector.from_case_uuid(authenticated_user.get_sumo_access_token(), case_uuid)
case_name = await case_inspector.get_case_name_async()
realizations = await case_inspector.get_realizations_in_iteration_async(ensemble_name)
field_identifiers = await case_inspector.get_field_identifiers_async()

Expand Down
2 changes: 1 addition & 1 deletion backend_py/primary/primary/routers/polygons/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ async def get_polygons_directory(
)
polygons_dir = await access.get_polygons_directory_async()

case_inspector = await CaseInspector.from_case_uuid_async(authenticated_user.get_sumo_access_token(), case_uuid)
case_inspector = CaseInspector.from_case_uuid(authenticated_user.get_sumo_access_token(), case_uuid)
strat_column_identifier = await case_inspector.get_stratigraphic_column_identifier_async()
strat_access: Union[StratigraphyAccess, _mocked_stratigraphy_access.StratigraphyAccess]

Expand Down
2 changes: 1 addition & 1 deletion backend_py/primary/primary/routers/surface/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ async def get_surface_directory(
)
sumo_surf_dir = await surface_access.get_surface_directory_async()

case_inspector = await CaseInspector.from_case_uuid_async(authenticated_user.get_sumo_access_token(), case_uuid)
case_inspector = CaseInspector.from_case_uuid(authenticated_user.get_sumo_access_token(), case_uuid)
strat_column_identifier = await case_inspector.get_stratigraphic_column_identifier_async()
strat_access: Union[StratigraphyAccess, _mocked_stratigraphy_access.StratigraphyAccess]

Expand Down
6 changes: 3 additions & 3 deletions backend_py/primary/primary/routers/well/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ async def get_drilled_wellbore_headers(
) -> List[schemas.WellboreHeader]:
"""Get wellbore headers for all wells in the field"""

case_inspector = await CaseInspector.from_case_uuid_async(authenticated_user.get_sumo_access_token(), case_uuid)
case_inspector = CaseInspector.from_case_uuid(authenticated_user.get_sumo_access_token(), case_uuid)
field_identifier = (await case_inspector.get_field_identifiers_async())[0]
well_access: Union[SmdaWellAccess, MockedSmdaWellAccess]
if field_identifier == "DROGON":
Expand All @@ -56,7 +56,7 @@ async def get_field_well_trajectories(
# fmt:on
) -> List[schemas.WellboreTrajectory]:
"""Get well trajectories for field"""
case_inspector = await CaseInspector.from_case_uuid_async(authenticated_user.get_sumo_access_token(), case_uuid)
case_inspector = CaseInspector.from_case_uuid(authenticated_user.get_sumo_access_token(), case_uuid)
field_identifier = (await case_inspector.get_field_identifiers_async())[0]
well_access: Union[SmdaWellAccess, MockedSmdaWellAccess]
if field_identifier == "DROGON":
Expand Down Expand Up @@ -111,7 +111,7 @@ async def get_wellbore_picks_and_stratigraphic_units(
well_access: Union[SmdaWellAccess, MockedSmdaWellAccess]
stratigraphy_access: Union[StratigraphyAccess, MockedStratigraphyAccess]

case_inspector = await CaseInspector.from_case_uuid_async(authenticated_user.get_sumo_access_token(), case_uuid)
case_inspector = CaseInspector.from_case_uuid(authenticated_user.get_sumo_access_token(), case_uuid)
stratigraphic_column_identifier = await case_inspector.get_stratigraphic_column_identifier_async()

# Handle DROGON
Expand Down
31 changes: 22 additions & 9 deletions backend_py/primary/primary/services/sumo_access/case_inspector.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,35 @@ class IterationInfo(BaseModel):


class CaseInspector:
def __init__(self, sumo_client: SumoClient, case: Case, case_uuid: str):
def __init__(self, sumo_client: SumoClient, case_uuid: str):
self._sumo_client = sumo_client
self._case = case
self._case_uuid = case_uuid
self._cached_case_obj: Case | None = None

@classmethod
async def from_case_uuid_async(cls, access_token: str, case_uuid: str) -> "CaseInspector":
def from_case_uuid(cls, access_token: str, case_uuid: str) -> "CaseInspector":
sumo_client: SumoClient = create_sumo_client(access_token)
case: Case = await create_sumo_case_async(client=sumo_client, case_uuid=case_uuid, want_keepalive_pit=False)
return CaseInspector(sumo_client=sumo_client, case=case, case_uuid=case_uuid)
return CaseInspector(sumo_client=sumo_client, case_uuid=case_uuid)

def get_case_name(self) -> str:
async def _get_or_create_case_obj(self) -> Case:
if not self._cached_case_obj:
self._cached_case_obj = await create_sumo_case_async(
client=self._sumo_client, case_uuid=self._case_uuid, want_keepalive_pit=False
)

return self._cached_case_obj

async def get_case_name_async(self) -> str:
"""Get name of the case"""
return self._case.name
case: Case = await self._get_or_create_case_obj()
return case.name

async def get_iterations_async(self) -> list[IterationInfo]:
iterations = await self._case.iterations_async
case: Case = await self._get_or_create_case_obj()

# Stick with the sync version for now, since there is a bug in the async version of SumoExplorer
# See: https://github.com/equinor/fmu-sumo/issues/326
iterations = case.iterations

iter_info_arr: list[IterationInfo] = []
for iteration in iterations:
Expand All @@ -45,7 +57,8 @@ async def get_iterations_async(self) -> list[IterationInfo]:

async def get_realizations_in_iteration_async(self, iteration_name: str) -> list[int]:
"""Get list of realizations for the specified iteration"""
realization_list = await self._case.get_realizations_async(iteration_name)
case: Case = await self._get_or_create_case_obj()
realization_list = await case.get_realizations_async(iteration_name)
return sorted([int(real) for real in realization_list])

async def get_stratigraphic_column_identifier_async(self) -> str:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ async def main() -> None:
print("The sumo case id was not found")
sys.exit(1)

case_inspector = await CaseInspector.from_case_uuid_async(access_token, sumo_case_id)
case_inspector = CaseInspector.from_case_uuid(access_token, sumo_case_id)
iteration_list = await case_inspector.get_iterations_async()
print("\n\n")
for iteration_info in iteration_list:
Expand Down
15 changes: 15 additions & 0 deletions frontend/src/modules/FlowNetwork/preview.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ import { ModuleRegistry } from "@framework/ModuleRegistry";
import { preview } from "./preview";
import { Interface, State } from "./settingsToViewInterface";

export const MODULE_NAME = "GroupTree";
export const MODULE_NAME = "FlowNetwork";

const description = "Visualizes dated group trees over time.";

ModuleRegistry.registerModule<State, Interface>({
moduleName: MODULE_NAME,
defaultTitle: "Group Tree",
defaultTitle: "Flow Network",
category: ModuleCategory.MAIN,
devState: ModuleDevState.DEV,
devState: ModuleDevState.PROD,
dataTagIds: [ModuleDataTagId.GROUP_TREE, ModuleDataTagId.SUMMARY],
preview,
description,
Expand Down
File renamed without changes.
File renamed without changes.
6 changes: 0 additions & 6 deletions frontend/src/modules/GroupTree/preview.svg

This file was deleted.

2 changes: 1 addition & 1 deletion frontend/src/modules/registerAllModules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { isDevMode } from "@lib/utils/devMode";

import "./3DViewer/registerModule";
import "./DistributionPlot/registerModule";
import "./FlowNetwork/registerModule";
// import "./Grid3DVTK/registerModule";
import "./InplaceVolumetrics/registerModule";
import "./Intersection/registerModule";
Expand All @@ -17,7 +18,6 @@ import "./StructuralUncertaintyIntersection/registerModule";
import "./SubsurfaceMap/registerModule";
import "./TornadoChart/registerModule";
import "./WellCompletions/registerModule";
import "./GroupTree/registerModule";

if (isDevMode()) {
await import("./MyModule/registerModule");
Expand Down

0 comments on commit e0c3e42

Please sign in to comment.