Skip to content

Commit

Permalink
Merge branch 'main' into unit-test
Browse files Browse the repository at this point in the history
  • Loading branch information
HansKallekleiv authored Sep 18, 2023
2 parents 723ada7 + 4822826 commit 7ea4f8c
Show file tree
Hide file tree
Showing 21 changed files with 259 additions and 180 deletions.
234 changes: 166 additions & 68 deletions backend/poetry.lock

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions backend/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ readme = "README.md"

[tool.poetry.dependencies]
python = "^3.10"
fastapi = "^0.89.1"
fastapi = "^0.103.1"
uvicorn = "^0.20.0"
msal = "1.20.0" # Lock version until we fix issues introduced by 1.21.0, see https://github.com/equinor/webviz/issues/105
starsessions = "^2.1.1"
starsessions = "^2.1.2"
redis = "^4.4.2"
pyarrow = "^10.0.1"
python-dotenv = "^0.21.0"
pyjwt = "^2.6.0"
pydantic = "^1.10.4"
pydantic = "^2.3.0"
numpy = "^1.24.1"
orjson = "^3.8.10"
pandas = {version = "2.0.1", extras = ["performance"]}
Expand Down
2 changes: 1 addition & 1 deletion backend/src/backend/auth/auth_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ async def _login_route(self, request: Request, redirect_url_after_login: Optiona
cca = _create_msal_confidential_client_app(token_cache=None)
flow_dict = cca.initiate_auth_code_flow(
scopes=all_scopes_list,
redirect_uri=request.url_for("_authorized_callback_route"),
redirect_uri=str(request.url_for("_authorized_callback_route")),
)

request.session["flow"] = flow_dict
Expand Down
10 changes: 2 additions & 8 deletions backend/src/backend/primary/routers/parameters/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def get_parameter_names_and_description(
case_uuid: str = Query(description="Sumo case uuid"),
ensemble_name: str = Query(description="Ensemble name"),
exclude_all_values_constant: bool = Query(True, description="Exclude all parameters where all values are the same value"),
sort_order: Optional[Literal[None,"alphabetically", "standard_deviation"]] = Query("alphabetically", description="Sort order"),
sort_order: Literal["alphabetically", "standard_deviation"] = Query("alphabetically", description="Sort order"),
# fmt:on
) -> List[schemas.EnsembleParameterDescription]:
"""Retrieve parameter names and description for an ensemble"""
Expand All @@ -47,12 +47,10 @@ def get_parameter_names_and_description(

@router.get("/parameter/")
def get_parameter(
# fmt:off
authenticated_user: AuthenticatedUser = Depends(AuthHelper.get_authenticated_user),
case_uuid: str = Query(description="Sumo case uuid"),
ensemble_name: str = Query(description="Ensemble name"),
parameter_name: str = Query(description="Parameter name"),
# fmt:on
) -> Optional[EnsembleParameter]:
"""Get a parameter in a given Sumo ensemble"""

Expand All @@ -77,11 +75,9 @@ def get_parameters(

@router.get("/is_sensitivity_run/")
def is_sensitivity_run(
# fmt:off
authenticated_user: AuthenticatedUser = Depends(AuthHelper.get_authenticated_user),
case_uuid: str = Query(description="Sumo case uuid"),
ensemble_name: str = Query(description="Ensemble name"),
# fmt:on
) -> bool:
"""Check if a given Sumo ensemble is a sensitivity run"""

Expand All @@ -92,12 +88,10 @@ def is_sensitivity_run(

@router.get("/sensitivities/")
def get_sensitivities(
# fmt:off
authenticated_user: AuthenticatedUser = Depends(AuthHelper.get_authenticated_user),
case_uuid: str = Query(description="Sumo case uuid"),
ensemble_name: str = Query(description="Ensemble name"),
# fmt:on
) -> Optional[List[EnsembleSensitivity]]:
) -> List[EnsembleSensitivity]:
"""Get sensitivities in a given Sumo ensemble"""

access = ParameterAccess(authenticated_user.get_sumo_access_token(), case_uuid, ensemble_name)
Expand Down
113 changes: 56 additions & 57 deletions backend/src/backend/primary/routers/timeseries/router.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import datetime
import logging
from typing import List, Optional, Sequence
from typing import Annotated

import pyarrow as pa
import pyarrow.compute as pc
Expand All @@ -22,16 +21,16 @@

@router.get("/vector_list/")
def get_vector_list(
authenticated_user: AuthenticatedUser = Depends(AuthHelper.get_authenticated_user),
case_uuid: str = Query(description="Sumo case uuid"),
ensemble_name: str = Query(description="Ensemble name"),
) -> List[schemas.VectorDescription]:
authenticated_user: Annotated[AuthenticatedUser, Depends(AuthHelper.get_authenticated_user)],
case_uuid: Annotated[str, Query(description="Sumo case uuid")],
ensemble_name: Annotated[str, Query(description="Ensemble name")],
) -> list[schemas.VectorDescription]:
"""Get list of all vectors in a given Sumo ensemble, excluding any historical vectors"""

access = SummaryAccess(authenticated_user.get_sumo_access_token(), case_uuid, ensemble_name)
vector_info_arr = access.get_available_vectors()

ret_arr: List[schemas.VectorDescription] = [
ret_arr: list[schemas.VectorDescription] = [
schemas.VectorDescription(name=vi.name, descriptive_name=vi.name, has_historical=vi.has_historical)
for vi in vector_info_arr
]
Expand All @@ -42,15 +41,15 @@ def get_vector_list(
@router.get("/realizations_vector_data/")
def get_realizations_vector_data(
# fmt:off
authenticated_user: AuthenticatedUser = Depends(AuthHelper.get_authenticated_user),
case_uuid: str = Query(description="Sumo case uuid"),
ensemble_name: str = Query(description="Ensemble name"),
vector_name: str = Query(description="Name of the vector"),
resampling_frequency: Optional[schemas.Frequency] = Query(None, description="Resampling frequency. If not specified, raw data without resampling wil be returned."),
realizations: Optional[Sequence[int]] = Query(None, description="Optional list of realizations to include. If not specified, all realizations will be returned."),
# relative_to_timestamp: Optional[datetime.datetime] = Query(None, description="Calculate relative to timestamp"),
authenticated_user: Annotated[AuthenticatedUser, Depends(AuthHelper.get_authenticated_user)],
case_uuid: Annotated[str, Query(description="Sumo case uuid")],
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,
# relative_to_timestamp: Annotated[datetime.datetime | None, Query(description="Calculate relative to timestamp")] = None,
# fmt:on
) -> List[schemas.VectorRealizationData]:
) -> list[schemas.VectorRealizationData]:
"""Get vector data per realization"""

access = SummaryAccess(authenticated_user.get_sumo_access_token(), case_uuid, ensemble_name)
Expand All @@ -62,7 +61,7 @@ def get_realizations_vector_data(
realizations=realizations,
)

ret_arr: List[schemas.VectorRealizationData] = []
ret_arr: list[schemas.VectorRealizationData] = []
for vec in sumo_vec_arr:
ret_arr.append(
schemas.VectorRealizationData(
Expand All @@ -79,12 +78,12 @@ def get_realizations_vector_data(

@router.get("/timestamps_list/")
def get_timestamps_list(
authenticated_user: AuthenticatedUser = Depends(AuthHelper.get_authenticated_user),
case_uuid: str = Query(description="Sumo case uuid"),
ensemble_name: str = Query(description="Ensemble name"),
resampling_frequency: Optional[schemas.Frequency] = Query(None, description="Resampling frequency"),
# realizations: Union[Sequence[int], None] = Query(None, description="Optional list of realizations to include"),
) -> List[int]:
authenticated_user: Annotated[AuthenticatedUser, Depends(AuthHelper.get_authenticated_user)],
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
stored raw dates will be returned. Thus the returned list of dates will not include
Expand All @@ -100,12 +99,12 @@ def get_timestamps_list(
@router.get("/historical_vector_data/")
# type: ignore [empty-body]
def get_historical_vector_data(
authenticated_user: AuthenticatedUser = Depends(AuthHelper.get_authenticated_user),
case_uuid: str = Query(description="Sumo case uuid"),
ensemble_name: str = Query(description="Ensemble name"),
non_historical_vector_name: str = Query(description="Name of the non-historical vector"),
resampling_frequency: Optional[schemas.Frequency] = Query(None, description="Resampling frequency"),
# relative_to_timestamp: Optional[datetime.datetime] = Query(None, description="Calculate relative to timestamp"),
authenticated_user: Annotated[AuthenticatedUser, Depends(AuthHelper.get_authenticated_user)],
case_uuid: Annotated[str, Query(description="Sumo case uuid")],
ensemble_name: Annotated[str, Query(description="Ensemble name")],
non_historical_vector_name: Annotated[str, Query(description="Name of the non-historical vector")],
resampling_frequency: Annotated[schemas.Frequency | None, Query(description="Resampling frequency")] = None,
# relative_to_timestamp: Annotated[datetime.datetime | None, Query(description="Calculate relative to timestamp")] = None,
) -> schemas.VectorHistoricalData:
access = SummaryAccess(authenticated_user.get_sumo_access_token(), case_uuid, ensemble_name)

Expand All @@ -128,14 +127,14 @@ def get_historical_vector_data(
@router.get("/statistical_vector_data/")
def get_statistical_vector_data(
# fmt:off
authenticated_user: AuthenticatedUser = Depends(AuthHelper.get_authenticated_user),
case_uuid: str = Query(description="Sumo case uuid"),
ensemble_name: str = Query(description="Ensemble name"),
vector_name: str = Query(description="Name of the vector"),
resampling_frequency: schemas.Frequency = Query(description="Resampling frequency"),
statistic_functions: Optional[Sequence[schemas.StatisticFunction]] = Query(None, description="Optional list of statistics to calculate. If not specified, all statistics will be calculated."),
realizations: Optional[Sequence[int]] = Query(None, description="Optional list of realizations to include. If not specified, all realizations will be included."),
# relative_to_timestamp: Optional[datetime.datetime] = Query(None, description="Calculate relative to timestamp"),
authenticated_user: Annotated[AuthenticatedUser, Depends(AuthHelper.get_authenticated_user)],
case_uuid: Annotated[str, Query(description="Sumo case uuid")],
ensemble_name: Annotated[str, Query(description="Ensemble name")],
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,
# 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"""
Expand Down Expand Up @@ -163,15 +162,15 @@ def get_statistical_vector_data(
@router.get("/statistical_vector_data_per_sensitivity/")
def get_statistical_vector_data_per_sensitivity(
# fmt:off
authenticated_user: AuthenticatedUser = Depends(AuthHelper.get_authenticated_user),
case_uuid: str = Query(description="Sumo case uuid"),
ensemble_name: str = Query(description="Ensemble name"),
vector_name: str = Query(description="Name of the vector"),
resampling_frequency: schemas.Frequency = Query(description="Resampling frequency"),
statistic_functions: Optional[Sequence[schemas.StatisticFunction]] = Query(None, description="Optional list of statistics to calculate. If not specified, all statistics will be calculated."),
# relative_to_timestamp: Optional[datetime.datetime] = Query(None, description="Calculate relative to timestamp"),
authenticated_user: Annotated[AuthenticatedUser, Depends(AuthHelper.get_authenticated_user)],
case_uuid: Annotated[str, Query(description="Sumo case uuid")],
ensemble_name: Annotated[str, Query(description="Ensemble name")],
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,
# relative_to_timestamp: Annotated[datetime.datetime | None, Query(description="Calculate relative to timestamp")] = None,
# fmt:on
) -> List[schemas.VectorStatisticSensitivityData]:
) -> list[schemas.VectorStatisticSensitivityData]:
"""Get statistical vector data for an ensemble per sensitivity"""

summmary_access = SummaryAccess(authenticated_user.get_sumo_access_token(), case_uuid, ensemble_name)
Expand All @@ -183,7 +182,7 @@ def get_statistical_vector_data_per_sensitivity(
vector_table, vector_metadata = summmary_access.get_vector_table(
vector_name=vector_name, resampling_frequency=service_freq, realizations=None
)
ret_data: List[schemas.VectorStatisticSensitivityData] = []
ret_data: list[schemas.VectorStatisticSensitivityData] = []
if not sensitivities:
return ret_data
for sensitivity in sensitivities:
Expand Down Expand Up @@ -214,12 +213,12 @@ def get_statistical_vector_data_per_sensitivity(
@router.get("/realization_vector_at_timestamp/")
def get_realization_vector_at_timestamp(
# fmt:off
authenticated_user: AuthenticatedUser = Depends(AuthHelper.get_authenticated_user),
case_uuid: str = Query(description="Sumo case uuid"),
ensemble_name: str = Query(description="Ensemble name"),
vector_name: str = Query(description="Name of the vector"),
timestamp_utc_ms: int = Query(description= "Timestamp in ms UTC to query vectors at"),
# realizations: Optional[Sequence[int]] = Query(None, description="Optional list of realizations to include. If not specified, all realizations will be returned."),
authenticated_user: Annotated[AuthenticatedUser, Depends(AuthHelper.get_authenticated_user)],
case_uuid: Annotated[str, Query(description="Sumo case uuid")],
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(authenticated_user.get_sumo_access_token(), case_uuid, ensemble_name)
Expand All @@ -231,12 +230,12 @@ def get_realization_vector_at_timestamp(

# @router.get("/realizations_calculated_vector_data/")
# def get_realizations_calculated_vector_data(
# authenticated_user: AuthenticatedUser = Depends(AuthHelper.get_authenticated_user),
# case_uuid: str = Query(description="Sumo case uuid"),
# ensemble_name: str = Query(description="Ensemble name"),
# expression: schemas.VectorExpressionInfo = Depends(),
# resampling_frequency: Optional[schemas.Frequency] = Query(None, description="Resampling frequency"),
# relative_to_timestamp: Optional[datetime.datetime] = Query(None, description="Calculate relative to timestamp"),
# authenticated_user: Annotated[AuthenticatedUser, Depends(AuthHelper.get_authenticated_user)],
# case_uuid: Annotated[str, Query(description="Sumo case uuid")],
# ensemble_name: Annotated[str, Query(description="Ensemble name")],
# expression: Annotated[schemas.VectorExpressionInfo, Depends()],
# resampling_frequency: Annotated[schemas.Frequency, Query(description="Resampling frequency")],
# relative_to_timestamp: Annotated[datetime.datetime | None, Query(description="Calculate relative to timestamp")] = None,
# ) -> str:
# """Get calculated vector data per realization"""
# print(expression)
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/api/models/Body_get_realizations_response.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import type { InplaceVolumetricsCategoricalMetaData } from './InplaceVolumetricsCategoricalMetaData';

export type Body_get_realizations_response = {
categorical_filter?: Array<InplaceVolumetricsCategoricalMetaData>;
realizations?: Array<number>;
categorical_filter?: (Array<InplaceVolumetricsCategoricalMetaData> | null);
realizations?: (Array<number> | null);
};

4 changes: 2 additions & 2 deletions frontend/src/api/models/EnsembleParameter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ export type EnsembleParameter = {
is_logarithmic: boolean;
is_numerical: boolean;
is_constant: boolean;
group_name?: string;
descriptive_name?: string;
group_name: (string | null);
descriptive_name: (string | null);
realizations: Array<number>;
values: (Array<number> | Array<string>);
};
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/api/models/EnsembleParameterDescription.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

export type EnsembleParameterDescription = {
name: string;
group_name?: string;
descriptive_name?: string;
group_name: (string | null);
descriptive_name: (string | null);
is_numerical: boolean;
};

4 changes: 2 additions & 2 deletions frontend/src/api/models/EnsembleScalarResponse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
export type EnsembleScalarResponse = {
realizations: Array<number>;
values: Array<number>;
name?: string;
unit?: string;
name: (string | null);
unit: (string | null);
};

3 changes: 0 additions & 3 deletions frontend/src/api/models/Frequency.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
/* tslint:disable */
/* eslint-disable */

/**
* An enumeration.
*/
export enum Frequency {
DAILY = 'DAILY',
WEEKLY = 'WEEKLY',
Expand Down
3 changes: 0 additions & 3 deletions frontend/src/api/models/SensitivityType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
/* tslint:disable */
/* eslint-disable */

/**
* An enumeration.
*/
export enum SensitivityType {
MONTECARLO = 'montecarlo',
SCENARIO = 'scenario',
Expand Down
3 changes: 0 additions & 3 deletions frontend/src/api/models/StatisticFunction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
/* tslint:disable */
/* eslint-disable */

/**
* An enumeration.
*/
export enum StatisticFunction {
MEAN = 'MEAN',
MIN = 'MIN',
Expand Down
3 changes: 0 additions & 3 deletions frontend/src/api/models/SurfaceStatisticFunction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
/* tslint:disable */
/* eslint-disable */

/**
* An enumeration.
*/
export enum SurfaceStatisticFunction {
MEAN = 'MEAN',
STD = 'STD',
Expand Down
14 changes: 7 additions & 7 deletions frontend/src/api/models/WellBoreHeader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ export type WellBoreHeader = {
wellbore_uuid: string;
unique_wellbore_identifier: string;
wellbore_purpose: string;
easting?: number;
northing?: number;
parent_wellbore?: string;
total_depth_driller_tvd?: number;
total_depth_driller_md?: number;
drill_start_date?: string;
drill_end_date?: string;
easting: (number | null);
northing: (number | null);
parent_wellbore: (string | null);
total_depth_driller_tvd: (number | null);
total_depth_driller_md: (number | null);
drill_start_date: (string | null);
drill_end_date: (string | null);
};

2 changes: 1 addition & 1 deletion frontend/src/api/models/WellCompletionZone.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
export type WellCompletionZone = {
name: string;
color: string;
subzones?: Array<WellCompletionZone>;
subzones: (Array<WellCompletionZone> | null);
};

2 changes: 1 addition & 1 deletion frontend/src/api/services/DefaultService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export class DefaultService {
* @throws ApiError
*/
public loginRoute(
redirectUrlAfterLogin?: string,
redirectUrlAfterLogin?: (string | null),
): CancelablePromise<any> {
return this.httpRequest.request({
method: 'GET',
Expand Down
Loading

0 comments on commit 7ea4f8c

Please sign in to comment.