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: Remove now redundant InternalFMU #961

Merged
merged 1 commit into from
Jan 9, 2025
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
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
Loading