Skip to content

Commit

Permalink
fix: update pydantic configuration for models
Browse files Browse the repository at this point in the history
  • Loading branch information
raylim committed Nov 15, 2023
1 parent afc13cc commit 965dd6c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
9 changes: 4 additions & 5 deletions src/luna/common/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import pandera as pa
from pandera.engines.pandas_engine import PydanticModel
from pandera.typing import Series
from pydantic import BaseModel
from pydantic import BaseModel, ConfigDict


class Slide(BaseModel):
Expand All @@ -19,9 +19,9 @@ class Slide(BaseModel):
channel1_R: Optional[float] = None
channel1_G: Optional[float] = None
channel1_B: Optional[float] = None
properties: Optional[dict] = None

class Config:
extra = "allow"
model_config = ConfigDict(extra="allow")


class ShapeFeaturesSchema(pa.DataFrameModel):
Expand All @@ -47,8 +47,7 @@ class Tile(BaseModel):
tile_size: int
tile_units: str

class Config:
extra = "allow"
model_config = ConfigDict(extra="allow")


class StoredTile(Tile):
Expand Down
4 changes: 2 additions & 2 deletions src/luna/pathology/cli/slide_etl.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from tiffslide import TiffSlide

from luna.common.dask import configure_dask_client, get_or_create_dask_client
from luna.common.models import Slide
from luna.common.models import Slide, SlideSchema
from luna.common.utils import apply_csv_filter, get_config, timed
from luna.pathology.common.utils import (
get_downscaled_thumbnail,
Expand Down Expand Up @@ -249,7 +249,7 @@ def __slide_etl(
output_urlpath,
)

return pd.json_normalize(slide.__dict__)
return DataFrame[SlideSchema](pd.json_normalize(slide.__dict__))


def fire_cli():
Expand Down

0 comments on commit 965dd6c

Please sign in to comment.