diff --git a/backend_py/primary/primary/routers/polygons/router.py b/backend_py/primary/primary/routers/polygons/router.py index 106fd485c..a2ff0b7f5 100644 --- a/backend_py/primary/primary/routers/polygons/router.py +++ b/backend_py/primary/primary/routers/polygons/router.py @@ -35,14 +35,13 @@ async def get_polygons_directory( polygons_dir = await access.get_polygons_directory_async() case_inspector = CaseInspector.from_case_uuid(authenticated_user.get_sumo_access_token(), case_uuid) - field_identifiers = await case_inspector.get_field_identifiers_async() strat_column_identifier = await case_inspector.get_stratigraphic_column_identifier_async() smda_access: Union[SmdaAccess, DrogonSmdaAccess] if is_drogon_identifier(strat_column_identifier=strat_column_identifier): smda_access = DrogonSmdaAccess() else: - smda_access = SmdaAccess(authenticated_user.get_smda_access_token(), field_identifier=field_identifiers[0]) + smda_access = SmdaAccess(authenticated_user.get_smda_access_token()) strat_units = await smda_access.get_stratigraphic_units(strat_column_identifier) sorted_stratigraphic_surfaces = sort_stratigraphic_names_by_hierarchy(strat_units) diff --git a/backend_py/primary/primary/routers/surface/router.py b/backend_py/primary/primary/routers/surface/router.py index 9a447f68c..11b12e1f0 100644 --- a/backend_py/primary/primary/routers/surface/router.py +++ b/backend_py/primary/primary/routers/surface/router.py @@ -320,7 +320,6 @@ async def _get_stratigraphic_units_for_case_async( perf_metrics = PerfMetrics() case_inspector = CaseInspector.from_case_uuid(authenticated_user.get_sumo_access_token(), case_uuid) - field_identifiers = await case_inspector.get_field_identifiers_async() strat_column_identifier = await case_inspector.get_stratigraphic_column_identifier_async() perf_metrics.record_lap("get-strat-ident") @@ -328,7 +327,7 @@ async def _get_stratigraphic_units_for_case_async( if is_drogon_identifier(strat_column_identifier=strat_column_identifier): smda_access = DrogonSmdaAccess() else: - smda_access = SmdaAccess(authenticated_user.get_smda_access_token(), field_identifier=field_identifiers[0]) + smda_access = SmdaAccess(authenticated_user.get_smda_access_token()) strat_units = await smda_access.get_stratigraphic_units(strat_column_identifier) perf_metrics.record_lap("get-strat-units") diff --git a/backend_py/primary/primary/routers/well/router.py b/backend_py/primary/primary/routers/well/router.py index 8891c4b38..9957529f5 100644 --- a/backend_py/primary/primary/routers/well/router.py +++ b/backend_py/primary/primary/routers/well/router.py @@ -32,9 +32,9 @@ async def get_drilled_wellbore_headers( # Handle DROGON well_access = DrogonSmdaAccess() else: - well_access = SmdaAccess(authenticated_user.get_smda_access_token(), field_identifier=field_identifier) + well_access = SmdaAccess(authenticated_user.get_smda_access_token()) - wellbore_headers = await well_access.get_wellbore_headers() + wellbore_headers = await well_access.get_wellbore_headers(field_identifier) return [converters.convert_wellbore_header_to_schema(wellbore_header) for wellbore_header in wellbore_headers] @@ -53,9 +53,12 @@ async def get_well_trajectories( # Handle DROGON well_access = DrogonSmdaAccess() else: - well_access = SmdaAccess(authenticated_user.get_smda_access_token(), field_identifier=field_identifier) + well_access = SmdaAccess(authenticated_user.get_smda_access_token()) - wellbore_trajectories = await well_access.get_wellbore_trajectories(wellbore_uuids=wellbore_uuids) + wellbore_trajectories = await well_access.get_wellbore_trajectories( + field_identifier=field_identifier, + wellbore_uuids=wellbore_uuids, + ) return [ converters.convert_well_trajectory_to_schema(wellbore_trajectory) @@ -67,19 +70,17 @@ async def get_well_trajectories( async def get_wellbore_pick_identifiers( # fmt:off authenticated_user: AuthenticatedUser = Depends(AuthHelper.get_authenticated_user), - field_identifier: str = Query(description="Official field identifier"), strat_column_identifier: str = Query(description="Stratigraphic column identifier") # fmt:on ) -> List[str]: """Get wellbore pick identifiers for field and stratigraphic column""" well_access: Union[SmdaAccess, DrogonSmdaAccess] - if is_drogon_identifier(strat_column_identifier=strat_column_identifier): # Handle DROGON well_access = DrogonSmdaAccess() else: - well_access = SmdaAccess(authenticated_user.get_smda_access_token(), field_identifier=field_identifier) + well_access = SmdaAccess(authenticated_user.get_smda_access_token()) wellbore_picks = await well_access.get_wellbore_pick_identifiers_in_stratigraphic_column( strat_column_identifier=strat_column_identifier @@ -102,9 +103,12 @@ async def get_wellbore_picks_for_pick_identifier( well_access = DrogonSmdaAccess() else: - well_access = SmdaAccess(authenticated_user.get_smda_access_token(), field_identifier=field_identifier) + well_access = SmdaAccess(authenticated_user.get_smda_access_token()) - wellbore_picks = await well_access.get_wellbore_picks_for_pick_identifier(pick_identifier=pick_identifier) + wellbore_picks = await well_access.get_wellbore_picks_for_pick_identifier( + field_identifier=field_identifier, + pick_identifier=pick_identifier, + ) return [converters.convert_wellbore_pick_to_schema(wellbore_pick) for wellbore_pick in wellbore_picks] @@ -112,18 +116,18 @@ async def get_wellbore_picks_for_pick_identifier( async def get_wellbore_picks_for_wellbore( # fmt:off authenticated_user: AuthenticatedUser = Depends(AuthHelper.get_authenticated_user), - field_identifier: str = Query(description="Official field identifier"), wellbore_uuid: str = Query(description="Wellbore uuid") # fmt:on ) -> List[schemas.WellborePick]: """Get wellbore picks for field and pick identifier""" well_access: Union[SmdaAccess, DrogonSmdaAccess] + if is_drogon_identifier(wellbore_uuid=wellbore_uuid): # Handle DROGON well_access = DrogonSmdaAccess() else: - well_access = SmdaAccess(authenticated_user.get_smda_access_token(), field_identifier=field_identifier) + well_access = SmdaAccess(authenticated_user.get_smda_access_token()) wellbore_picks = await well_access.get_wellbore_picks_for_wellbore(wellbore_uuid=wellbore_uuid) return [converters.convert_wellbore_pick_to_schema(wellbore_pick) for wellbore_pick in wellbore_picks] diff --git a/backend_py/primary/primary/services/smda_access/drogon/drogon_smda_access.py b/backend_py/primary/primary/services/smda_access/drogon/drogon_smda_access.py index e32f82fc4..9204a616b 100644 --- a/backend_py/primary/primary/services/smda_access/drogon/drogon_smda_access.py +++ b/backend_py/primary/primary/services/smda_access/drogon/drogon_smda_access.py @@ -18,11 +18,14 @@ def __init__(self) -> None: async def get_stratigraphic_units(self, stratigraphic_column_identifier: str) -> List[StratigraphicUnit]: return get_drogon_strat_units() - async def get_wellbore_headers(self) -> List[WellboreHeader]: + # pylint: disable=unused-argument + async def get_wellbore_headers(self, field_identififer: str) -> List[WellboreHeader]: """Get Drogon wellbore headers""" return get_drogon_well_headers() - async def get_wellbore_trajectories(self, wellbore_uuids: Optional[List[str]] = None) -> List[WellboreTrajectory]: + async def get_wellbore_trajectories( + self, field_identifier: str, wellbore_uuids: Optional[List[str]] = None + ) -> List[WellboreTrajectory]: """Get all Drogon trajectories""" all_well_trajs = get_drogon_well_trajectories() if wellbore_uuids: @@ -40,6 +43,7 @@ async def get_wellbore_picks_for_wellbore( # pylint: disable=unused-argument async def get_wellbore_picks_for_pick_identifier( self, + field_identifier: str, pick_identifier: str, interpreter: str = "STAT", obs_no: Optional[int] = None, diff --git a/backend_py/primary/primary/services/smda_access/smda_access.py b/backend_py/primary/primary/services/smda_access/smda_access.py index 152d53c15..9babae2c7 100644 --- a/backend_py/primary/primary/services/smda_access/smda_access.py +++ b/backend_py/primary/primary/services/smda_access/smda_access.py @@ -24,9 +24,8 @@ class SmdaEndpoints: class SmdaAccess: - def __init__(self, access_token: str, field_identifier: str): + def __init__(self, access_token: str): self._smda_token = access_token - self._field_identifier = field_identifier async def _smda_get_request(self, endpoint: str, params: dict) -> List[dict]: return await smda_get_request(access_token=self._smda_token, endpoint=endpoint, params=params) @@ -46,7 +45,7 @@ async def get_stratigraphic_units(self, strat_column_identifier: str) -> List[St units = [StratigraphicUnit(**result) for result in results] return units - async def get_wellbore_headers(self) -> List[WellboreHeader]: + async def get_wellbore_headers(self, field_identifier: str) -> List[WellboreHeader]: """ Get wellbore header information for all wellbores in a field. We need the wellbores with actual survey data, so we must use the wellbore-survey-headers endpoint. @@ -65,7 +64,7 @@ async def get_wellbore_headers(self) -> List[WellboreHeader]: params = { "_projection": ",".join(projection), "_sort": "unique_wellbore_identifier", - "field_identifier": self._field_identifier, + "field_identifier": field_identifier, } survey_header_results = await self._smda_get_request( @@ -73,13 +72,13 @@ async def get_wellbore_headers(self) -> List[WellboreHeader]: ) if not survey_header_results: - raise NoDataError(f"No wellbore headers found for {self._field_identifier=}.", Service.SMDA) + raise NoDataError(f"No wellbore headers found for {field_identifier=}.", Service.SMDA) projection = ["unique_wellbore_identifier", "wellbore_purpose", "wellbore_status"] params = { "_projection": ",".join(projection), "_sort": "unique_wellbore_identifier", - "field_identifier": self._field_identifier, + "field_identifier": field_identifier, } wellbore_headers_results = await self._smda_get_request(endpoint=SmdaEndpoints.WELLHEADERS, params=params) @@ -101,14 +100,16 @@ async def get_wellbore_headers(self) -> List[WellboreHeader]: return [WellboreHeader(**result) for result in survey_header_results] - async def get_wellbore_trajectories(self, wellbore_uuids: Optional[List[str]] = None) -> List[WellboreTrajectory]: + async def get_wellbore_trajectories( + self, field_identifier: str, wellbore_uuids: Optional[List[str]] = None + ) -> List[WellboreTrajectory]: """ Get wellbore trajectories (survey samples) for all wells in a field, optionally with a subset of wellbores. """ params = { "_projection": "wellbore_uuid, unique_wellbore_identifier,easting,northing,tvd_msl,md", "_sort": "unique_wellbore_identifier,md", - "field_identifier": self._field_identifier, + "field_identifier": field_identifier, } if wellbore_uuids: params["wellbore_uuid"] = ", ".join(wellbore_uuids) @@ -116,9 +117,7 @@ async def get_wellbore_trajectories(self, wellbore_uuids: Optional[List[str]] = result = await self._smda_get_request(endpoint=SmdaEndpoints.WELLBORE_SURVEY_SAMPLES, params=params) if not result: - raise NoDataError( - f"No wellbore surveys found for {self._field_identifier}, {wellbore_uuids=}.", Service.SMDA - ) + raise NoDataError(f"No wellbore surveys found for {field_identifier=}, {wellbore_uuids=}.", Service.SMDA) # Convert the result to polars for processing resultdf = pl.DataFrame(result) @@ -198,6 +197,7 @@ async def get_wellbore_picks_for_wellbore( async def get_wellbore_picks_for_pick_identifier( self, + field_identifier: str, pick_identifier: str, interpreter: str = "STAT", obs_no: Optional[int] = None, @@ -208,7 +208,7 @@ async def get_wellbore_picks_for_pick_identifier( """ params = { "_sort": "unique_wellbore_identifier,md", - "field_identifier": self._field_identifier, + "field_identifier": field_identifier, "pick_identifier": pick_identifier, "interpreter": interpreter, } @@ -218,7 +218,7 @@ async def get_wellbore_picks_for_pick_identifier( results = await self._smda_get_request(endpoint=SmdaEndpoints.WELLBORE_PICKS, params=params) if not results: raise NoDataError( - f"No wellbore picks found for {self._field_identifier=}, {pick_identifier=}, {interpreter=}, {obs_no=}.", + f"No wellbore picks found for {field_identifier=}, {pick_identifier=}, {interpreter=}, {obs_no=}.", Service.SMDA, ) picks: List[WellborePick] = [] diff --git a/frontend/src/api/services/WellService.ts b/frontend/src/api/services/WellService.ts index e79a6a572..222cf22bc 100644 --- a/frontend/src/api/services/WellService.ts +++ b/frontend/src/api/services/WellService.ts @@ -62,20 +62,17 @@ export class WellService { /** * Get Wellbore Pick Identifiers * Get wellbore pick identifiers for field and stratigraphic column - * @param fieldIdentifier Official field identifier * @param stratColumnIdentifier Stratigraphic column identifier * @returns string Successful Response * @throws ApiError */ public getWellborePickIdentifiers( - fieldIdentifier: string, stratColumnIdentifier: string, ): CancelablePromise> { return this.httpRequest.request({ method: 'GET', url: '/well/wellbore_pick_identifiers/', query: { - 'field_identifier': fieldIdentifier, 'strat_column_identifier': stratColumnIdentifier, }, errors: { @@ -110,20 +107,17 @@ export class WellService { /** * Get Wellbore Picks For Wellbore * Get wellbore picks for field and pick identifier - * @param fieldIdentifier Official field identifier * @param wellboreUuid Wellbore uuid * @returns WellborePick Successful Response * @throws ApiError */ public getWellborePicksForWellbore( - fieldIdentifier: string, wellboreUuid: string, ): CancelablePromise> { return this.httpRequest.request({ method: 'GET', url: '/well/wellbore_picks_for_wellbore/', query: { - 'field_identifier': fieldIdentifier, 'wellbore_uuid': wellboreUuid, }, errors: { diff --git a/frontend/src/modules/Intersection/utils/layers/WellpicksLayer.ts b/frontend/src/modules/Intersection/utils/layers/WellpicksLayer.ts index 2ca0eaec8..c68ba3a05 100644 --- a/frontend/src/modules/Intersection/utils/layers/WellpicksLayer.ts +++ b/frontend/src/modules/Intersection/utils/layers/WellpicksLayer.ts @@ -72,20 +72,12 @@ export class WellpicksLayer extends BaseLayer { - const queryKey = [ - "getWellborePicksAndStratigraphicUnits", - this._settings.fieldIdentifier, - this._settings.wellboreUuid, - ]; + const queryKey = ["getWellborePicksAndStratigraphicUnits", this._settings.wellboreUuid]; this.registerQueryKey(queryKey); const wellborePicksPromise = queryClient.fetchQuery({ queryKey, - queryFn: () => - apiService.well.getWellborePicksForWellbore( - this._settings.fieldIdentifier ?? "", - this._settings.wellboreUuid ?? "" - ), + queryFn: () => apiService.well.getWellborePicksForWellbore(this._settings.wellboreUuid ?? ""), staleTime: STALE_TIME, gcTime: CACHE_TIME, }); diff --git a/frontend/src/modules/WellLogViewer/settings/atoms/queryAtoms.ts b/frontend/src/modules/WellLogViewer/settings/atoms/queryAtoms.ts index 667b586d2..407efef04 100644 --- a/frontend/src/modules/WellLogViewer/settings/atoms/queryAtoms.ts +++ b/frontend/src/modules/WellLogViewer/settings/atoms/queryAtoms.ts @@ -43,13 +43,12 @@ export const wellLogCurveHeadersQueryAtom = atomWithQuery((get) => { }); export const wellborePicksQueryAtom = atomWithQuery((get) => { - const selectedFieldIdent = get(selectedFieldIdentifierAtom) ?? ""; const selectedWellboreUuid = get(selectedWellboreHeaderAtom)?.wellboreUuid ?? ""; return { - queryKey: ["getWellborePicksForWellbore", selectedFieldIdent, selectedWellboreUuid], - enabled: Boolean(selectedFieldIdent && selectedWellboreUuid), - queryFn: () => apiService.well.getWellborePicksForWellbore(selectedFieldIdent, selectedWellboreUuid), + queryKey: ["getWellborePicksForWellbore", selectedWellboreUuid], + enabled: Boolean(selectedWellboreUuid), + queryFn: () => apiService.well.getWellborePicksForWellbore(selectedWellboreUuid), ...SHARED_QUERY_OPTS, }; }); @@ -61,7 +60,7 @@ export const wellboreStratigraphicUnitsQueryAtom = atomWithQuery((get) => { const caseUuid = selectedEnsemble?.getCaseUuid() ?? ""; return { - queryKey: ["getWellborePicksForWellbore", caseUuid], + queryKey: ["getStratigraphicUnits", caseUuid], enabled: Boolean(caseUuid), queryFn: () => apiService.surface.getStratigraphicUnits(caseUuid), ...SHARED_QUERY_OPTS,