Skip to content

Commit

Permalink
Merge remote-tracking branch 'equinor/main' into 2d-viewer-context-de…
Browse files Browse the repository at this point in the history
…ps-spike
  • Loading branch information
rubenthoms committed Nov 12, 2024
2 parents 1ca3234 + 09109b0 commit 6928469
Show file tree
Hide file tree
Showing 78 changed files with 3,952 additions and 783 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ in the following folders are changed:
./backend/src
```

If other files are changed through the host operativey system,
If other files are changed through the host operating system,
e.g. typically when a new dependency is added, the relevant component needs to be rebuilt. I.e.
`docker-compose up --build frontend` or `docker-compose up --build backend`.

Expand Down
2 changes: 0 additions & 2 deletions backend_py/primary/primary/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
from primary.auth.auth_helper import AuthHelper
from primary.auth.enforce_logged_in_middleware import EnforceLoggedInMiddleware
from primary.middleware.add_process_time_to_server_timing_middleware import AddProcessTimeToServerTimingMiddleware
from primary.routers.correlations.router import router as correlations_router
from primary.routers.dev.router import router as dev_router
from primary.routers.explore import router as explore_router
from primary.routers.general import router as general_router
Expand Down Expand Up @@ -77,7 +76,6 @@ def custom_generate_unique_id(route: APIRoute) -> str:
app.include_router(inplace_volumetrics_router, prefix="/inplace_volumetrics", tags=["inplace_volumetrics"])
app.include_router(surface_router, prefix="/surface", tags=["surface"])
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(group_tree_router, prefix="/group_tree", tags=["group_tree"])
app.include_router(pvt_router, prefix="/pvt", tags=["pvt"])
Expand Down
Empty file.
65 changes: 0 additions & 65 deletions backend_py/primary/primary/routers/correlations/router.py

This file was deleted.

2 changes: 1 addition & 1 deletion backend_py/primary/primary/routers/parameters/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ async def get_parameter_names_and_description(
name=parameter.name,
descriptive_name=parameter.descriptive_name,
group_name=parameter.group_name,
is_numerical=parameter.is_numerical,
is_discrete=parameter.is_discrete,
)
for parameter in parameters
]
Expand Down
2 changes: 1 addition & 1 deletion backend_py/primary/primary/routers/parameters/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ class EnsembleParameterDescription(BaseModel):
name: str
group_name: Optional[str] = None
descriptive_name: Optional[str] = None
is_numerical: bool
is_discrete: bool
19 changes: 19 additions & 0 deletions backend_py/primary/primary/routers/rft/converters.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from primary.services.sumo_access.rft_types import RftTableDefinition

from . import schemas


def to_api_table_definition(
table_definition: RftTableDefinition,
) -> schemas.RftTableDefinition:
"""Converts the table definitions from the sumo service to the API format"""
return schemas.RftTableDefinition(
response_names=table_definition.response_names,
well_infos=[
schemas.RftWellInfo(
well_name=well_info.well_name,
timestamps_utc_ms=well_info.timestamps_utc_ms,
)
for well_info in table_definition.well_infos
],
)
15 changes: 6 additions & 9 deletions backend_py/primary/primary/routers/rft/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,23 @@
from primary.services.utils.authenticated_user import AuthenticatedUser

from . import schemas
from . import converters

LOGGER = logging.getLogger(__name__)

router = APIRouter()


@router.get("/rft_info")
async def get_rft_info(
@router.get("/table_definition")
async def get_table_definition(
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.RftInfo]:
) -> schemas.RftTableDefinition:
access = await RftAccess.from_case_uuid_async(authenticated_user.get_sumo_access_token(), case_uuid, ensemble_name)
rft_well_list = await access.get_rft_info()
rft_table_def = await access.get_rft_info()

ret_rft_well_list: list[schemas.RftInfo] = []
for rftinfo in rft_well_list:
ret_rft_well_list.append(schemas.RftInfo.model_validate(rftinfo.model_dump()))

return ret_rft_well_list
return converters.to_api_table_definition(rft_table_def)


@router.get("/realization_data")
Expand Down
7 changes: 6 additions & 1 deletion backend_py/primary/primary/routers/rft/schemas.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
from pydantic import BaseModel


class RftInfo(BaseModel):
class RftWellInfo(BaseModel):
well_name: str
timestamps_utc_ms: list[int]


class RftTableDefinition(BaseModel):
response_names: list[str]
well_infos: list[RftWellInfo]


class RftRealizationData(BaseModel):
well_name: str
realization: int
Expand Down
62 changes: 0 additions & 62 deletions backend_py/primary/primary/services/parameter_correlations.py

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def parameter_table_to_ensemble_parameters(parameter_table: pa.Table) -> List[En
name=parameter_name,
group_name=f"LOG10_{group_name}" if is_logarithmic else group_name,
is_logarithmic=is_logarithmic,
is_numerical=parameter_table.schema.field(table_column_name).type != pa.string,
is_discrete=_is_discrete_column(parameter_table.schema.field(table_column_name).type),
is_constant=len(set(parameter_table[table_column_name])) == 1,
descriptive_name=parameter_name,
values=parameter_table[table_column_name].to_numpy().tolist(),
Expand All @@ -150,6 +150,20 @@ def parameter_table_to_ensemble_parameters(parameter_table: pa.Table) -> List[En
return ensemble_parameters


def _is_discrete_column(column_type: pa.DataType) -> bool:
"""Check if a column is discrete
Discrete parameter is defined as a parameter that is either a string or an integer
"""
return (
column_type == pa.string()
or column_type == pa.int64()
or column_type == pa.int32()
or column_type == pa.int16()
or column_type == pa.int8()
)


def _parameter_name_and_group_name_to_parameter_str(parameter_name: str, group_name: Optional[str]) -> str:
"""Convert a parameter name and group name to a parameter string"""
return f"{group_name}:{parameter_name}" if group_name else parameter_name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class EnsembleParameter(BaseModel):

name: str
is_logarithmic: bool
is_numerical: bool
is_discrete: bool # values are string or integer
is_constant: bool # all values are equal
group_name: Optional[str] = None
descriptive_name: Optional[str] = None
Expand Down
Loading

0 comments on commit 6928469

Please sign in to comment.