Skip to content

Commit

Permalink
Lint
Browse files Browse the repository at this point in the history
  • Loading branch information
HansKallekleiv committed Aug 22, 2023
1 parent a04baae commit 2939969
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 14 deletions.
Empty file.
2 changes: 1 addition & 1 deletion backend/src/backend/primary/routers/surface/converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,5 @@ def to_api_surface_data(xtgeo_surf: xtgeo.RegularSurface) -> schemas.SurfaceData
val_min=xtgeo_surf.values.min(),
val_max=xtgeo_surf.values.max(),
rot_deg=xtgeo_surf.rotation,
mesh_data=orjson.dumps(float32values),
mesh_data=orjson.dumps(float32values), # pylint: disable=maybe-no-member,
)
3 changes: 2 additions & 1 deletion backend/src/backend/primary/routers/surface/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
from src.services.utils.authenticated_user import AuthenticatedUser
from src.services.utils.perf_timer import PerfTimer
from src.backend.auth.auth_helper import AuthHelper
from src.services.sumo_access.generic_types import SumoContent

from . import converters
from . import schemas
from src.services.sumo_access.generic_types import SumoContent

LOGGER = logging.getLogger(__name__)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
from typing import List
import orjson
import xtgeo

from src.services.utils.surface_to_float32 import surface_to_float32_array
from . import schemas


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@
from fastapi import APIRouter, Depends, HTTPException, Query

from src.services.sumo_access.surface_polygon_access import SurfacePolygonsAccess
from src.services.utils.statistic_function import StatisticFunction
from src.services.utils.authenticated_user import AuthenticatedUser
from src.services.utils.perf_timer import PerfTimer
from src.backend.auth.auth_helper import AuthHelper

from src.services.sumo_access.generic_types import SumoContent

from . import schemas
from . import converters
Expand All @@ -31,7 +29,11 @@ def get_surface_polygons_directory(
access = SurfacePolygonsAccess(authenticated_user.get_sumo_access_token(), case_uuid, ensemble_name)
polygons_dir = access.get_surface_polygons_dir()

return polygons_dir
return schemas.SurfacePolygonDirectory(
names=polygons_dir.names,
attributes=polygons_dir.attributes,
valid_attributes_for_name=polygons_dir.valid_attributes_for_name,
)


@router.get("/surface_polygons_data/")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from enum import Enum
from typing import List

from pydantic import BaseModel
Expand Down
8 changes: 4 additions & 4 deletions backend/src/services/sumo_access/generic_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,11 @@ class SumoContent(str, Enum):
WELLPICKS = "wellpicks"

@classmethod
def values(cls):
def values(cls) -> List[str]:
return [_.value for _ in list(cls)]

@classmethod
def has(cls, value):
def has(cls, value) -> bool:
return value in cls.values()


Expand All @@ -87,9 +87,9 @@ class SumoClass(str, Enum):
POINTS = "points"

@classmethod
def values(cls):
def values(cls) -> List[str]:
return [_.value for _ in list(cls)]

@classmethod
def has(cls, value):
def has(cls, value) -> bool:
return value in cls.values()
5 changes: 3 additions & 2 deletions backend/src/services/sumo_access/surface_polygon_access.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,14 @@ def get_surface_polygons(self, real_num: int, name: str, attribute: str) -> Opti
return None

is_valid = False
byte_stream: BytesIO
if surface_polygons_count > 1:
LOGGER.warning(
f"Multiple ({surface_polygons_count}) polygons set found in Sumo for: {addr_str}. Returning first polygons set."
)
# Some fields has multiple polygons set. There should only be one.
for poly in polygons_collection:
byte_stream: BytesIO = poly.blob
byte_stream = poly.blob
poly_df = pd.read_csv(byte_stream)
if set(["X_UTME", "Y_UTMN", "Z_TVDSS", "POLY_ID"]) == set(poly_df.columns):
is_valid = True
Expand All @@ -124,7 +125,7 @@ def get_surface_polygons(self, real_num: int, name: str, attribute: str) -> Opti
break
else:
sumo_polys = polygons_collection[0]
byte_stream: BytesIO = sumo_polys.blob
byte_stream = sumo_polys.blob
poly_df = pd.read_csv(byte_stream)
if set(["X_UTME", "Y_UTMN", "Z_TVDSS", "POLY_ID"]) == set(poly_df.columns):
is_valid = True
Expand Down

0 comments on commit 2939969

Please sign in to comment.