Skip to content

Commit

Permalink
MAINT: Remove now redundant InternalFMU
Browse files Browse the repository at this point in the history
  • Loading branch information
mferrera committed Jan 9, 2025
1 parent e604248 commit 03a8ad7
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/fmu/dataio/_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def _get_meta_filedata(
).get_metadata()


def _get_meta_fmu(fmudata: FmuProvider) -> schema.InternalFMU | None:
def _get_meta_fmu(fmudata: FmuProvider) -> fields.FMU | None:
try:
return fmudata.get_metadata()
except InvalidMetadataError:
Expand Down
12 changes: 1 addition & 11 deletions src/fmu/dataio/_model/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,6 @@ class JsonSchemaMetadata(BaseModel):
source: str = Field(default=SOURCE, frozen=True)


class Context(BaseModel, use_enum_values=True):
stage: enums.FMUContext


# Remove the two models below when content is required as input.
class InternalUnsetData(data.Data):
content: Literal["unset"] # type: ignore
Expand All @@ -132,12 +128,6 @@ def _deprecation_warning(self) -> InternalUnsetData:
return self


class InternalFMU(fields.FMU):
# This class is identical to the one used in the schema
# except for more fmu context values being allowed internally
context: Context # type: ignore


class InternalObjectMetadata(JsonSchemaMetadata, populate_by_name=True):
# TODO: aim to use root.ObjectMetadata as base
# class and disallow creating invalid metadata.
Expand All @@ -152,7 +142,7 @@ class InternalObjectMetadata(JsonSchemaMetadata, populate_by_name=True):
enums.FMUClass.points,
enums.FMUClass.dictionary,
] = Field(alias="class")
fmu: Optional[InternalFMU]
fmu: Optional[fields.FMU]
masterdata: Optional[fields.Masterdata]
access: Optional[fields.SsdlAccess]
data: Union[InternalUnsetData, data.AnyData] # keep InternalUnsetData first here
Expand Down
10 changes: 5 additions & 5 deletions src/fmu/dataio/providers/_fmu.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ def get_runpath(self) -> Path | None:
"""Return runpath for a FMU run."""
return self._runpath

def get_metadata(self) -> schema.InternalFMU:
def get_metadata(self) -> fields.FMU:
"""Construct the metadata FMU block for an ERT forward job."""
logger.debug("Generate ERT metadata...")

Expand All @@ -178,7 +178,7 @@ def get_metadata(self) -> schema.InternalFMU:
case_meta = self._get_case_meta()

if self.fmu_context != FMUContext.realization:
return schema.InternalFMU(
return fields.FMU(
case=case_meta.fmu.case,
context=self._get_fmucontext_meta(),
model=self.model or case_meta.fmu.model,
Expand All @@ -189,7 +189,7 @@ def get_metadata(self) -> schema.InternalFMU:
iter_uuid, real_uuid = self._get_iteration_and_real_uuid(
case_meta.fmu.case.uuid
)
return schema.InternalFMU(
return fields.FMU(
case=case_meta.fmu.case,
context=self._get_fmucontext_meta(),
model=self.model or case_meta.fmu.model,
Expand Down Expand Up @@ -326,8 +326,8 @@ def _get_iteration_meta(self, iter_uuid: UUID) -> fields.Iteration:
else None,
)

def _get_fmucontext_meta(self) -> schema.Context:
return schema.Context(stage=self.fmu_context)
def _get_fmucontext_meta(self) -> fields.Context:
return fields.Context(stage=self.fmu_context)

def _get_workflow_meta(self) -> fields.Workflow:
assert self.workflow is not None
Expand Down

0 comments on commit 03a8ad7

Please sign in to comment.