diff --git a/docs/src/conf.py b/docs/src/conf.py index 2ff1446f5..33e942f17 100755 --- a/docs/src/conf.py +++ b/docs/src/conf.py @@ -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", diff --git a/docs/src/datamodel/index.rst b/docs/src/datamodel/index.rst index 9dd4cec1f..c4894896c 100644 --- a/docs/src/datamodel/index.rst +++ b/docs/src/datamodel/index.rst @@ -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 diff --git a/docs/src/rms_oneliners.rst b/docs/src/rms_oneliners.rst index 060b2ba6f..3dd98813c 100644 --- a/docs/src/rms_oneliners.rst +++ b/docs/src/rms_oneliners.rst @@ -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: diff --git a/schemas/0.8.0/fmu_results.json b/schemas/0.8.0/fmu_results.json index e942a23b9..951a8e2c3 100644 --- a/schemas/0.8.0/fmu_results.json +++ b/schemas/0.8.0/fmu_results.json @@ -10885,5 +10885,5 @@ } } }, - "title": "Root" + "title": "FmuResults" } \ No newline at end of file diff --git a/src/fmu/dataio/_metadata.py b/src/fmu/dataio/_metadata.py index 75212463b..58d01b858 100644 --- a/src/fmu/dataio/_metadata.py +++ b/src/fmu/dataio/_metadata.py @@ -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 diff --git a/src/fmu/dataio/_model/__init__.py b/src/fmu/dataio/_model/__init__.py deleted file mode 100644 index 8f5832dd9..000000000 --- a/src/fmu/dataio/_model/__init__.py +++ /dev/null @@ -1,6 +0,0 @@ -from .root import FmuResultsSchema, Root - -__all__ = [ - "FmuResultsSchema", - "Root", -] diff --git a/src/fmu/dataio/_models/__init__.py b/src/fmu/dataio/_models/__init__.py new file mode 100644 index 000000000..43cab2d04 --- /dev/null +++ b/src/fmu/dataio/_models/__init__.py @@ -0,0 +1,11 @@ +from .fmu_results import FmuResults, FmuResultsSchema +from .products import InplaceVolumesResult, InplaceVolumesSchema + +__all__ = [ + "FmuResults", + "FmuResultsSchema", + "InplaceVolumesResult", + "InplaceVolumesSchema", +] + +schemas = [FmuResultsSchema, InplaceVolumesSchema] diff --git a/src/fmu/dataio/_models/fmu_results/__init__.py b/src/fmu/dataio/_models/fmu_results/__init__.py new file mode 100644 index 000000000..aa639076e --- /dev/null +++ b/src/fmu/dataio/_models/fmu_results/__init__.py @@ -0,0 +1,6 @@ +from .fmu_results import FmuResults, FmuResultsSchema + +__all__ = [ + "FmuResultsSchema", + "FmuResults", +] diff --git a/src/fmu/dataio/_model/data.py b/src/fmu/dataio/_models/fmu_results/data.py similarity index 100% rename from src/fmu/dataio/_model/data.py rename to src/fmu/dataio/_models/fmu_results/data.py diff --git a/src/fmu/dataio/_model/enums.py b/src/fmu/dataio/_models/fmu_results/enums.py similarity index 100% rename from src/fmu/dataio/_model/enums.py rename to src/fmu/dataio/_models/fmu_results/enums.py diff --git a/src/fmu/dataio/_model/fields.py b/src/fmu/dataio/_models/fmu_results/fields.py similarity index 100% rename from src/fmu/dataio/_model/fields.py rename to src/fmu/dataio/_models/fmu_results/fields.py diff --git a/src/fmu/dataio/_model/root.py b/src/fmu/dataio/_models/fmu_results/fmu_results.py similarity index 98% rename from src/fmu/dataio/_model/root.py rename to src/fmu/dataio/_models/fmu_results/fmu_results.py index 198a7fa90..a28c51b02 100644 --- a/src/fmu/dataio/_model/root.py +++ b/src/fmu/dataio/_models/fmu_results/fmu_results.py @@ -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 ) @@ -252,7 +252,7 @@ class ObjectMetadata(MetadataBase): should/could be displayed. See :class:`Display`.""" -class Root( +class FmuResults( RootModel[ Annotated[ Union[ @@ -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") diff --git a/src/fmu/dataio/_model/global_configuration.py b/src/fmu/dataio/_models/fmu_results/global_configuration.py similarity index 100% rename from src/fmu/dataio/_model/global_configuration.py rename to src/fmu/dataio/_models/fmu_results/global_configuration.py diff --git a/src/fmu/dataio/_model/product.py b/src/fmu/dataio/_models/fmu_results/product.py similarity index 96% rename from src/fmu/dataio/_model/product.py rename to src/fmu/dataio/_models/fmu_results/product.py index f6af71c99..3cbe607e0 100644 --- a/src/fmu/dataio/_model/product.py +++ b/src/fmu/dataio/_models/fmu_results/product.py @@ -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 diff --git a/src/fmu/dataio/_model/specification.py b/src/fmu/dataio/_models/fmu_results/specification.py similarity index 100% rename from src/fmu/dataio/_model/specification.py rename to src/fmu/dataio/_models/fmu_results/specification.py diff --git a/src/fmu/dataio/_models/products/__init__.py b/src/fmu/dataio/_models/products/__init__.py new file mode 100644 index 000000000..d58e316a5 --- /dev/null +++ b/src/fmu/dataio/_models/products/__init__.py @@ -0,0 +1,6 @@ +from .inplace_volumes import InplaceVolumesResult, InplaceVolumesSchema + +__all__ = [ + "InplaceVolumesResult", + "InplaceVolumesSchema", +] diff --git a/src/fmu/dataio/_products/inplace_volumes.py b/src/fmu/dataio/_models/products/inplace_volumes.py similarity index 100% rename from src/fmu/dataio/_products/inplace_volumes.py rename to src/fmu/dataio/_models/products/inplace_volumes.py diff --git a/src/fmu/dataio/_products/__init__.py b/src/fmu/dataio/_products/__init__.py deleted file mode 100644 index b8b729fef..000000000 --- a/src/fmu/dataio/_products/__init__.py +++ /dev/null @@ -1,5 +0,0 @@ -from .inplace_volumes import InplaceVolumesSchema - -__all__ = [ - "InplaceVolumesSchema", -] diff --git a/src/fmu/dataio/aggregation.py b/src/fmu/dataio/aggregation.py index 361936c44..5d824f707 100644 --- a/src/fmu/dataio/aggregation.py +++ b/src/fmu/dataio/aggregation.py @@ -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 diff --git a/src/fmu/dataio/case.py b/src/fmu/dataio/case.py index 52a9155fb..a08e28eda 100644 --- a/src/fmu/dataio/case.py +++ b/src/fmu/dataio/case.py @@ -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__) @@ -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, ), ), diff --git a/src/fmu/dataio/dataio.py b/src/fmu/dataio/dataio.py index 8c65985a6..3298efbd2 100644 --- a/src/fmu/dataio/dataio.py +++ b/src/fmu/dataio/dataio.py @@ -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, diff --git a/src/fmu/dataio/export/rms/inplace_volumes.py b/src/fmu/dataio/export/rms/inplace_volumes.py index 33469915d..87b08d9a8 100644 --- a/src/fmu/dataio/export/rms/inplace_volumes.py +++ b/src/fmu/dataio/export/rms/inplace_volumes.py @@ -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 diff --git a/src/fmu/dataio/preprocessed.py b/src/fmu/dataio/preprocessed.py index c19bdc81b..a9e4d49e1 100644 --- a/src/fmu/dataio/preprocessed.py +++ b/src/fmu/dataio/preprocessed.py @@ -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 diff --git a/src/fmu/dataio/providers/_filedata.py b/src/fmu/dataio/providers/_filedata.py index 90d84b39f..ed85a01d2 100644 --- a/src/fmu/dataio/providers/_filedata.py +++ b/src/fmu/dataio/providers/_filedata.py @@ -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 diff --git a/src/fmu/dataio/providers/_fmu.py b/src/fmu/dataio/providers/_fmu.py index 313907366..30a7e97f5 100644 --- a/src/fmu/dataio/providers/_fmu.py +++ b/src/fmu/dataio/providers/_fmu.py @@ -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 diff --git a/src/fmu/dataio/providers/objectdata/_base.py b/src/fmu/dataio/providers/objectdata/_base.py index f8ae390a8..59afb0b3c 100644 --- a/src/fmu/dataio/providers/objectdata/_base.py +++ b/src/fmu/dataio/providers/objectdata/_base.py @@ -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 @@ -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 diff --git a/src/fmu/dataio/providers/objectdata/_export_models.py b/src/fmu/dataio/providers/objectdata/_export_models.py index 48bc8f6f5..34840203d 100644 --- a/src/fmu/dataio/providers/objectdata/_export_models.py +++ b/src/fmu/dataio/providers/objectdata/_export_models.py @@ -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__) diff --git a/src/fmu/dataio/providers/objectdata/_faultroom.py b/src/fmu/dataio/providers/objectdata/_faultroom.py index 36085b588..573338202 100644 --- a/src/fmu/dataio/providers/objectdata/_faultroom.py +++ b/src/fmu/dataio/providers/objectdata/_faultroom.py @@ -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 ( diff --git a/src/fmu/dataio/providers/objectdata/_provider.py b/src/fmu/dataio/providers/objectdata/_provider.py index 07e8dfc66..8beea3a2a 100644 --- a/src/fmu/dataio/providers/objectdata/_provider.py +++ b/src/fmu/dataio/providers/objectdata/_provider.py @@ -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 ( diff --git a/src/fmu/dataio/providers/objectdata/_tables.py b/src/fmu/dataio/providers/objectdata/_tables.py index 9663087a8..c93dc2043 100644 --- a/src/fmu/dataio/providers/objectdata/_tables.py +++ b/src/fmu/dataio/providers/objectdata/_tables.py @@ -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, diff --git a/src/fmu/dataio/providers/objectdata/_utils.py b/src/fmu/dataio/providers/objectdata/_utils.py index 6a51a7061..3617a304c 100644 --- a/src/fmu/dataio/providers/objectdata/_utils.py +++ b/src/fmu/dataio/providers/objectdata/_utils.py @@ -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: diff --git a/src/fmu/dataio/providers/objectdata/_xtgeo.py b/src/fmu/dataio/providers/objectdata/_xtgeo.py index f64dc836a..e64b10bfc 100644 --- a/src/fmu/dataio/providers/objectdata/_xtgeo.py +++ b/src/fmu/dataio/providers/objectdata/_xtgeo.py @@ -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, diff --git a/tests/conftest.py b/tests/conftest.py index 6b83890b2..42fb47288 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -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 @@ -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) diff --git a/tests/test_export_rms/test_export_rms_volumetrics.py b/tests/test_export_rms/test_export_rms_volumetrics.py index bb8e3d78b..cef76a2a2 100644 --- a/tests/test_export_rms/test_export_rms_volumetrics.py +++ b/tests/test_export_rms/test_export_rms_volumetrics.py @@ -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, diff --git a/tests/test_integration/test_simple_export_run.py b/tests/test_integration/test_simple_export_run.py index 15232893a..7e84e02ad 100644 --- a/tests/test_integration/test_simple_export_run.py +++ b/tests/test_integration/test_simple_export_run.py @@ -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, @@ -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 diff --git a/tests/test_schema/test_pydantic_logic.py b/tests/test_schema/test_pydantic_logic.py index 85a40e2a4..f9747f2c4 100644 --- a/tests/test_schema/test_pydantic_logic.py +++ b/tests/test_schema/test_pydantic_logic.py @@ -7,7 +7,8 @@ import pytest from pydantic import ValidationError -from fmu.dataio._model import Root, data, enums +from fmu.dataio._models import FmuResults +from fmu.dataio._models.fmu_results import data, enums from ..utils import _get_pydantic_models_from_annotation, _metadata_examples @@ -30,7 +31,7 @@ def test_schema_example_filenames(file, example): @pytest.mark.parametrize("file, example", _metadata_examples().items()) def test_validate(file, example): """Confirm that examples are valid against the schema""" - Root.model_validate(example) + FmuResults.model_validate(example) def test_for_optional_fields_without_default(pydantic_models_from_root): @@ -89,33 +90,33 @@ def test_schema_file_block(metadata_examples): # get a specific example example = metadata_examples["surface_depth.yml"] - # Root.model_validate(example) + # FmuResults.model_validate(example) # shall validate as-is - Root.model_validate(example) + FmuResults.model_validate(example) # shall validate without absolute_path _example = deepcopy(example) del _example["file"]["absolute_path"] - Root.model_validate(_example) + FmuResults.model_validate(_example) # md5 checksum shall be a string _example["file"]["checksum_md5"] = 123.4 with pytest.raises(ValidationError): - Root.model_validate(_example) + FmuResults.model_validate(_example) # shall not validate without checksum_md5 del _example["file"]["checksum_md5"] with pytest.raises(ValidationError): - Root.model_validate(_example) + FmuResults.model_validate(_example) # shall validate when checksum is put back in _example["file"]["checksum_md5"] = "somechecksum" - Root.model_validate(_example) + FmuResults.model_validate(_example) # shall not validate without relative_path del _example["file"]["relative_path"] with pytest.raises(ValidationError): - Root.model_validate(_example) + FmuResults.model_validate(_example) def test_case(metadata_examples): @@ -124,21 +125,21 @@ def test_case(metadata_examples): example = metadata_examples["case.yml"] # assert validation with no changes - Root.model_validate(example) + FmuResults.model_validate(example) # assert validation error when "fmu" is missing _example = deepcopy(example) del _example["fmu"] with pytest.raises(ValidationError): - Root.model_validate(_example) + FmuResults.model_validate(_example) # assert validation error when "fmu.model" is missing _example = deepcopy(example) del _example["fmu"]["model"] with pytest.raises(ValidationError): - Root.model_validate(_example) + FmuResults.model_validate(_example) def test_fmu_block_aggr_real(metadata_examples): @@ -150,14 +151,14 @@ def test_fmu_block_aggr_real(metadata_examples): assert "aggregation" not in metadata["fmu"] # assert validation as-is - Root.model_validate(metadata) + FmuResults.model_validate(metadata) # add aggregation, shall fail. Get this from an actual example that validates. _metadata_aggregation = metadata_examples["aggregated_surface_depth.yml"] metadata["fmu"]["aggregation"] = _metadata_aggregation["fmu"]["aggregation"] with pytest.raises(ValidationError): - Root.model_validate(metadata) + FmuResults.model_validate(metadata) def test_data_top_base(metadata_examples): @@ -173,25 +174,25 @@ def test_data_top_base(metadata_examples): assert "base" in metadata["data"] # assert validation as-is - Root.model_validate(metadata) + FmuResults.model_validate(metadata) # remove "top" - shall fail _metadata = deepcopy(metadata) del _metadata["data"]["top"] with pytest.raises(ValidationError): - Root.model_validate(_metadata) + FmuResults.model_validate(_metadata) # remove "base" - shall fail _metadata = deepcopy(metadata) del _metadata["data"]["base"] with pytest.raises(ValidationError): - Root.model_validate(_metadata) + FmuResults.model_validate(_metadata) # remove both - shall pass del _metadata["data"]["top"] assert "top" not in _metadata["data"] # test assumption assert "base" not in _metadata["data"] # test assumption - Root.model_validate(_metadata) + FmuResults.model_validate(_metadata) def test_field_outline(metadata_examples): @@ -207,13 +208,13 @@ def test_field_outline(metadata_examples): assert "field_outline" in metadata["data"] # assert validation as-is - Root.model_validate(metadata) + FmuResults.model_validate(metadata) # assert failure when content is field_outline and fluid_contact is missing _metadata = deepcopy(metadata) del _metadata["data"]["field_outline"] with pytest.raises(ValidationError): - Root.model_validate(_metadata) + FmuResults.model_validate(_metadata) def test_field_region(metadata_examples): @@ -228,24 +229,24 @@ def test_field_region(metadata_examples): assert metadata["data"]["content"] == "field_region" assert "field_region" in metadata["data"] assert "id" in metadata["data"]["field_region"] - Root.model_validate(metadata) + FmuResults.model_validate(metadata) # assert that data.field_region is required _metadata = deepcopy(metadata) del _metadata["data"]["field_region"] with pytest.raises(ValidationError): - Root.model_validate(_metadata) + FmuResults.model_validate(_metadata) # validation of data.field_region _metadata = deepcopy(metadata) del _metadata["data"]["field_region"]["id"] with pytest.raises(ValidationError): - Root.model_validate(_metadata) + FmuResults.model_validate(_metadata) _metadata = deepcopy(metadata) _metadata["data"]["field_region"]["id"] = "NotANumber" with pytest.raises(ValidationError): - Root.model_validate(_metadata) + FmuResults.model_validate(_metadata) def test_fluid_contact(metadata_examples): @@ -265,7 +266,7 @@ def test_fluid_contact(metadata_examples): _metadata = deepcopy(metadata) del _metadata["data"]["fluid_contact"] with pytest.raises(ValidationError): - Root.model_validate(_metadata) + FmuResults.model_validate(_metadata) def test_schema_masterdata_smda(metadata_examples): @@ -274,20 +275,20 @@ def test_schema_masterdata_smda(metadata_examples): example = metadata_examples["case.yml"] # assert validation with no changes - Root.model_validate(example) + FmuResults.model_validate(example) # assert validation error when masterdata block is missing _example = deepcopy(example) del _example["masterdata"] with pytest.raises(ValidationError): - Root.model_validate(_example) + FmuResults.model_validate(_example) # assert validation error when masterdata.smda is missing # print(example["masterdata"]) _example = deepcopy(example) del _example["masterdata"]["smda"] with pytest.raises(ValidationError): - Root.model_validate(_example) + FmuResults.model_validate(_example) # assert validation error when missing attribute for block in [ @@ -300,7 +301,7 @@ def test_schema_masterdata_smda(metadata_examples): _example = deepcopy(example) del _example["masterdata"]["smda"][block] with pytest.raises(ValidationError): - Root.model_validate(_example) + FmuResults.model_validate(_example) # assert validation error if not correct type for block, type_ in [ @@ -315,7 +316,7 @@ def test_schema_masterdata_smda(metadata_examples): _example["masterdata"]["smda"][block] = "somestring" with pytest.raises(ValidationError): - Root.model_validate(_example) + FmuResults.model_validate(_example) def test_schema_data_time(metadata_examples): @@ -326,23 +327,23 @@ def test_schema_data_time(metadata_examples): assert "time" in example["data"] # assert validation with no changes - Root.model_validate(example) + FmuResults.model_validate(example) # valid when data.time is missing _example = deepcopy(example) del _example["data"]["time"] - Root.model_validate(_example) + FmuResults.model_validate(_example) # valid when only t0 _example = deepcopy(example) del _example["data"]["time"]["t1"] assert "t0" in _example["data"]["time"] # test assumption - Root.model_validate(_example) + FmuResults.model_validate(_example) # valid without labels _example = deepcopy(example) del _example["data"]["time"]["t0"]["label"] - Root.model_validate(_example) + FmuResults.model_validate(_example) # NOT valid when other types for testvalue in [ @@ -354,7 +355,7 @@ def test_schema_data_time(metadata_examples): _example = deepcopy(example) _example["data"]["time"] = testvalue with pytest.raises(ValidationError): - Root.model_validate(_example) + FmuResults.model_validate(_example) def test_classification(metadata_examples): @@ -364,19 +365,19 @@ def test_classification(metadata_examples): example = deepcopy(metadata_examples["surface_depth.yml"]) # assert validation with no changes - Root.model_validate(example) + FmuResults.model_validate(example) # assert "internal" and "restricted" validates example["access"]["classification"] = "internal" - Root.model_validate(example) + FmuResults.model_validate(example) example["access"]["classification"] = "restricted" - Root.model_validate(example) + FmuResults.model_validate(example) # assert erroneous value does not validate example["access"]["classification"] = "open" with pytest.raises(ValidationError): - Root.model_validate(example) + FmuResults.model_validate(example) def test_data_spec(metadata_examples): @@ -386,23 +387,23 @@ def test_data_spec(metadata_examples): example_surface = deepcopy(metadata_examples["surface_depth.yml"]) # assert validation with no changes - Root.model_validate(example_surface) + FmuResults.model_validate(example_surface) # assert data.spec required when class == surface del example_surface["data"]["spec"] with pytest.raises(ValidationError): - Root.model_validate(example_surface) + FmuResults.model_validate(example_surface) # fetch table example example_table = deepcopy(metadata_examples["table_inplace.yml"]) # assert validation with no changes - Root.model_validate(example_table) + FmuResults.model_validate(example_table) # assert data.spec required when class == table del example_table["data"]["spec"] with pytest.raises(ValidationError): - Root.model_validate(example_table) + FmuResults.model_validate(example_table) # fetch dictionary example example_dict = deepcopy(metadata_examples["dictionary_parameters.yml"]) @@ -412,7 +413,7 @@ def test_data_spec(metadata_examples): example_dict["data"]["spec"] # assert data.spec not required when class === dictionary - Root.model_validate(example_dict) + FmuResults.model_validate(example_dict) def test_content_whitelist(metadata_examples): @@ -423,12 +424,12 @@ def test_content_whitelist(metadata_examples): example_surface = deepcopy(metadata_examples["surface_depth.yml"]) # assert validation with no changes - Root.model_validate(example_surface) + FmuResults.model_validate(example_surface) # shall fail when content is not in whitelist example_surface["data"]["content"] = "not_valid_content" with pytest.raises(ValidationError): - Root.model_validate(example_surface) + FmuResults.model_validate(example_surface) def test_zmin_zmax_not_present_for_surfaces(metadata_examples): @@ -441,19 +442,19 @@ def test_zmin_zmax_not_present_for_surfaces(metadata_examples): example_surface = deepcopy(metadata_examples["surface_depth.yml"]) # assert validation with no changes and check that bbox is 3D - model = Root.model_validate(example_surface) + model = FmuResults.model_validate(example_surface) assert isinstance(model.root.data.root.bbox, data.BoundingBox3D) # assert validation works with zmin/zmax = None, bbox should be 2D example_surface["data"]["bbox"]["zmin"] = None example_surface["data"]["bbox"]["zmax"] = None - model = Root.model_validate(example_surface) + model = FmuResults.model_validate(example_surface) assert isinstance(model.root.data.root.bbox, data.BoundingBox2D) # assert validation works without zmin/zmax, bbox should be 2D del example_surface["data"]["bbox"]["zmin"] del example_surface["data"]["bbox"]["zmax"] - model = Root.model_validate(example_surface) + model = FmuResults.model_validate(example_surface) assert isinstance(model.root.data.root.bbox, data.BoundingBox2D) @@ -463,28 +464,28 @@ def test_iteration(metadata_examples): example = metadata_examples["iteration.yml"] # assert validation with no changes - Root.model_validate(example) + FmuResults.model_validate(example) # assert validation error when "fmu" is missing _example = deepcopy(example) del _example["fmu"] with pytest.raises(ValidationError): - Root.model_validate(_example) + FmuResults.model_validate(_example) # assert validation error when "fmu.iteration" is missing _example = deepcopy(example) del _example["fmu"]["iteration"] with pytest.raises(ValidationError): - Root.model_validate(_example) + FmuResults.model_validate(_example) # assert validation error when "fmu.context.stage" is not iteration _example = deepcopy(example) _example["fmu"]["context"]["stage"] = "case" with pytest.raises(ValidationError): - Root.model_validate(_example) + FmuResults.model_validate(_example) def test_realization(metadata_examples): @@ -493,25 +494,25 @@ def test_realization(metadata_examples): example = metadata_examples["realization.yml"] # assert validation with no changes - Root.model_validate(example) + FmuResults.model_validate(example) # assert validation error when "fmu" is missing _example = deepcopy(example) del _example["fmu"] with pytest.raises(ValidationError): - Root.model_validate(_example) + FmuResults.model_validate(_example) # assert validation error when "fmu.realization" is missing _example = deepcopy(example) del _example["fmu"]["realization"] with pytest.raises(ValidationError): - Root.model_validate(_example) + FmuResults.model_validate(_example) # assert validation error when "fmu.context.stage" is not realization _example = deepcopy(example) _example["fmu"]["context"]["stage"] = "iteration" with pytest.raises(ValidationError): - Root.model_validate(_example) + FmuResults.model_validate(_example) diff --git a/tests/test_schema/test_schemas_up_to_date.py b/tests/test_schema/test_schemas_up_to_date.py index c9e536ed5..8648b78fd 100644 --- a/tests/test_schema/test_schemas_up_to_date.py +++ b/tests/test_schema/test_schemas_up_to_date.py @@ -7,10 +7,7 @@ from pytest import MonkeyPatch from fmu.dataio._definitions import FmuSchemas, SchemaBase -from fmu.dataio._model import FmuResultsSchema -from fmu.dataio._products import InplaceVolumesSchema - -SCHEMAS = [FmuResultsSchema, InplaceVolumesSchema] +from fmu.dataio._models import schemas def contains_discriminator_mapping(schema: Any) -> bool: @@ -30,7 +27,7 @@ def contains_discriminator_mapping(schema: Any) -> bool: return False -@pytest.mark.parametrize("schema", SCHEMAS) +@pytest.mark.parametrize("schema", schemas) def test_schemas_uptodate(schema: SchemaBase) -> None: """ Test to verify if the local schemas are up to date with the schema @@ -44,7 +41,7 @@ def test_schemas_uptodate(schema: SchemaBase) -> None: assert json.load(f) == schema.dump() -@pytest.mark.parametrize("schema", SCHEMAS) +@pytest.mark.parametrize("schema", schemas) def test_schema_url_changes_with_env_var( schema: SchemaBase, monkeypatch: MonkeyPatch ) -> None: @@ -55,7 +52,7 @@ def test_schema_url_changes_with_env_var( assert schema.dump()["$id"].startswith(FmuSchemas.PROD_URL) -@pytest.mark.parametrize("schema", SCHEMAS) +@pytest.mark.parametrize("schema", schemas) def test_no_discriminator_mappings_leftover_in_schema(schema: SchemaBase) -> None: """Sumo's AJV validator doesn't like discriminator mappings leftover in the schema.""" diff --git a/tests/test_units/test_dataio.py b/tests/test_units/test_dataio.py index 181d7d448..d6fce0327 100644 --- a/tests/test_units/test_dataio.py +++ b/tests/test_units/test_dataio.py @@ -11,7 +11,7 @@ import pytest import yaml -from fmu.dataio._model.enums import FMUContext +from fmu.dataio._models.fmu_results.enums import FMUContext from fmu.dataio._utils import convert_datestr_to_isoformat, prettyprint_dict from fmu.dataio.dataio import ExportData, read_metadata from fmu.dataio.providers._fmu import FmuEnv diff --git a/tests/test_units/test_dunder_methods.py b/tests/test_units/test_dunder_methods.py index 3ed3c9847..b8d4c8ce0 100644 --- a/tests/test_units/test_dunder_methods.py +++ b/tests/test_units/test_dunder_methods.py @@ -2,8 +2,11 @@ import pytest -from fmu.dataio._model.fields import Parameters -from fmu.dataio._model.global_configuration import Stratigraphy, StratigraphyElement +from fmu.dataio._models.fmu_results.fields import Parameters +from fmu.dataio._models.fmu_results.global_configuration import ( + Stratigraphy, + StratigraphyElement, +) # -------------------------------------------------------------------------------------- # Stratigraphy diff --git a/tests/test_units/test_filedataprovider_class.py b/tests/test_units/test_filedataprovider_class.py index eaee88286..193e3acc4 100644 --- a/tests/test_units/test_filedataprovider_class.py +++ b/tests/test_units/test_filedataprovider_class.py @@ -9,7 +9,7 @@ from fmu.dataio import ExportData from fmu.dataio._definitions import ExportFolder -from fmu.dataio._model import fields +from fmu.dataio._models.fmu_results import fields from fmu.dataio.providers._filedata import FileDataProvider from fmu.dataio.providers.objectdata._provider import objectdata_provider_factory diff --git a/tests/test_units/test_fmuprovider_class.py b/tests/test_units/test_fmuprovider_class.py index e13ff71fd..7d03f04b6 100644 --- a/tests/test_units/test_fmuprovider_class.py +++ b/tests/test_units/test_fmuprovider_class.py @@ -8,9 +8,7 @@ import pytest from fmu import dataio - -# from conftest import pretend_ert_env_run1 -from fmu.dataio._model.enums import ErtSimulationMode, FMUContext +from fmu.dataio._models.fmu_results.enums import ErtSimulationMode, FMUContext from fmu.dataio.exceptions import InvalidMetadataError from fmu.dataio.providers._fmu import ( DEFAULT_ITER_NAME, diff --git a/tests/test_units/test_global_configuration.py b/tests/test_units/test_global_configuration.py index f1e2daaf9..4a0cd0b98 100644 --- a/tests/test_units/test_global_configuration.py +++ b/tests/test_units/test_global_configuration.py @@ -1,7 +1,7 @@ import pytest from hypothesis import given, strategies -from fmu.dataio._model import global_configuration +from fmu.dataio._models.fmu_results import global_configuration @given( diff --git a/tests/test_units/test_metadata_class.py b/tests/test_units/test_metadata_class.py index 9a5c9cc2c..9acd8b33c 100644 --- a/tests/test_units/test_metadata_class.py +++ b/tests/test_units/test_metadata_class.py @@ -8,8 +8,8 @@ import fmu.dataio as dio from fmu.dataio._definitions import SOURCE from fmu.dataio._metadata import generate_export_metadata -from fmu.dataio._model import FmuResultsSchema, enums -from fmu.dataio._model.fields import ( +from fmu.dataio._models.fmu_results import FmuResultsSchema, enums +from fmu.dataio._models.fmu_results.fields import ( OperatingSystem, TracklogEvent, ) diff --git a/tests/test_units/test_objectdataprovider_class.py b/tests/test_units/test_objectdataprovider_class.py index 37527046f..4662d1c35 100644 --- a/tests/test_units/test_objectdataprovider_class.py +++ b/tests/test_units/test_objectdataprovider_class.py @@ -8,7 +8,7 @@ from fmu import dataio from fmu.dataio._definitions import ConfigurationError, ValidFormats -from fmu.dataio._model.specification import FaultRoomSurfaceSpecification +from fmu.dataio._models.fmu_results.specification import FaultRoomSurfaceSpecification from fmu.dataio.providers.objectdata._faultroom import FaultRoomSurfaceProvider from fmu.dataio.providers.objectdata._provider import ( objectdata_provider_factory, diff --git a/tests/test_units/test_utils.py b/tests/test_units/test_utils.py index 19781862f..242752613 100644 --- a/tests/test_units/test_utils.py +++ b/tests/test_units/test_utils.py @@ -10,7 +10,7 @@ from xtgeo import Grid, Polygons, RegularSurface from fmu.dataio import _utils as utils -from fmu.dataio._model import fields +from fmu.dataio._models.fmu_results import fields from ..utils import _get_pydantic_models_from_annotation, inside_rms diff --git a/tools/schema-validate.py b/tools/schema-validate.py index 6813baa9c..c5beb0a93 100644 --- a/tools/schema-validate.py +++ b/tools/schema-validate.py @@ -6,7 +6,7 @@ from orjson import dumps from yaml import safe_load -from fmu.dataio._model import Root +from fmu.dataio._models import FmuResults def read(file): @@ -17,7 +17,7 @@ def read(file): for file in (f.strip() for f in sys.stdin.readlines()): print(file) try: - Root.model_validate_json(dumps(safe_load(read(file)))) + FmuResults.model_validate_json(dumps(safe_load(read(file)))) except ValueError: from pprint import pp diff --git a/tools/sumo-explorer-validate.py b/tools/sumo-explorer-validate.py index d362b279f..e840e2e6a 100644 --- a/tools/sumo-explorer-validate.py +++ b/tools/sumo-explorer-validate.py @@ -13,7 +13,7 @@ from pydantic import ValidationError from tqdm import tqdm -from fmu.dataio._model import Root +from fmu.dataio._models import FmuResults from fmu.sumo.explorer import Explorer @@ -78,7 +78,7 @@ async def main( pbar.update() try: - parsed = Root.model_validate(obj) + parsed = FmuResults.model_validate(obj) except ValidationError as e: pbar.write(pformat(obj)) pbar.write(str(e)) diff --git a/tools/update-schema b/tools/update-schema index 948012360..4b969d02c 100755 --- a/tools/update-schema +++ b/tools/update-schema @@ -24,8 +24,7 @@ from pathlib import Path from typing import Any, Dict, List, TypeVar from fmu.dataio._definitions import SchemaBase -from fmu.dataio._model import FmuResultsSchema -from fmu.dataio._products import InplaceVolumesSchema +from fmu.dataio._models import schemas GREEN = "\033[32m" RED = "\033[31m" @@ -36,11 +35,6 @@ PASS = f"[{BOLD}{GREEN}✔{NC}]" FAIL = f"[{BOLD}{RED}✖{NC}]" INFO = f"[{BOLD}{YELLOW}+{NC}]" -SCHEMAS = [ - FmuResultsSchema, - InplaceVolumesSchema, -] - T = TypeVar("T", Dict, List, object) @@ -228,7 +222,7 @@ def main() -> None: is_release = bool(os.environ.get("SCHEMA_RELEASE", False)) failed_a_write = False - for schema in SCHEMAS: + for schema in schemas: did_write = write_schema(schema, args.force, is_release, args.test, args.diff) if not did_write: failed_a_write = True