Skip to content

Commit

Permalink
Merge branch 'main' of github.com:equinor/webviz
Browse files Browse the repository at this point in the history
  • Loading branch information
HansKallekleiv committed Sep 3, 2024
2 parents eebfca3 + d59a635 commit 1ddd468
Show file tree
Hide file tree
Showing 247 changed files with 4,170 additions and 8,921 deletions.
3,555 changes: 1,833 additions & 1,722 deletions backend_py/primary/poetry.lock

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions backend_py/primary/primary/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
from primary.routers.general import router as general_router
from primary.routers.graph.router import router as graph_router
from primary.routers.grid3d.router import router as grid3d_router
from primary.routers.grid3d.router_vtk import router as grid3d_router_vtk
from primary.routers.group_tree.router import router as group_tree_router
from primary.routers.inplace_volumetrics.router import router as inplace_volumetrics_router
from primary.routers.observations.router import router as observations_router
Expand Down Expand Up @@ -79,7 +78,6 @@ def custom_generate_unique_id(route: APIRoute) -> str:
app.include_router(parameters_router, prefix="/parameters", tags=["parameters"])
app.include_router(correlations_router, prefix="/correlations", tags=["correlations"])
app.include_router(grid3d_router, prefix="/grid3d", tags=["grid3d"])
app.include_router(grid3d_router_vtk, prefix="/grid3d", tags=["grid3d"])
app.include_router(group_tree_router, prefix="/group_tree", tags=["group_tree"])
app.include_router(pvt_router, prefix="/pvt", tags=["pvt"])
app.include_router(well_completions_router, prefix="/well_completions", tags=["well_completions"])
Expand Down
187 changes: 0 additions & 187 deletions backend_py/primary/primary/routers/grid3d/router_vtk.py

This file was deleted.

25 changes: 0 additions & 25 deletions backend_py/primary/primary/routers/grid3d/schemas_vtk.py

This file was deleted.

4 changes: 1 addition & 3 deletions backend_py/primary/primary/routers/surface/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,6 @@ async def get_surface_data(
raise HTTPException(status_code=404, detail="Could not get realization surface")

elif addr.address_type == "STAT":
if addr.stat_realizations is not None:
raise HTTPException(status_code=501, detail="Statistics with specific realizations not yet supported")

service_stat_func_to_compute = StatisticFunction.from_string_value(addr.stat_function)
if service_stat_func_to_compute is None:
raise HTTPException(status_code=404, detail="Invalid statistic requested")
Expand All @@ -164,6 +161,7 @@ async def get_surface_data(
statistic_function=service_stat_func_to_compute,
name=addr.name,
attribute=addr.attribute,
realizations=addr.stat_realizations,
time_or_interval_str=addr.iso_time_or_interval,
)
perf_metrics.record_lap("sumo-calc")
Expand Down
47 changes: 35 additions & 12 deletions backend_py/primary/primary/services/sumo_access/surface_access.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import asyncio
import logging
from io import BytesIO
from typing import Optional
from typing import Sequence

import xtgeo

Expand Down Expand Up @@ -118,10 +118,11 @@ async def get_observed_surfaces_metadata_async(self) -> SurfaceMetaSet:
return surf_meta_set

async def get_realization_surface_data_async(
self, real_num: int, name: str, attribute: str, time_or_interval_str: Optional[str] = None
) -> Optional[xtgeo.RegularSurface]:
self, real_num: int, name: str, attribute: str, time_or_interval_str: str | None = None
) -> xtgeo.RegularSurface | None:
"""
Get surface data for a realization surface
If time_or_interval_str is None, only surfaces with no time information will be considered.
"""
if not self._iteration_name:
raise InvalidParameterError("Iteration name must be set to get realization surface", Service.SUMO)
Expand All @@ -148,7 +149,7 @@ async def get_realization_surface_data_async(
f"Multiple ({surf_count}) surfaces found in Sumo for: {surf_str}", Service.SUMO
)
if surf_count == 0:
LOGGER.warning(f"No realization surface found in Sumo for {surf_str}")
LOGGER.warning(f"No realization surface found in Sumo for: {surf_str}")
return None

sumo_surf: Surface = await surface_collection.getitem_async(0)
Expand All @@ -170,7 +171,7 @@ async def get_realization_surface_data_async(

async def get_observed_surface_data_async(
self, name: str, attribute: str, time_or_interval_str: str
) -> Optional[xtgeo.RegularSurface]:
) -> xtgeo.RegularSurface | None:
"""
Get surface data for an observed surface
"""
Expand Down Expand Up @@ -218,17 +219,25 @@ async def get_statistical_surface_data_async(
statistic_function: StatisticFunction,
name: str,
attribute: str,
time_or_interval_str: Optional[str] = None,
) -> Optional[xtgeo.RegularSurface]:
realizations: Sequence[int] | None = None,
time_or_interval_str: str | None = None,
) -> xtgeo.RegularSurface | None:
"""
Compute statistic and return surface data
If realizations is None this is interpreted as a wildcard and surfaces from all realizations will be included
in the statistics. The list of realizations cannon be empty.
If time_or_interval_str is None, only surfaces with no time information will be considered.
"""
if not self._iteration_name:
raise InvalidParameterError("Iteration name must be set to get realization surfaces", Service.SUMO)

if realizations is not None:
if len(realizations) == 0:
raise InvalidParameterError("List of realizations cannot be empty", Service.SUMO)

perf_metrics = PerfMetrics()

surf_str = self._make_real_surf_log_str(-1, name, attribute, time_or_interval_str)
surf_str = self._make_stat_surf_log_str(name, attribute, time_or_interval_str)

time_filter = _time_or_interval_str_to_time_filter(time_or_interval_str)

Expand All @@ -238,28 +247,38 @@ async def get_statistical_surface_data_async(
iteration=self._iteration_name,
name=name,
tagname=attribute,
realization=realizations,
time=time_filter,
)

surf_count = await surface_collection.length_async()
if surf_count == 0:
LOGGER.warning(f"No statistical source surfaces found in Sumo for {surf_str}")
LOGGER.warning(f"No statistical source surfaces found in Sumo for: {surf_str}")
return None
perf_metrics.record_lap("locate")

realizations = await surface_collection.realizations_async
realizations_found = await surface_collection.realizations_async
perf_metrics.record_lap("collect-reals")

# Ensure that we got data for all the requested realizations
if realizations is not None:
missing_reals = list(set(realizations) - set(realizations_found))
if len(missing_reals) > 0:
raise InvalidParameterError(
f"Could not find source surfaces for realizations: {missing_reals} in Sumo for {surf_str}",
Service.SUMO,
)

xtgeo_surf = await _compute_statistical_surface_async(statistic_function, surface_collection)
perf_metrics.record_lap("calc-stat")

if not xtgeo_surf:
LOGGER.warning(f"Could not calculate statistical surface using Sumo for {surf_str}")
LOGGER.warning(f"Could not calculate statistical surface using Sumo for: {surf_str}")
return None

LOGGER.debug(
f"Calculated statistical surface using Sumo in: {perf_metrics.to_string()} "
f"({surf_str} {len(realizations)=})"
f"[{xtgeo_surf.ncol}x{xtgeo_surf.nrow}, real count: {len(realizations_found)}] ({surf_str})"
)

return xtgeo_surf
Expand All @@ -272,6 +291,10 @@ def _make_obs_surf_log_str(self, name: str, attribute: str, date_str: str) -> st
addr_str = f"N={name}, A={attribute}, D={date_str}, C={self._case_uuid}"
return addr_str

def _make_stat_surf_log_str(self, name: str, attribute: str, date_str: str | None) -> str:
addr_str = f"N={name}, A={attribute}, D={date_str}, C={self._case_uuid}, I={self._iteration_name}"
return addr_str


def _build_surface_meta_arr(
src_surf_info_arr: list[SurfInfo], time_type: SurfTimeType, are_observations: bool
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

class UserComponent(str, Enum):
GRID3D_RI = "GRID3D_RI"
GRID3D_VTK = "GRID3D_VTK"
MOCK = "MOCK"


Expand Down Expand Up @@ -53,12 +52,6 @@ class _UserSessionDef:
resource_req=RadixResourceRequests(cpu="4", memory="16Gi"),
payload_dict={"ri_omp_num_treads": 4},
),
UserComponent.GRID3D_VTK: _UserSessionDef(
job_component_name="user-grid3d-vtk",
port=8003,
resource_req=RadixResourceRequests(cpu="200m", memory="400Mi"),
payload_dict=None,
),
}


Expand Down
Loading

0 comments on commit 1ddd468

Please sign in to comment.