Skip to content

Commit

Permalink
teset
Browse files Browse the repository at this point in the history
  • Loading branch information
HansKallekleiv committed Nov 18, 2023
1 parent 5cf262e commit 9b745ea
Showing 1 changed file with 30 additions and 13 deletions.
43 changes: 30 additions & 13 deletions backend/src/services/sumo_access/surface_access.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ async def get_realization_surface_data_async(
else:
timestamp_arr = time_or_interval_str.split("/", 1)
if len(timestamp_arr) == 0 or len(timestamp_arr) > 2:
raise ValueError("time_or_interval_str must contain a single timestamp or interval")
raise ValueError(
"time_or_interval_str must contain a single timestamp or interval"
)
if len(timestamp_arr) == 1:
time_filter = TimeFilter(
TimeType.TIMESTAMP,
Expand Down Expand Up @@ -119,7 +121,9 @@ async def get_realization_surface_data_async(
LOGGER.warning(f"No realization surface found in Sumo for {addr_str}")
return None
if surf_count > 1:
LOGGER.warning(f"Multiple ({surf_count}) surfaces found in Sumo for: {addr_str}. Returning first surface.")
LOGGER.warning(
f"Multiple ({surf_count}) surfaces found in Sumo for: {addr_str}. Returning first surface."
)

sumo_surf: Surface = await surface_collection.getitem_async(0)
et_locate_ms = timer.lap_ms()
Expand All @@ -136,12 +140,13 @@ async def get_realization_surface_data_async(
f"Got realization surface from Sumo",
extra={
"service": "sumo",
"operation": "get_realization_surface_data",
"operation": "get_realization_surface_data_async",
"elapsed_ms_total": timer.elapsed_ms(),
"elapsed_ms_locate": et_locate_ms,
"elapsed_ms_download": et_download_ms,
"elapsed_ms_xtgeo_read": et_xtgeo_read_ms,
"size_mb": size_mb,
"uuid": sumo_surf.uuid,
},
)

Expand All @@ -166,7 +171,9 @@ async def get_statistical_surface_data_async(
else:
timestamp_arr = time_or_interval_str.split("/", 1)
if len(timestamp_arr) == 0 or len(timestamp_arr) > 2:
raise ValueError("time_or_interval_str must contain a single timestamp or interval")
raise ValueError(
"time_or_interval_str must contain a single timestamp or interval"
)
if len(timestamp_arr) == 1:
time_filter = TimeFilter(
TimeType.TIMESTAMP,
Expand Down Expand Up @@ -199,24 +206,34 @@ async def get_statistical_surface_data_async(
realizations = await surface_collection.realizations_async
et_collect_reals_ms = timer.lap_ms()

xtgeo_surf = await _compute_statistical_surface_async(statistic_function, surface_collection)
xtgeo_surf = await _compute_statistical_surface_async(
statistic_function, surface_collection
)
et_calc_stat_ms = timer.lap_ms()

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

LOGGER.debug(
f"Calculated statistical surface using Sumo in: {timer.elapsed_ms()}ms ("
f"locate={et_locate_ms}ms, "
f"collect_reals={et_collect_reals_ms}ms, "
f"calc_stat={et_calc_stat_ms}ms) "
f"({addr_str} {len(realizations)=} )"
LOGGER.info(
f"Got statistical surface from Sumo",
extra={
"service": "sumo",
"operation": "get_statistical_surface_data_async",
"elapsed_ms_total": timer.elapsed_ms(),
"elapsed_ms_locate": et_locate_ms,
"elapsed_ms_collect_reals": et_collect_reals_ms,
"elapsed_ms_calculate_stat": et_calc_stat_ms,
},
)

return xtgeo_surf

def _make_addr_str(self, real_num: int, name: str, attribute: str, date_str: Optional[str]) -> str:
def _make_addr_str(
self, real_num: int, name: str, attribute: str, date_str: Optional[str]
) -> str:
addr_str = f"R:{real_num}__N:{name}__A:{attribute}__D:{date_str}__I:{self._iteration_name}__C:{self._case_uuid}"
return addr_str

Expand Down

0 comments on commit 9b745ea

Please sign in to comment.