Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MAINT: Fix pydantic serialization warning #824

Merged
merged 1 commit into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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