Skip to content

Commit

Permalink
linting issues and bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
rubenthoms committed Jun 12, 2024
1 parent bed4615 commit ac669a6
Show file tree
Hide file tree
Showing 53 changed files with 619 additions and 608 deletions.
6 changes: 4 additions & 2 deletions backend_py/primary/primary/routers/dev/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ async def ri_surf(
grid_service = await UserGrid3dService.create_async(authenticated_user, case_uuid)
await grid_service.get_grid_geometry_async(ensemble_name, realization, grid_name, ijk_index_filter)
await grid_service.get_mapped_grid_properties_async(
ensemble_name, realization, grid_name, property_name, ijk_index_filter
ensemble_name, realization, grid_name, property_name, None, ijk_index_filter
)

return "OK"
Expand Down Expand Up @@ -227,6 +227,8 @@ async def ri_isect(
# fmt:on

grid_service = await UserGrid3dService.create_async(authenticated_user, case_uuid)
await grid_service.get_polyline_intersection_async(ensemble_name, realization, grid_name, property_name, xy_arr)
await grid_service.get_polyline_intersection_async(
ensemble_name, realization, grid_name, property_name, None, xy_arr
)

return "OK"
181 changes: 139 additions & 42 deletions backend_py/primary/primary/routers/well/converters.py
Original file line number Diff line number Diff line change
@@ -1,46 +1,143 @@
from typing import List

from primary.services.smda_access.types import WellborePick, StratigraphicUnit
from primary.services.smda_access.types import WellboreHeader, WellboreTrajectory, WellborePick, StratigraphicUnit
from primary.services.ssdl_access.types import (
WellboreCasing,
WellboreCompletion,
WellboreLogCurveHeader,
WellborePerforation,
WellboreLogCurveData,
)

from . import schemas


def convert_wellbore_picks_to_schema(wellbore_picks: List[WellborePick]) -> List[schemas.WellborePick]:
return [
schemas.WellborePick(
northing=pick.northing,
easting=pick.easting,
tvd=pick.tvd,
tvdMsl=pick.tvd_msl,
md=pick.md,
mdMsl=pick.md_msl,
uniqueWellboreIdentifier=pick.unique_wellbore_identifier,
pickIdentifier=pick.pick_identifier,
confidence=pick.confidence,
depthReferencePoint=pick.depth_reference_point,
mdUnit=pick.md_unit,
)
for pick in wellbore_picks
]


def convert_stratigraphic_units_to_schema(
stratigraphic_units: List[StratigraphicUnit],
) -> List[schemas.StratigraphicUnit]:
return [
schemas.StratigraphicUnit(
identifier=unit.identifier,
top=unit.top,
base=unit.base,
stratUnitLevel=unit.strat_unit_level,
stratUnitType=unit.strat_unit_type,
topAge=unit.top_age,
baseAge=unit.base_age,
stratUnitParent=unit.strat_unit_parent,
colorR=unit.color_r,
colorG=unit.color_g,
colorB=unit.color_b,
lithologyType=unit.lithology_type,
)
for unit in stratigraphic_units
]
def convert_wellbore_pick_to_schema(wellbore_pick: WellborePick) -> schemas.WellborePick:
return schemas.WellborePick(
northing=wellbore_pick.northing,
easting=wellbore_pick.easting,
tvd=wellbore_pick.tvd,
tvdMsl=wellbore_pick.tvd_msl,
md=wellbore_pick.md,
mdMsl=wellbore_pick.md_msl,
uniqueWellboreIdentifier=wellbore_pick.unique_wellbore_identifier,
pickIdentifier=wellbore_pick.pick_identifier,
confidence=wellbore_pick.confidence,
depthReferencePoint=wellbore_pick.depth_reference_point,
mdUnit=wellbore_pick.md_unit,
)


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:
return schemas.WellboreHeader(
wellboreUuid=drilled_wellbore_header.wellbore_uuid,
uniqueWellboreIdentifier=drilled_wellbore_header.unique_wellbore_identifier,
wellUuid=drilled_wellbore_header.well_uuid,
uniqueWellIdentifier=drilled_wellbore_header.unique_well_identifier,
wellEasting=drilled_wellbore_header.well_easting,
wellNorthing=drilled_wellbore_header.well_northing,
depthReferencePoint=drilled_wellbore_header.depth_reference_point,
depthReferenceElevation=drilled_wellbore_header.depth_reference_elevation,
)


def convert_well_trajectory_to_schema(
well_trajectory: WellboreTrajectory,
) -> schemas.WellboreTrajectory:
return schemas.WellboreTrajectory(
wellboreUuid=well_trajectory.wellbore_uuid,
uniqueWellboreIdentifier=well_trajectory.unique_wellbore_identifier,
tvdMslArr=well_trajectory.tvd_msl_arr,
mdArr=well_trajectory.md_arr,
eastingArr=well_trajectory.easting_arr,
northingArr=well_trajectory.northing_arr,
)


def convert_wellbore_completion_to_schema(
wellbore_completion: WellboreCompletion,
) -> schemas.WellboreCompletion:
return schemas.WellboreCompletion(
mdTop=wellbore_completion.md_top,
mdBottom=wellbore_completion.md_bottom,
tvdTop=wellbore_completion.tvd_top,
tvdBottom=wellbore_completion.tvd_bottom,
description=wellbore_completion.description,
symbolName=wellbore_completion.symbol_name,
comment=wellbore_completion.comment,
)


def convert_wellbore_casing_to_schema(
wellbore_casing: WellboreCasing,
) -> schemas.WellboreCasing:
return schemas.WellboreCasing(
itemType=wellbore_casing.item_type,
diameterNumeric=wellbore_casing.diameter_numeric,
diameterInner=wellbore_casing.diameter_inner,
description=wellbore_casing.description,
remark=wellbore_casing.remark,
depthTopMd=wellbore_casing.depth_top_md,
depthBottomMd=wellbore_casing.depth_bottom_md,
totalDepthMd=wellbore_casing.total_depth_md,
startDepth=wellbore_casing.start_depth,
endDepth=wellbore_casing.end_depth,
)


def convert_wellbore_perforation_to_schema(
wellbore_perforation: WellborePerforation,
) -> schemas.WellborePerforation:
return schemas.WellborePerforation(
mdTop=wellbore_perforation.md_top,
mdBottom=wellbore_perforation.md_bottom,
tvdTop=wellbore_perforation.tvd_top,
tvdBottom=wellbore_perforation.tvd_bottom,
status=wellbore_perforation.status,
completionMode=wellbore_perforation.completion_mode,
)


def convert_wellbore_log_curve_header_to_schema(
wellbore_log_curve_header: WellboreLogCurveHeader,
) -> schemas.WellboreLogCurveHeader:
return schemas.WellboreLogCurveHeader(
logName=wellbore_log_curve_header.log_name,
curveName=wellbore_log_curve_header.curve_name,
curveUnit=wellbore_log_curve_header.curve_unit,
)


def convert_wellbore_log_curve_data_to_schema(
wellbore_log_curve_data: WellboreLogCurveData,
) -> schemas.WellboreLogCurveData:
return schemas.WellboreLogCurveData(
indexMin=wellbore_log_curve_data.index_min,
indexMax=wellbore_log_curve_data.index_max,
minCurveValue=wellbore_log_curve_data.min_curve_value,
maxCurveValue=wellbore_log_curve_data.max_curve_value,
dataPoints=wellbore_log_curve_data.DataPoints,
curveAlias=wellbore_log_curve_data.curve_alias,
curveDescription=wellbore_log_curve_data.curve_description,
indexUnit=wellbore_log_curve_data.index_unit,
noDataValue=wellbore_log_curve_data.no_data_value,
)
58 changes: 35 additions & 23 deletions backend_py/primary/primary/routers/well/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,7 @@ async def get_drilled_wellbore_headers(

wellbore_headers = await well_access.get_wellbore_headers(field_identifier=field_identifier)

ret_arr = [schemas.WellboreHeader(**wellbore_header) for wellbore_header in wellbore_headers]

return ret_arr
return [converters.convert_wellbore_header_to_schema(wellbore_header) for wellbore_header in wellbore_headers]


@router.get("/field_well_trajectories/")
Expand All @@ -71,9 +69,10 @@ async def get_field_well_trajectories(
field_identifier=field_identifier, unique_wellbore_identifiers=unique_wellbore_identifiers
)

ret_arr = [schemas.WellboreTrajectory(**wellbore_trajectory) for wellbore_trajectory in wellbore_trajectories]

return ret_arr
return [
converters.convert_well_trajectory_to_schema(wellbore_trajectory)
for wellbore_trajectory in wellbore_trajectories
]


@router.get("/well_trajectories/")
Expand All @@ -94,9 +93,10 @@ async def get_well_trajectories(

wellbore_trajectories = await well_access.get_wellbore_trajectories(wellbore_uuids=wellbore_uuids)

ret_arr = [schemas.WellboreTrajectory(**wellbore_trajectory) for wellbore_trajectory in wellbore_trajectories]

return ret_arr
return [
converters.convert_well_trajectory_to_schema(wellbore_trajectory)
for wellbore_trajectory in wellbore_trajectories
]


@router.get("/wellbore_picks_and_stratigraphic_units/")
Expand Down Expand Up @@ -128,8 +128,11 @@ async def get_wellbore_picks_and_stratigraphic_units(
wellbore_picks = await well_access.get_all_picks_for_wellbore(wellbore_uuid=wellbore_uuid)

return schemas.WellborePicksAndStratigraphicUnits(
wellbore_picks=converters.convert_wellbore_picks_to_schema(wellbore_picks),
stratigraphic_units=converters.convert_stratigraphic_units_to_schema(stratigraphic_units),
wellbore_picks=[converters.convert_wellbore_pick_to_schema(wellbore_pick) for wellbore_pick in wellbore_picks],
stratigraphic_units=[
converters.convert_stratigraphic_unit_to_schema(stratigraphic_unit)
for stratigraphic_unit in stratigraphic_units
],
)


Expand All @@ -149,27 +152,30 @@ async def get_wellbore_completions(
well_access = SsdlWellAccess(authenticated_user.get_ssdl_access_token())

wellbore_completions = await well_access.get_completions_for_wellbore(wellbore_uuid=wellbore_uuid)
return wellbore_completions
return [
converters.convert_wellbore_completion_to_schema(wellbore_completion)
for wellbore_completion in wellbore_completions
]


@router.get("/wellbore_casing/")
async def get_wellbore_casing(
@router.get("/wellbore_casings/")
async def get_wellbore_casings(
# fmt:off
authenticated_user: AuthenticatedUser = Depends(AuthHelper.get_authenticated_user),
wellbore_uuid: str = Query(description="Wellbore uuid"),
# fmt:on
) -> List[schemas.WellboreCasing]:
"""Get well bore casing for a single well bore"""
"""Get well bore casings for a single well bore"""

# Handle DROGON
if wellbore_uuid in ["drogon_horizontal", "drogon_vertical"]:
return []

well_access = SsdlWellAccess(authenticated_user.get_ssdl_access_token())

wellbore_casing = await well_access.get_casing_for_wellbore(wellbore_uuid=wellbore_uuid)
wellbore_casings = await well_access.get_casings_for_wellbore(wellbore_uuid=wellbore_uuid)

return wellbore_casing
return [converters.convert_wellbore_casing_to_schema(wellbore_casing) for wellbore_casing in wellbore_casings]


@router.get("/wellbore_perforations/")
Expand All @@ -189,7 +195,10 @@ async def get_wellbore_perforations(

wellbore_perforations = await well_access.get_perforations_for_wellbore(wellbore_uuid=wellbore_uuid)

return wellbore_perforations
return [
converters.convert_wellbore_perforation_to_schema(wellbore_perforation)
for wellbore_perforation in wellbore_perforations
]


@router.get("/wellbore_log_curve_headers/")
Expand All @@ -198,7 +207,7 @@ async def get_wellbore_log_curve_headers(
authenticated_user: AuthenticatedUser = Depends(AuthHelper.get_authenticated_user),
wellbore_uuid: str = Query(description="Wellbore uuid"),
# fmt:on
) -> List[schemas.WellboreLogCurveInfo]:
) -> List[schemas.WellboreLogCurveHeader]:
"""Get all log curve headers for a single well bore"""

# Handle DROGON
Expand All @@ -207,9 +216,12 @@ async def get_wellbore_log_curve_headers(

well_access = SsdlWellAccess(authenticated_user.get_ssdl_access_token())

wellbore_casing = await well_access.get_log_curve_headers_for_wellbore(wellbore_uuid=wellbore_uuid)
wellbore_log_curve_headers = await well_access.get_log_curve_headers_for_wellbore(wellbore_uuid=wellbore_uuid)

return wellbore_casing
return [
converters.convert_wellbore_log_curve_header_to_schema(wellbore_log_curve_header)
for wellbore_log_curve_header in wellbore_log_curve_headers
]


@router.get("/log_curve_data/")
Expand All @@ -224,10 +236,10 @@ async def get_log_curve_data(

# Handle DROGON
if wellbore_uuid in ["drogon_horizontal", "drogon_vertical"]:
return []
raise NotImplementedError("DROGON log curve data not implemented")

well_access = SsdlWellAccess(authenticated_user.get_ssdl_access_token())

log_curve = await well_access.get_log_curve_data(wellbore_uuid=wellbore_uuid, curve_name=log_curve_name)

return log_curve
return converters.convert_wellbore_log_curve_data_to_schema(log_curve)
Loading

0 comments on commit ac669a6

Please sign in to comment.