diff --git a/backend_py/primary/primary/routers/polygons/router.py b/backend_py/primary/primary/routers/polygons/router.py index b4834e800..a2ff0b7f5 100644 --- a/backend_py/primary/primary/routers/polygons/router.py +++ b/backend_py/primary/primary/routers/polygons/router.py @@ -11,6 +11,7 @@ from primary.services.sumo_access.case_inspector import CaseInspector from primary.services.sumo_access.polygons_access import PolygonsAccess from primary.services.utils.authenticated_user import AuthenticatedUser +from primary.utils.drogon import is_drogon_identifier from . import converters, schemas @@ -37,7 +38,7 @@ async def get_polygons_directory( strat_column_identifier = await case_inspector.get_stratigraphic_column_identifier_async() smda_access: Union[SmdaAccess, DrogonSmdaAccess] - if strat_column_identifier == "DROGON_HAS_NO_STRATCOLUMN": + if is_drogon_identifier(strat_column_identifier=strat_column_identifier): smda_access = DrogonSmdaAccess() else: smda_access = SmdaAccess(authenticated_user.get_smda_access_token()) diff --git a/backend_py/primary/primary/routers/surface/router.py b/backend_py/primary/primary/routers/surface/router.py index fd16a0a1a..11b12e1f0 100644 --- a/backend_py/primary/primary/routers/surface/router.py +++ b/backend_py/primary/primary/routers/surface/router.py @@ -17,6 +17,7 @@ from primary.services.surface_query_service.surface_query_service import batch_sample_surface_in_points_async from primary.services.surface_query_service.surface_query_service import RealizationSampleResult from primary.utils.response_perf_metrics import ResponsePerfMetrics +from primary.utils.drogon import is_drogon_identifier from . import converters from . import schemas @@ -323,7 +324,7 @@ async def _get_stratigraphic_units_for_case_async( perf_metrics.record_lap("get-strat-ident") smda_access: SmdaAccess | DrogonSmdaAccess - if strat_column_identifier == "DROGON_HAS_NO_STRATCOLUMN": + if is_drogon_identifier(strat_column_identifier=strat_column_identifier): smda_access = DrogonSmdaAccess() else: smda_access = SmdaAccess(authenticated_user.get_smda_access_token()) diff --git a/backend_py/primary/primary/routers/surface/schemas.py b/backend_py/primary/primary/routers/surface/schemas.py index 3e6224991..719478b86 100644 --- a/backend_py/primary/primary/routers/surface/schemas.py +++ b/backend_py/primary/primary/routers/surface/schemas.py @@ -167,6 +167,12 @@ class PointSetXY(BaseModel): class StratigraphicUnit(BaseModel): + """ + Stratigraphic unit from SMDA + + Camel case attributes needed for esvIntersection component in front-end + """ + identifier: str top: str base: str diff --git a/backend_py/primary/primary/routers/well/converters.py b/backend_py/primary/primary/routers/well/converters.py index ab40d5a80..3aa679195 100644 --- a/backend_py/primary/primary/routers/well/converters.py +++ b/backend_py/primary/primary/routers/well/converters.py @@ -1,4 +1,4 @@ -from primary.services.smda_access.types import WellboreHeader, WellboreTrajectory, WellborePick, StratigraphicUnit +from primary.services.smda_access.types import WellboreHeader, WellboreTrajectory, WellborePick from primary.services.ssdl_access.types import ( WellboreCasing, WellboreCompletion, @@ -27,25 +27,6 @@ def convert_wellbore_pick_to_schema(wellbore_pick: WellborePick) -> schemas.Well ) -def convert_stratigraphic_unit_to_schema( - stratigraphic_unit: StratigraphicUnit, -) -> schemas.StratigraphicUnit: - return schemas.StratigraphicUnit( - identifier=stratigraphic_unit.identifier, - top=stratigraphic_unit.top, - base=stratigraphic_unit.base, - stratUnitLevel=stratigraphic_unit.strat_unit_level, - stratUnitType=stratigraphic_unit.strat_unit_type, - topAge=stratigraphic_unit.top_age, - baseAge=stratigraphic_unit.base_age, - stratUnitParent=stratigraphic_unit.strat_unit_parent, - colorR=stratigraphic_unit.color_r, - colorG=stratigraphic_unit.color_g, - colorB=stratigraphic_unit.color_b, - lithologyType=stratigraphic_unit.lithology_type, - ) - - def convert_wellbore_header_to_schema( drilled_wellbore_header: WellboreHeader, ) -> schemas.WellboreHeader: diff --git a/backend_py/primary/primary/routers/well/router.py b/backend_py/primary/primary/routers/well/router.py index a1eee9c7d..9957529f5 100644 --- a/backend_py/primary/primary/routers/well/router.py +++ b/backend_py/primary/primary/routers/well/router.py @@ -7,6 +7,7 @@ from primary.services.smda_access import SmdaAccess from primary.services.utils.authenticated_user import AuthenticatedUser from primary.auth.auth_helper import AuthHelper +from primary.utils.drogon import is_drogon_identifier from primary.services.ssdl_access.well_access import WellAccess as SsdlWellAccess @@ -27,7 +28,7 @@ async def get_drilled_wellbore_headers( ) -> List[schemas.WellboreHeader]: """Get wellbore headers for all wells in the field""" well_access: Union[SmdaAccess, DrogonSmdaAccess] - if field_identifier == "DROGON": + if is_drogon_identifier(field_identifier=field_identifier): # Handle DROGON well_access = DrogonSmdaAccess() else: @@ -48,7 +49,7 @@ async def get_well_trajectories( ) -> List[schemas.WellboreTrajectory]: """Get well trajectories for field""" well_access: Union[SmdaAccess, DrogonSmdaAccess] - if field_identifier == "DROGON": + if is_drogon_identifier(field_identifier=field_identifier): # Handle DROGON well_access = DrogonSmdaAccess() else: @@ -74,7 +75,7 @@ async def get_wellbore_pick_identifiers( ) -> List[str]: """Get wellbore pick identifiers for field and stratigraphic column""" well_access: Union[SmdaAccess, DrogonSmdaAccess] - if strat_column_identifier == "DROGON_HAS_NO_STRATCOLUMN": + if is_drogon_identifier(strat_column_identifier=strat_column_identifier): # Handle DROGON well_access = DrogonSmdaAccess() @@ -97,7 +98,7 @@ async def get_wellbore_picks_for_pick_identifier( ) -> List[schemas.WellborePick]: """Get wellbore picks for field and pick identifier""" well_access: Union[SmdaAccess, DrogonSmdaAccess] - if field_identifier == "DROGON": + if is_drogon_identifier(field_identifier=field_identifier): # Handle DROGON well_access = DrogonSmdaAccess() @@ -120,7 +121,8 @@ async def get_wellbore_picks_for_wellbore( ) -> List[schemas.WellborePick]: """Get wellbore picks for field and pick identifier""" well_access: Union[SmdaAccess, DrogonSmdaAccess] - if wellbore_uuid in ["drogon_horizontal", "drogon_vertical"]: + + if is_drogon_identifier(wellbore_uuid=wellbore_uuid): # Handle DROGON well_access = DrogonSmdaAccess() @@ -141,7 +143,7 @@ async def get_wellbore_completions( """Get well bore completions for a single well bore""" # Handle DROGON - if wellbore_uuid in ["drogon_horizontal", "drogon_vertical"]: + if is_drogon_identifier(wellbore_uuid=wellbore_uuid): return [] well_access = SsdlWellAccess(authenticated_user.get_ssdl_access_token()) @@ -163,7 +165,7 @@ async def get_wellbore_casings( """Get well bore casings for a single well bore""" # Handle DROGON - if wellbore_uuid in ["drogon_horizontal", "drogon_vertical"]: + if is_drogon_identifier(wellbore_uuid=wellbore_uuid): return [] well_access = SsdlWellAccess(authenticated_user.get_ssdl_access_token()) @@ -183,7 +185,7 @@ async def get_wellbore_perforations( """Get well bore casing for a single well bore""" # Handle DROGON - if wellbore_uuid in ["drogon_horizontal", "drogon_vertical"]: + if is_drogon_identifier(wellbore_uuid=wellbore_uuid): return [] well_access = SsdlWellAccess(authenticated_user.get_ssdl_access_token()) @@ -206,7 +208,7 @@ async def get_wellbore_log_curve_headers( """Get all log curve headers for a single well bore""" # Handle DROGON - if wellbore_uuid in ["drogon_horizontal", "drogon_vertical"]: + if is_drogon_identifier(wellbore_uuid=wellbore_uuid): return [] well_access = SsdlWellAccess(authenticated_user.get_ssdl_access_token()) @@ -232,7 +234,7 @@ async def get_log_curve_data( """Get log curve data""" # Handle DROGON - if wellbore_uuid in ["drogon_horizontal", "drogon_vertical"]: + if is_drogon_identifier(wellbore_uuid=wellbore_uuid): raise NotImplementedError("DROGON log curve data not implemented") well_access = SsdlWellAccess(authenticated_user.get_ssdl_access_token()) diff --git a/backend_py/primary/primary/routers/well/schemas.py b/backend_py/primary/primary/routers/well/schemas.py index cbb606e1c..fb31a9e8a 100644 --- a/backend_py/primary/primary/routers/well/schemas.py +++ b/backend_py/primary/primary/routers/well/schemas.py @@ -2,27 +2,6 @@ from pydantic import BaseModel -class StratigraphicUnit(BaseModel): - """ - Stratigraphic unit from SMDA - - Camel case attributes needed for esvIntersection component in front-end - """ - - identifier: str - top: str - base: str - stratUnitLevel: int - stratUnitType: str - topAge: int | float - baseAge: int | float - stratUnitParent: Optional[str] = None - colorR: int - colorG: int - colorB: int - lithologyType: int | float | str = "unknown" - - class WellboreHeader(BaseModel): wellboreUuid: str uniqueWellboreIdentifier: str @@ -66,11 +45,6 @@ class WellborePick(BaseModel): mdUnit: str -class WellborePicksAndStratigraphicUnits(BaseModel): - wellbore_picks: List[WellborePick] = [] - stratigraphic_units: List[StratigraphicUnit] = [] - - class WellboreCompletion(BaseModel): mdTop: float mdBottom: float diff --git a/backend_py/primary/primary/utils/drogon.py b/backend_py/primary/primary/utils/drogon.py new file mode 100644 index 000000000..348ce3240 --- /dev/null +++ b/backend_py/primary/primary/utils/drogon.py @@ -0,0 +1,19 @@ +from typing import Optional + + +def is_drogon_identifier( + field_identifier: Optional[str] = None, + wellbore_uuid: Optional[str] = None, + strat_column_identifier: Optional[str] = None, +) -> bool: + """ + Checks if an element's identifier is for the drogon mock. + """ + if field_identifier == "DROGON": + return True + if wellbore_uuid in ["drogon_horizontal", "drogon_vertical"]: + return True + if strat_column_identifier == "DROGON_HAS_NO_STRATCOLUMN": + return True + + return False diff --git a/frontend/src/api/models/StratigraphicUnit.ts b/frontend/src/api/models/StratigraphicUnit.ts index bb879bac0..614eb722c 100644 --- a/frontend/src/api/models/StratigraphicUnit.ts +++ b/frontend/src/api/models/StratigraphicUnit.ts @@ -2,6 +2,11 @@ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ +/** + * Stratigraphic unit from SMDA + * + * Camel case attributes needed for esvIntersection component in front-end + */ export type StratigraphicUnit = { identifier: string; top: string;