Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Encode/decode realization array for endpoints #832

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 15 additions & 12 deletions backend_py/primary/primary/routers/inplace_volumetrics/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from primary.services.utils.authenticated_user import AuthenticatedUser
from primary.auth.auth_helper import AuthHelper
from primary.utils.response_perf_metrics import ResponsePerfMetrics
from primary.utils.query_string_utils import decode_uint_list_str

from . import schemas
from . import converters
Expand Down Expand Up @@ -52,12 +53,7 @@ async def post_get_aggregated_per_realization_table_data(
group_by_identifiers: Annotated[
list[schemas.InplaceVolumetricsIdentifier] | None, Query(description="The identifiers to group table data by")
] = None,
realizations: Annotated[
list[int] | None,
Query(
description="Optional list of realizations to include. If not specified, all realizations will be returned."
),
] = None,
realizations_encoded_as_uint_list_str: Annotated[str | None, Query(description="Optional list of realizations encoded as string to include. If not specified, all realizations will be included.")] = None,
) -> schemas.InplaceVolumetricTableDataPerFluidSelection:
"""
Get aggregated volumetric data for a given table with data per realization based on requested results and categories/index filter.
Expand All @@ -67,6 +63,12 @@ async def post_get_aggregated_per_realization_table_data(
"""
perf_metrics = ResponsePerfMetrics(response)

realizations = None
if realizations_encoded_as_uint_list_str:
realizations = decode_uint_list_str(realizations_encoded_as_uint_list_str)

perf_metrics.record_lap("decode realizations array")

access = await InplaceVolumetricsAccess.from_case_uuid_async(
authenticated_user.get_sumo_access_token(), case_uuid, ensemble_name
)
Expand Down Expand Up @@ -110,12 +112,7 @@ async def post_get_aggregated_statistical_table_data(
group_by_identifiers: Annotated[
list[schemas.InplaceVolumetricsIdentifier] | None, Query(description="The identifiers to group table data by")
] = None,
realizations: Annotated[
list[int] | None,
Query(
description="Optional list of realizations to include. If not specified, all realizations will be returned."
),
] = None,
realizations_encoded_as_uint_list_str: Annotated[str | None, Query(description="Optional list of realizations encoded as string to include. If not specified, all realizations will be included.")] = None,
) -> schemas.InplaceStatisticalVolumetricTableDataPerFluidSelection:
"""
Get statistical volumetric data across selected realizations for a given table based on requested results and categories/index filter.
Expand All @@ -125,6 +122,12 @@ async def post_get_aggregated_statistical_table_data(
"""
perf_metrics = ResponsePerfMetrics(response)

realizations: list[int]|None = None
if realizations_encoded_as_uint_list_str:
realizations = decode_uint_list_str(realizations_encoded_as_uint_list_str)

perf_metrics.record_lap("decode realizations array")

access = await InplaceVolumetricsAccess.from_case_uuid_async(
authenticated_user.get_sumo_access_token(), case_uuid, ensemble_name
)
Expand Down
7 changes: 6 additions & 1 deletion backend_py/primary/primary/routers/rft/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from primary.auth.auth_helper import AuthHelper
from primary.services.sumo_access.rft_access import RftAccess
from primary.services.utils.authenticated_user import AuthenticatedUser
from primary.utils.query_string_utils import decode_uint_list_str

from . import schemas
from . import converters
Expand Down Expand Up @@ -35,8 +36,12 @@ async def get_realization_data(
well_name: Annotated[str, Query(description="Well name")],
response_name: Annotated[str, Query(description="Response name")],
timestamps_utc_ms: Annotated[list[int] | None, Query(description="Timestamps utc ms")] = None,
realizations: Annotated[list[int] | None, Query(description="Realizations")] = None,
realizations_encoded_as_uint_list_str: Annotated[str | None, Query(description="Optional list of realizations encoded as string to include. If not specified, all realizations will be included.")] = None,
) -> list[schemas.RftRealizationData]:
realizations: list[int]|None = None
if realizations_encoded_as_uint_list_str:
realizations = decode_uint_list_str(realizations_encoded_as_uint_list_str)

access = await RftAccess.from_case_uuid_async(authenticated_user.get_sumo_access_token(), case_uuid, ensemble_name)
data = await access.get_rft_well_realization_data(
well_name=well_name,
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 @@ -288,7 +288,7 @@ async def get_misfit_surface_data(
obs_surf_addr_str: Annotated[str, Query(description="Address of observed surface, only supported address type is *OBS*")],
sim_surf_addr_str: Annotated[str, Query(description="Address of simulated surface, supported type is *PARTIAL*")],
statistic_functions: Annotated[list[schemas.SurfaceStatisticFunction], Query(description="Statistics to calculate")],
realizations: Annotated[list[int], Query(description="Realization numbers")],
realizations_encoded_as_uint_list_str: Annotated[str | None, Query(description="Optional list of realizations encoded as string to include. If not specified, all realizations will be included.")] = None,
data_format: Annotated[Literal["float", "png"], Query(description="Format of binary data in the response")] = "float",
resample_to: Annotated[schemas.SurfaceDef | None, Depends(dependencies.get_resample_to_param_from_keyval_str)] = None,
# fmt:on
Expand Down
18 changes: 13 additions & 5 deletions backend_py/primary/primary/routers/timeseries/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from primary.services.sumo_access.parameter_access import ParameterAccess
from primary.services.sumo_access.summary_access import Frequency, SummaryAccess
from primary.services.utils.authenticated_user import AuthenticatedUser
from primary.utils.query_string_utils import decode_uint_list_str

from . import converters, schemas

Expand Down Expand Up @@ -57,13 +58,18 @@ async def get_realizations_vector_data(
ensemble_name: Annotated[str, Query(description="Ensemble name")],
vector_name: Annotated[str, Query(description="Name of the vector")],
resampling_frequency: Annotated[schemas.Frequency | None, Query(description="Resampling frequency. If not specified, raw data without resampling wil be returned.")] = None,
realizations: Annotated[list[int] | None, Query(description="Optional list of realizations to include. If not specified, all realizations will be returned.")] = None,
realizations_encoded_as_uint_list_str: Annotated[str | None, Query(description="Optional list of realizations encoded as string to include. If not specified, all realizations will be included.")] = None,
# relative_to_timestamp: Annotated[datetime.datetime | None, Query(description="Calculate relative to timestamp")] = None,
# fmt:on
) -> list[schemas.VectorRealizationData]:
"""Get vector data per realization"""

perf_metrics = ResponsePerfMetrics(response)

realizations: list[int]|None = None
if realizations_encoded_as_uint_list_str:
realizations = decode_uint_list_str(realizations_encoded_as_uint_list_str)

access = SummaryAccess.from_case_uuid(authenticated_user.get_sumo_access_token(), case_uuid, ensemble_name)

sumo_freq = Frequency.from_string_value(resampling_frequency.value if resampling_frequency else "dummy")
Expand Down Expand Up @@ -97,7 +103,6 @@ async def get_timestamps_list(
case_uuid: Annotated[str, Query(description="Sumo case uuid")],
ensemble_name: Annotated[str, Query(description="Ensemble name")],
resampling_frequency: Annotated[schemas.Frequency | None, Query(description="Resampling frequency")] = None,
# realizations: Annotated[list[int] | None, Query(description="Optional list of realizations to include")] = None,
) -> list[int]:
"""Get the intersection of available timestamps.
Note that when resampling_frequency is None, the pure intersection of the
Expand Down Expand Up @@ -149,14 +154,18 @@ async def get_statistical_vector_data(
vector_name: Annotated[str, Query(description="Name of the vector")],
resampling_frequency: Annotated[schemas.Frequency, Query(description="Resampling frequency")],
statistic_functions: Annotated[list[schemas.StatisticFunction] | None, Query(description="Optional list of statistics to calculate. If not specified, all statistics will be calculated.")] = None,
realizations: Annotated[list[int] | None, Query(description="Optional list of realizations to include. If not specified, all realizations will be included.")] = None,
realizations_encoded_as_uint_list_str: Annotated[str | None, Query(description="Optional list of realizations encoded as string to include. If not specified, all realizations will be included.")] = None,
# relative_to_timestamp: Annotated[datetime.datetime | None, Query(description="Calculate relative to timestamp")] = None,
# fmt:on
) -> schemas.VectorStatisticData:
"""Get statistical vector data for an ensemble"""

perf_metrics = ResponsePerfMetrics(response)

realizations: list[int]|None = None
if realizations_encoded_as_uint_list_str:
realizations = decode_uint_list_str(realizations_encoded_as_uint_list_str)

access = SummaryAccess.from_case_uuid(authenticated_user.get_sumo_access_token(), case_uuid, ensemble_name)

service_freq = Frequency.from_string_value(resampling_frequency.value)
Expand Down Expand Up @@ -242,7 +251,6 @@ async def get_realization_vector_at_timestamp(
ensemble_name: Annotated[str, Query(description="Ensemble name")],
vector_name: Annotated[str, Query(description="Name of the vector")],
timestamp_utc_ms: Annotated[int, Query(description= "Timestamp in ms UTC to query vectors at")],
# realizations: Annotated[list[int] | None, Query(description="Optional list of realizations to include. If not specified, all realizations will be returned.")] = None,
# fmt:on
) -> EnsembleScalarResponse:
summary_access = SummaryAccess.from_case_uuid(authenticated_user.get_sumo_access_token(), case_uuid, ensemble_name)
Expand Down
12 changes: 6 additions & 6 deletions frontend/src/api/services/InplaceVolumetricsService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export class InplaceVolumetricsService {
* @param accumulateFluidZones Whether to accumulate fluid zones
* @param requestBody
* @param groupByIdentifiers The identifiers to group table data by
* @param realizations Optional list of realizations to include. If not specified, all realizations will be returned.
* @param realizationsEncodedAsUintListStr Optional list of realizations encoded as string to include. If not specified, all realizations will be included.
* @returns InplaceVolumetricTableDataPerFluidSelection Successful Response
* @throws ApiError
*/
Expand All @@ -64,7 +64,7 @@ export class InplaceVolumetricsService {
accumulateFluidZones: boolean,
requestBody: Body_post_get_aggregated_per_realization_table_data,
groupByIdentifiers?: (Array<InplaceVolumetricsIdentifier> | null),
realizations?: (Array<number> | null),
realizationsEncodedAsUintListStr?: (string | null),
): CancelablePromise<InplaceVolumetricTableDataPerFluidSelection> {
return this.httpRequest.request({
method: 'POST',
Expand All @@ -77,7 +77,7 @@ export class InplaceVolumetricsService {
'fluid_zones': fluidZones,
'accumulate_fluid_zones': accumulateFluidZones,
'group_by_identifiers': groupByIdentifiers,
'realizations': realizations,
'realizations_encoded_as_uint_list_str': realizationsEncodedAsUintListStr,
},
body: requestBody,
mediaType: 'application/json',
Expand All @@ -100,7 +100,7 @@ export class InplaceVolumetricsService {
* @param accumulateFluidZones Whether to accumulate fluid zones
* @param requestBody
* @param groupByIdentifiers The identifiers to group table data by
* @param realizations Optional list of realizations to include. If not specified, all realizations will be returned.
* @param realizationsEncodedAsUintListStr Optional list of realizations encoded as string to include. If not specified, all realizations will be included.
* @returns InplaceStatisticalVolumetricTableDataPerFluidSelection Successful Response
* @throws ApiError
*/
Expand All @@ -113,7 +113,7 @@ export class InplaceVolumetricsService {
accumulateFluidZones: boolean,
requestBody: Body_post_get_aggregated_statistical_table_data,
groupByIdentifiers?: (Array<InplaceVolumetricsIdentifier> | null),
realizations?: (Array<number> | null),
realizationsEncodedAsUintListStr?: (string | null),
): CancelablePromise<InplaceStatisticalVolumetricTableDataPerFluidSelection> {
return this.httpRequest.request({
method: 'POST',
Expand All @@ -126,7 +126,7 @@ export class InplaceVolumetricsService {
'fluid_zones': fluidZones,
'accumulate_fluid_zones': accumulateFluidZones,
'group_by_identifiers': groupByIdentifiers,
'realizations': realizations,
'realizations_encoded_as_uint_list_str': realizationsEncodedAsUintListStr,
},
body: requestBody,
mediaType: 'application/json',
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/api/services/RftService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export class RftService {
* @param wellName Well name
* @param responseName Response name
* @param timestampsUtcMs Timestamps utc ms
* @param realizations Realizations
* @param realizationsEncodedAsUintListStr Optional list of realizations encoded as string to include. If not specified, all realizations will be included.
* @returns RftRealizationData Successful Response
* @throws ApiError
*/
Expand All @@ -48,7 +48,7 @@ export class RftService {
wellName: string,
responseName: string,
timestampsUtcMs?: (Array<number> | null),
realizations?: (Array<number> | null),
realizationsEncodedAsUintListStr?: (string | null),
): CancelablePromise<Array<RftRealizationData>> {
return this.httpRequest.request({
method: 'GET',
Expand All @@ -59,7 +59,7 @@ export class RftService {
'well_name': wellName,
'response_name': responseName,
'timestamps_utc_ms': timestampsUtcMs,
'realizations': realizations,
'realizations_encoded_as_uint_list_str': realizationsEncodedAsUintListStr,
},
errors: {
422: `Validation Error`,
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/api/services/SurfaceService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ export class SurfaceService {
* @param obsSurfAddrStr Address of observed surface, only supported address type is *OBS*
* @param simSurfAddrStr Address of simulated surface, supported type is *PARTIAL*
* @param statisticFunctions Statistics to calculate
* @param realizations Realization numbers
* @param realizationsEncodedAsUintListStr Optional list of realizations encoded as string to include. If not specified, all realizations will be included.
* @param dataFormat Format of binary data in the response
* @param resampleToDefStr Definition of the surface onto which the data should be resampled. *SurfaceDef* object properties encoded as a `KeyValStr` string.
* @returns SurfaceDataFloat Successful Response
Expand All @@ -230,7 +230,7 @@ export class SurfaceService {
obsSurfAddrStr: string,
simSurfAddrStr: string,
statisticFunctions: Array<SurfaceStatisticFunction>,
realizations: Array<number>,
realizationsEncodedAsUintListStr?: (string | null),
dataFormat: 'float' | 'png' = 'float',
resampleToDefStr?: (string | null),
): CancelablePromise<Array<SurfaceDataFloat>> {
Expand All @@ -241,7 +241,7 @@ export class SurfaceService {
'obs_surf_addr_str': obsSurfAddrStr,
'sim_surf_addr_str': simSurfAddrStr,
'statistic_functions': statisticFunctions,
'realizations': realizations,
'realizations_encoded_as_uint_list_str': realizationsEncodedAsUintListStr,
'data_format': dataFormat,
'resample_to_def_str': resampleToDefStr,
},
Expand Down
12 changes: 6 additions & 6 deletions frontend/src/api/services/TimeseriesService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export class TimeseriesService {
* @param ensembleName Ensemble name
* @param vectorName Name of the vector
* @param resamplingFrequency Resampling frequency. If not specified, raw data without resampling wil be returned.
* @param realizations Optional list of realizations to include. If not specified, all realizations will be returned.
* @param realizationsEncodedAsUintListStr Optional list of realizations encoded as string to include. If not specified, all realizations will be included.
* @returns VectorRealizationData Successful Response
* @throws ApiError
*/
Expand All @@ -54,7 +54,7 @@ export class TimeseriesService {
ensembleName: string,
vectorName: string,
resamplingFrequency?: (Frequency | null),
realizations?: (Array<number> | null),
realizationsEncodedAsUintListStr?: (string | null),
): CancelablePromise<Array<VectorRealizationData>> {
return this.httpRequest.request({
method: 'GET',
Expand All @@ -64,7 +64,7 @@ export class TimeseriesService {
'ensemble_name': ensembleName,
'vector_name': vectorName,
'resampling_frequency': resamplingFrequency,
'realizations': realizations,
'realizations_encoded_as_uint_list_str': realizationsEncodedAsUintListStr,
},
errors: {
422: `Validation Error`,
Expand Down Expand Up @@ -140,7 +140,7 @@ export class TimeseriesService {
* @param vectorName Name of the vector
* @param resamplingFrequency Resampling frequency
* @param statisticFunctions Optional list of statistics to calculate. If not specified, all statistics will be calculated.
* @param realizations Optional list of realizations to include. If not specified, all realizations will be included.
* @param realizationsEncodedAsUintListStr Optional list of realizations encoded as string to include. If not specified, all realizations will be included.
* @returns VectorStatisticData Successful Response
* @throws ApiError
*/
Expand All @@ -150,7 +150,7 @@ export class TimeseriesService {
vectorName: string,
resamplingFrequency: Frequency,
statisticFunctions?: (Array<StatisticFunction> | null),
realizations?: (Array<number> | null),
realizationsEncodedAsUintListStr?: (string | null),
): CancelablePromise<VectorStatisticData> {
return this.httpRequest.request({
method: 'GET',
Expand All @@ -161,7 +161,7 @@ export class TimeseriesService {
'vector_name': vectorName,
'resampling_frequency': resamplingFrequency,
'statistic_functions': statisticFunctions,
'realizations': realizations,
'realizations_encoded_as_uint_list_str': realizationsEncodedAsUintListStr,
},
errors: {
422: `Validation Error`,
Expand Down
Loading
Loading