Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
HansKallekleiv committed Dec 3, 2024
1 parent 4500279 commit a1e2f81
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@


class SmdaAccess:
"""Drogon SMDA access class containing methods to get mocked Drogon data
disable-unused-argument needed to keep the same method signature as the SMDA access class"""

def __init__(self) -> None:
pass

# type: ignore
# pylint: disable=unused-argument
async def get_stratigraphic_units(self, stratigraphic_column_identifier: str) -> List[StratigraphicUnit]:
return get_drogon_strat_units()
Expand All @@ -27,7 +29,6 @@ async def get_wellbore_trajectories(self, wellbore_uuids: Optional[List[str]] =
return [traj for traj in all_well_trajs if traj.wellbore_uuid in wellbore_uuids]
return all_well_trajs

# type: ignore
# pylint: disable=unused-argument
async def get_wellbore_picks_for_wellbore(
self, wellbore_uuid: str, obs_no: Optional[int] = None
Expand All @@ -36,7 +37,6 @@ async def get_wellbore_picks_for_wellbore(
well_picks = [pick for pick in get_drogon_well_picks() if pick.wellbore_uuid == wellbore_uuid]
return well_picks

# type: ignore
# pylint: disable=unused-argument
async def get_wellbore_picks_for_pick_identifier(
self,
Expand Down
18 changes: 13 additions & 5 deletions backend_py/primary/primary/services/smda_access/smda_access.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,20 @@ async def get_wellbore_headers(self) -> List[WellboreHeader]:

wellbore_headers_results = await self._smda_get_request(endpoint=SmdaEndpoints.WELLHEADERS, params=params)

# Create a dictionary to map unique wellbore identifiers to wellbore headers for faster lookup
wellbore_headers_dict = {
wellbore_header["unique_wellbore_identifier"]: wellbore_header
for wellbore_header in wellbore_headers_results
}

# Iterate over the survey headers and update the information from wellbore headers if available
for survey_header in survey_header_results:
for wellbore_header in wellbore_headers_results:
if survey_header["unique_wellbore_identifier"] == wellbore_header["unique_wellbore_identifier"]:
survey_header["wellbore_purpose"] = wellbore_header.get("wellbore_purpose")
survey_header["wellbore_status"] = wellbore_header.get("wellbore_status")
break
unique_id = survey_header["unique_wellbore_identifier"]

wellbore_header = wellbore_headers_dict.get(unique_id)
if wellbore_header:
survey_header["wellbore_purpose"] = wellbore_header.get("wellbore_purpose")
survey_header["wellbore_status"] = wellbore_header.get("wellbore_status")

return [WellboreHeader(**result) for result in survey_header_results]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
LOGGER = logging.getLogger(__name__)


async def smda_get_request(access_token: str, endpoint: str, params: Optional[dict] = None) -> List[dict]:
async def ssdl_get_request(access_token: str, endpoint: str, params: Optional[dict] = None) -> List[dict]:
"""
Generic GET request to SSDL API.
Uses `next` pagination to get all results.
Expand Down
14 changes: 7 additions & 7 deletions backend_py/primary/primary/services/ssdl_access/well_access.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Service,
InvalidDataError,
)
from ._ssdl_get_request import smda_get_request
from ._ssdl_get_request import ssdl_get_request

from . import types

Expand All @@ -17,7 +17,7 @@ async def get_completions_for_wellbore(self, wellbore_uuid: str) -> List[types.W
endpoint = f"Wellbores/{wellbore_uuid}/completion"
params = {"normalized_data": True}

ssdl_data = await smda_get_request(access_token=self._ssdl_token, endpoint=endpoint, params=params)
ssdl_data = await ssdl_get_request(access_token=self._ssdl_token, endpoint=endpoint, params=params)
try:
result = [types.WellboreCompletion.model_validate(casing) for casing in ssdl_data]
except ValidationError as error:
Expand All @@ -29,7 +29,7 @@ async def get_completions_for_wellbore(self, wellbore_uuid: str) -> List[types.W
async def get_casings_for_wellbore(self, wellbore_uuid: str) -> List[types.WellboreCasing]:
endpoint = f"Wellbores/{wellbore_uuid}/casing"
params = {"source": "dbr"}
ssdl_data = await smda_get_request(access_token=self._ssdl_token, endpoint=endpoint, params=params)
ssdl_data = await ssdl_get_request(access_token=self._ssdl_token, endpoint=endpoint, params=params)
try:
result = [types.WellboreCasing.model_validate(casing) for casing in ssdl_data]
except ValidationError as error:
Expand All @@ -40,7 +40,7 @@ async def get_perforations_for_wellbore(self, wellbore_uuid: str) -> List[types.
endpoint = f"Wellbores/{wellbore_uuid}/perforations"
params = {"normalized-data": False, "details": True}

ssdl_data = await smda_get_request(access_token=self._ssdl_token, endpoint=endpoint, params=params)
ssdl_data = await ssdl_get_request(access_token=self._ssdl_token, endpoint=endpoint, params=params)
try:
result = [types.WellborePerforation.model_validate(casing) for casing in ssdl_data]
except ValidationError as error:
Expand All @@ -49,7 +49,7 @@ async def get_perforations_for_wellbore(self, wellbore_uuid: str) -> List[types.

async def get_log_curve_headers_for_wellbore(self, wellbore_uuid: str) -> List[types.WellboreLogCurveHeader]:
endpoint = f"WellLog/{wellbore_uuid}"
ssdl_data = await smda_get_request(access_token=self._ssdl_token, endpoint=endpoint, params=None)
ssdl_data = await ssdl_get_request(access_token=self._ssdl_token, endpoint=endpoint, params=None)
try:
result = [types.WellboreLogCurveHeader.model_validate(log_curve) for log_curve in ssdl_data]
except ValidationError as error:
Expand All @@ -58,7 +58,7 @@ async def get_log_curve_headers_for_wellbore(self, wellbore_uuid: str) -> List[t

async def get_log_curve_headers_for_field(self, field_uuid: str) -> List[types.WellboreLogCurveHeader]:
endpoint = f"WellLog/field/{field_uuid}"
ssdl_data = await smda_get_request(access_token=self._ssdl_token, endpoint=endpoint, params=None)
ssdl_data = await ssdl_get_request(access_token=self._ssdl_token, endpoint=endpoint, params=None)
try:
result = [types.WellboreLogCurveHeader.model_validate(log_curve) for log_curve in ssdl_data]
except ValidationError as error:
Expand All @@ -68,7 +68,7 @@ async def get_log_curve_headers_for_field(self, field_uuid: str) -> List[types.W
async def get_log_curve_data(self, wellbore_uuid: str, curve_name: str) -> types.WellboreLogCurveData:
params = {"normalized_data": False}
endpoint = f"WellLog/{wellbore_uuid}/{curve_name}"
ssdl_data = await smda_get_request(access_token=self._ssdl_token, endpoint=endpoint, params=params)
ssdl_data = await ssdl_get_request(access_token=self._ssdl_token, endpoint=endpoint, params=params)
try:
result = types.WellboreLogCurveData.model_validate(ssdl_data)
except ValidationError as error:
Expand Down
5 changes: 1 addition & 4 deletions frontend/src/modules/Intersection/view/view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,7 @@ export function View(props: ModuleViewProps<Interfaces>): React.ReactNode {

React.useEffect(
function handleTitleChange() {
let fieldName = "";
if (fieldIdentifier) {
fieldName = fieldIdentifier;
}
const fieldName = fieldIdentifier ?? "";

props.viewContext.setInstanceTitle(
`${wellboreHeader?.identifier ?? "Intersection"}
Expand Down

0 comments on commit a1e2f81

Please sign in to comment.