From 774a9b2b05df2ec371ab1ecdec7bf5afc9290e57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Therese=20Natter=C3=B8y?= <61694854+tnatt@users.noreply.github.com> Date: Fri, 27 Sep 2024 12:55:21 +0200 Subject: [PATCH] MAINT: Fix pydantic serialization warning --- src/fmu/dataio/_model/schema.py | 6 +----- src/fmu/dataio/providers/objectdata/_base.py | 8 ++++---- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/fmu/dataio/_model/schema.py b/src/fmu/dataio/_model/schema.py index 4fe266e67..e9923b2ba 100644 --- a/src/fmu/dataio/_model/schema.py +++ b/src/fmu/dataio/_model/schema.py @@ -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 @@ -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 diff --git a/src/fmu/dataio/providers/objectdata/_base.py b/src/fmu/dataio/providers/objectdata/_base.py index 697f2bdd2..2c43d4900 100644 --- a/src/fmu/dataio/providers/objectdata/_base.py +++ b/src/fmu/dataio/providers/objectdata/_base.py @@ -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 @@ -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) @@ -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) ) @@ -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