Skip to content

Commit

Permalink
MAINT: Fix pydantic serialization warning
Browse files Browse the repository at this point in the history
  • Loading branch information
tnatt committed Sep 27, 2024
1 parent 633e1dd commit 774a9b2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
6 changes: 1 addition & 5 deletions src/fmu/dataio/_model/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,6 @@ def _deprecation_warning(self) -> InternalUnsetData:
return self


class InternalAnyData(data.AnyData):
root: InternalUnsetData # type: ignore


class InternalFMU(fields.FMU):
# This class is identical to the one used in the schema
# exept for more fmu context values beeing allowed internally
Expand All @@ -156,7 +152,7 @@ class InternalObjectMetadata(JsonSchemaMetadata):
fmu: Optional[InternalFMU]
masterdata: Optional[fields.Masterdata]
access: Optional[fields.SsdlAccess]
data: Union[data.AnyData, InternalAnyData]
data: Union[InternalUnsetData, data.AnyData] # keep InternalUnsetData first here
file: fields.File
display: fields.Display
tracklog: fields.Tracklog
Expand Down
8 changes: 4 additions & 4 deletions src/fmu/dataio/providers/objectdata/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
GlobalConfiguration,
StratigraphyElement,
)
from fmu.dataio._model.schema import AllowedContent, InternalAnyData
from fmu.dataio._model.schema import AllowedContent, InternalUnsetData
from fmu.dataio._utils import generate_description
from fmu.dataio.providers._base import Provider

Expand Down Expand Up @@ -56,7 +56,7 @@ class ObjectDataProvider(Provider):
# result properties; the most important is metadata which IS the 'data' part in
# the resulting metadata. But other variables needed later are also given
# as instance properties in addition (for simplicity in other classes/functions)
_metadata: AnyData | InternalAnyData | None = field(default=None)
_metadata: AnyData | InternalUnsetData | None = field(default=None)
name: str = field(default="")
time0: datetime | None = field(default=None)
time1: datetime | None = field(default=None)
Expand Down Expand Up @@ -109,7 +109,7 @@ def __post_init__(self) -> None:
metadata["description"] = generate_description(self.dataio.description)

self._metadata = (
InternalAnyData.model_validate(metadata)
InternalUnsetData.model_validate(metadata)
if metadata["content"] == "unset"
else AnyData.model_validate(metadata)
)
Expand Down Expand Up @@ -157,7 +157,7 @@ def get_bbox(self) -> BoundingBox2D | BoundingBox3D | None:
def get_spec(self) -> AnySpecification | None:
raise NotImplementedError

def get_metadata(self) -> AnyData | InternalAnyData:
def get_metadata(self) -> AnyData | InternalUnsetData:
assert self._metadata is not None
return self._metadata

Expand Down

0 comments on commit 774a9b2

Please sign in to comment.