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: Restructure models and schemas #963

Merged
merged 1 commit into from
Jan 13, 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 docs/src/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def filter(self, record: logging.LogRecord) -> bool:
apidoc_output_dir = "apiref"
apidoc_excluded_paths = [
"case",
"datastructure",
"_models",
"hook_implementations",
"providers",
"scripts",
Expand Down
4 changes: 2 additions & 2 deletions docs/src/datamodel/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ documentation of these two models can be inspected from here.
.. toctree::
:maxdepth: -1

~fmu.dataio._model.root.ObjectMetadata
~fmu.dataio._model.root.CaseMetadata
~fmu.dataio._models.fmu_results.fmu_results.ObjectMetadata
~fmu.dataio._models.fmu_results.fmu_results.CaseMetadata


About the data model
Expand Down
5 changes: 3 additions & 2 deletions docs/src/rms_oneliners.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ a few lines will be needed.
Currently only volumes are exposed, but this will be extended in the near future.

.. note::
All simplified export functions requires that the global configuration file is found at the standard
location in FMU. For RMS exports that will be ``'../../fmuconfig/output/global_variables.yml'``.

All simplified export functions requires that the global configuration file is found at the standard
location in FMU. For RMS exports that will be ``'../../fmuconfig/output/global_variables.yml'``.

.. _example-export-volumes-rms:

Expand Down
2 changes: 1 addition & 1 deletion schemas/0.8.0/fmu_results.json
Original file line number Diff line number Diff line change
Expand Up @@ -10885,5 +10885,5 @@
}
}
},
"title": "Root"
"title": "FmuResults"
}
14 changes: 9 additions & 5 deletions src/fmu/dataio/_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,15 @@
)

from ._logging import null_logger
from ._model import data, fields
from ._model.enums import FMUClass
from ._model.global_configuration import GlobalConfiguration
from ._model.product import Product
from ._model.root import CaseMetadata, FmuResultsSchema, ObjectMetadata
from ._models.fmu_results import data, fields
from ._models.fmu_results.enums import FMUClass
from ._models.fmu_results.fmu_results import (
CaseMetadata,
FmuResultsSchema,
ObjectMetadata,
)
from ._models.fmu_results.global_configuration import GlobalConfiguration
from ._models.fmu_results.product import Product
from .exceptions import InvalidMetadataError
from .providers._filedata import FileDataProvider
from .providers.objectdata._base import UnsetData
Expand Down
6 changes: 0 additions & 6 deletions src/fmu/dataio/_model/__init__.py

This file was deleted.

11 changes: 11 additions & 0 deletions src/fmu/dataio/_models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from .fmu_results import FmuResults, FmuResultsSchema
from .products import InplaceVolumesResult, InplaceVolumesSchema

__all__ = [
"FmuResults",
"FmuResultsSchema",
"InplaceVolumesResult",
"InplaceVolumesSchema",
]

schemas = [FmuResultsSchema, InplaceVolumesSchema]
6 changes: 6 additions & 0 deletions src/fmu/dataio/_models/fmu_results/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from .fmu_results import FmuResults, FmuResultsSchema

__all__ = [
"FmuResultsSchema",
"FmuResults",
]
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def generate(

@staticmethod
def dump() -> dict[str, Any]:
return Root.model_json_schema(
return FmuResults.model_json_schema(
schema_generator=FmuResultsSchema.FmuResultsGenerateJsonSchema
)

Expand Down Expand Up @@ -252,7 +252,7 @@ class ObjectMetadata(MetadataBase):
should/could be displayed. See :class:`Display`."""


class Root(
class FmuResults(
RootModel[
Annotated[
Union[
Expand All @@ -266,7 +266,7 @@ class Root(
]
):
@model_validator(mode="after")
def _check_class_data_spec(self) -> Root:
def _check_class_data_spec(self) -> FmuResults:
if (
self.root.class_ in (FMUClass.table, FMUClass.surface)
and hasattr(self.root, "data")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
)
from typing_extensions import Annotated

from fmu.dataio._products import InplaceVolumesSchema
from fmu.dataio._models.products import InplaceVolumesSchema

from . import enums

Expand Down
6 changes: 6 additions & 0 deletions src/fmu/dataio/_models/products/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from .inplace_volumes import InplaceVolumesResult, InplaceVolumesSchema

__all__ = [
"InplaceVolumesResult",
"InplaceVolumesSchema",
]
5 changes: 0 additions & 5 deletions src/fmu/dataio/_products/__init__.py

This file was deleted.

4 changes: 2 additions & 2 deletions src/fmu/dataio/aggregation.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@

from pydantic import ValidationError

from fmu.dataio._model import fields
from fmu.dataio._models.fmu_results import fields
from fmu.dataio._models.fmu_results.enums import FMUContext

from . import _utils, dataio, types
from ._logging import null_logger
from ._metadata import ObjectMetadataExport
from ._model.enums import FMUContext
from .exceptions import InvalidMetadataError
from .providers.objectdata._provider import objectdata_provider_factory

Expand Down
14 changes: 6 additions & 8 deletions src/fmu/dataio/case.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,11 @@

from pydantic import ValidationError

from fmu.dataio._model import fields
from fmu.dataio._models.fmu_results import fields, global_configuration

from . import _utils
from ._logging import null_logger
from ._metadata import CaseMetadataExport
from ._model import global_configuration
from ._model.fields import Access, Case, Masterdata, Model, User

logger: Final = null_logger(__name__)

Expand Down Expand Up @@ -117,16 +115,16 @@ def generate_metadata(self) -> dict:
return {}

self._metadata = CaseMetadataExport(
masterdata=Masterdata.model_validate(self.config["masterdata"]),
access=Access.model_validate(self.config["access"]),
masterdata=fields.Masterdata.model_validate(self.config["masterdata"]),
access=fields.Access.model_validate(self.config["access"]),
fmu=fields.FMUBase(
model=Model.model_validate(
model=fields.Model.model_validate(
self.config["model"],
),
case=Case(
case=fields.Case(
name=self.casename,
uuid=self._case_uuid(),
user=User(id=self.caseuser),
user=fields.User(id=self.caseuser),
description=None,
),
),
Expand Down
6 changes: 3 additions & 3 deletions src/fmu/dataio/dataio.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
from ._definitions import ValidationError
from ._logging import null_logger
from ._metadata import generate_export_metadata
from ._model import enums, global_configuration
from ._model.global_configuration import GlobalConfiguration
from ._model.product import Product
from ._models.fmu_results import enums, global_configuration
from ._models.fmu_results.global_configuration import GlobalConfiguration
from ._models.fmu_results.product import Product
from ._utils import (
detect_inside_rms, # dataio_examples,
export_file,
Expand Down
6 changes: 3 additions & 3 deletions src/fmu/dataio/export/rms/inplace_volumes.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@

import fmu.dataio as dio
from fmu.dataio._logging import null_logger
from fmu.dataio._model import product
from fmu.dataio._model.enums import Classification, ProductName
from fmu.dataio._products.inplace_volumes import InplaceVolumesResult
from fmu.dataio._models import InplaceVolumesResult
from fmu.dataio._models.fmu_results import product
from fmu.dataio._models.fmu_results.enums import Classification, ProductName
from fmu.dataio.export import _enums
from fmu.dataio.export._decorators import experimental
from fmu.dataio.export._export_result import ExportResult, ExportResultItem
Expand Down
6 changes: 3 additions & 3 deletions src/fmu/dataio/preprocessed.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@

from ._logging import null_logger
from ._metadata import ObjectMetadataExport
from ._model import enums
from ._model.enums import FMUContext
from ._model.fields import File
from ._models.fmu_results import enums
from ._models.fmu_results.enums import FMUContext
from ._models.fmu_results.fields import File
from ._utils import export_metadata_file, md5sum
from .exceptions import InvalidMetadataError
from .providers._filedata import ShareFolder
Expand Down
2 changes: 1 addition & 1 deletion src/fmu/dataio/providers/_filedata.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from typing import TYPE_CHECKING, Final

from fmu.dataio._logging import null_logger
from fmu.dataio._model import enums, fields
from fmu.dataio._models.fmu_results import enums, fields
from fmu.dataio._utils import compute_md5, compute_md5_using_temp_file

from ._base import Provider
Expand Down
4 changes: 2 additions & 2 deletions src/fmu/dataio/providers/_fmu.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
from fmu.dataio import _utils
from fmu.dataio._logging import null_logger
from fmu.dataio._metadata import CaseMetadataExport
from fmu.dataio._model import fields
from fmu.dataio._model.enums import ErtSimulationMode, FMUContext
from fmu.dataio._models.fmu_results import fields
from fmu.dataio._models.fmu_results.enums import ErtSimulationMode, FMUContext
from fmu.dataio.exceptions import InvalidMetadataError

from ._base import Provider
Expand Down
12 changes: 6 additions & 6 deletions src/fmu/dataio/providers/objectdata/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@

from fmu.dataio._definitions import ConfigurationError, ValidFormats
from fmu.dataio._logging import null_logger
from fmu.dataio._model.data import AnyData, Time, Timestamp
from fmu.dataio._model.enums import Content
from fmu.dataio._model.global_configuration import (
from fmu.dataio._models.fmu_results.data import AnyData, Time, Timestamp
from fmu.dataio._models.fmu_results.enums import Content
from fmu.dataio._models.fmu_results.global_configuration import (
GlobalConfiguration,
StratigraphyElement,
)
from fmu.dataio._model.product import Product
from fmu.dataio._models.fmu_results.product import Product
from fmu.dataio._utils import generate_description
from fmu.dataio.providers._base import Provider
from fmu.dataio.providers.objectdata._export_models import AllowedContent, UnsetData
Expand All @@ -25,8 +25,8 @@
BoundingBox3D,
Geometry,
)
from fmu.dataio._model.enums import FMUClass, Layout
from fmu.dataio._model.specification import AnySpecification
from fmu.dataio._models._fmu_results.enums import FMUClass, Layout
from fmu.dataio._models._fmu_results.specification import AnySpecification
from fmu.dataio.dataio import ExportData
from fmu.dataio.types import Inferrable

Expand Down
2 changes: 1 addition & 1 deletion src/fmu/dataio/providers/objectdata/_export_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
)

from fmu.dataio._logging import null_logger
from fmu.dataio._model import data, enums
from fmu.dataio._models.fmu_results import data, enums

logger: Final = null_logger(__name__)

Expand Down
8 changes: 4 additions & 4 deletions src/fmu/dataio/providers/objectdata/_faultroom.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@

from fmu.dataio._definitions import ExportFolder, ValidFormats
from fmu.dataio._logging import null_logger
from fmu.dataio._model.data import BoundingBox3D
from fmu.dataio._model.enums import FMUClass, Layout
from fmu.dataio._model.global_configuration import (
from fmu.dataio._models.fmu_results.data import BoundingBox3D
from fmu.dataio._models.fmu_results.enums import FMUClass, Layout
from fmu.dataio._models.fmu_results.global_configuration import (
GlobalConfiguration,
)
from fmu.dataio._model.specification import FaultRoomSurfaceSpecification
from fmu.dataio._models.fmu_results.specification import FaultRoomSurfaceSpecification
from fmu.dataio.providers.objectdata._utils import Utils

from ._base import (
Expand Down
4 changes: 2 additions & 2 deletions src/fmu/dataio/providers/objectdata/_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@

from fmu.dataio._definitions import ExportFolder, ValidFormats
from fmu.dataio._logging import null_logger
from fmu.dataio._model.enums import FMUClass, Layout
from fmu.dataio._model.product import Product
from fmu.dataio._models.fmu_results.enums import FMUClass, Layout
from fmu.dataio._models.fmu_results.product import Product
from fmu.dataio.readers import FaultRoomSurface

from ._base import (
Expand Down
4 changes: 2 additions & 2 deletions src/fmu/dataio/providers/objectdata/_tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
ValidFormats,
)
from fmu.dataio._logging import null_logger
from fmu.dataio._model.enums import FMUClass, Layout
from fmu.dataio._model.specification import TableSpecification
from fmu.dataio._models.fmu_results.enums import FMUClass, Layout
from fmu.dataio._models.fmu_results.specification import TableSpecification

from ._base import (
ObjectDataProvider,
Expand Down
2 changes: 1 addition & 1 deletion src/fmu/dataio/providers/objectdata/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import warnings

from fmu.dataio._model.global_configuration import Stratigraphy
from fmu.dataio._models.fmu_results.global_configuration import Stratigraphy


class Utils:
Expand Down
6 changes: 3 additions & 3 deletions src/fmu/dataio/providers/objectdata/_xtgeo.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@

from fmu.dataio._definitions import ExportFolder, ValidFormats
from fmu.dataio._logging import null_logger
from fmu.dataio._model.data import BoundingBox2D, BoundingBox3D, Geometry
from fmu.dataio._model.enums import FMUClass, Layout
from fmu.dataio._model.specification import (
from fmu.dataio._models.fmu_results.data import BoundingBox2D, BoundingBox3D, Geometry
from fmu.dataio._models.fmu_results.enums import FMUClass, Layout
from fmu.dataio._models.fmu_results.specification import (
CPGridPropertySpecification,
CPGridSpecification,
CubeSpecification,
Expand Down
6 changes: 3 additions & 3 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import fmu.dataio as dio
from fmu.config import utilities as ut
from fmu.dataio._model import Root, fields, global_configuration
from fmu.dataio._models.fmu_results import FmuResults, fields, global_configuration
from fmu.dataio.dataio import ExportData, read_metadata
from fmu.dataio.providers._fmu import FmuEnv
from fmu.dataio.readers import FaultRoomSurface
Expand Down Expand Up @@ -750,5 +750,5 @@ def fixture_drogon_volumes(rootpath):

@pytest.fixture(scope="session")
def pydantic_models_from_root():
"""Return all nested pydantic models from Root and downwards"""
return _get_nested_pydantic_models(Root)
"""Return all nested pydantic models from FmuResults and downwards"""
return _get_nested_pydantic_models(FmuResults)
4 changes: 2 additions & 2 deletions tests/test_export_rms/test_export_rms_volumetrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@

from fmu import dataio
from fmu.dataio._logging import null_logger
from fmu.dataio._model.enums import ProductName
from fmu.dataio._products.inplace_volumes import (
from fmu.dataio._models.fmu_results.enums import ProductName
from fmu.dataio._models.products.inplace_volumes import (
InplaceVolumesResult,
InplaceVolumesResultRow,
InplaceVolumesSchema,
Expand Down
6 changes: 3 additions & 3 deletions tests/test_integration/test_simple_export_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
import pytest
import yaml

from fmu.dataio._model import Root
from fmu.dataio._model.enums import ErtSimulationMode
from fmu.dataio._models import FmuResults
from fmu.dataio._models.fmu_results.enums import ErtSimulationMode

from .ert_config_utils import (
add_create_case_workflow,
Expand Down Expand Up @@ -57,6 +57,6 @@ def test_simple_export_ert_environment_variables(snakeoil_export_surface: Path)
with open(avg_poro_yml, encoding="utf-8") as f:
avg_poro_metadata = yaml.safe_load(f)

avg_poro = Root.model_validate(avg_poro_metadata) # asserts valid
avg_poro = FmuResults.model_validate(avg_poro_metadata) # asserts valid
assert avg_poro.root.fmu.ert.simulation_mode == ErtSimulationMode.test_run
assert avg_poro.root.fmu.ert.experiment.id is not None
Loading
Loading