diff --git a/src/fmu/dataio/_products/inplace_volumes.py b/src/fmu/dataio/_products/inplace_volumes.py index 76a9d3aab..f3acf4350 100644 --- a/src/fmu/dataio/_products/inplace_volumes.py +++ b/src/fmu/dataio/_products/inplace_volumes.py @@ -5,6 +5,8 @@ from pydantic import BaseModel, Field, RootModel from pydantic.json_schema import GenerateJsonSchema +from fmu.dataio.export._enums import InplaceVolumes + if TYPE_CHECKING: from typing import Any, Mapping @@ -23,7 +25,7 @@ class InplaceVolumesResultRow(BaseModel): should increase the version number in a way that corresponds to the schema versioning specification (i.e. they are a patch, minor, or major change).""" - FLUID: Literal["oil", "gas", "water"] + FLUID: InplaceVolumes.Fluid ZONE: str REGION: Optional[str] = Field(default=None) FACIES: Optional[str] = Field(default=None) diff --git a/src/fmu/dataio/export/rms/_enums.py b/src/fmu/dataio/export/_enums.py similarity index 91% rename from src/fmu/dataio/export/rms/_enums.py rename to src/fmu/dataio/export/_enums.py index 2bbdfe78f..8fdfd4bc5 100644 --- a/src/fmu/dataio/export/rms/_enums.py +++ b/src/fmu/dataio/export/_enums.py @@ -8,11 +8,11 @@ class InplaceVolumes: """Enumerations relevant to inplace volumes tables.""" class Fluid(str, Enum): - """Fluid types""" + """Fluid types used as values in the FLUID column.""" - OIL = "OIL" - GAS = "GAS" - WATER = "WATER" + oil = "oil" + gas = "gas" + water = "water" class TableIndexColumns(str, Enum): """The index columns for an inplace volumes table.""" diff --git a/src/fmu/dataio/export/rms/inplace_volumes.py b/src/fmu/dataio/export/rms/inplace_volumes.py index 2c7b46e26..cae505f35 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.enums import Classification +from fmu.dataio.export import _enums from fmu.dataio.export._decorators import experimental from fmu.dataio.export._export_result import ExportResult, ExportResultItem -from fmu.dataio.export.rms import _enums from fmu.dataio.export.rms._conditional_rms_imports import import_rms_package from fmu.dataio.export.rms._utils import ( check_rmsapi_version, @@ -154,19 +154,24 @@ def _transform_and_add_fluid_column_to_table( ] tables = [] - for fluid in [ - _enums.InplaceVolumes.Fluid.GAS.value, - _enums.InplaceVolumes.Fluid.OIL.value, - ]: - fluid_columns = [col for col in table.columns if col.endswith(f"_{fluid}")] + for fluid in ( + _enums.InplaceVolumes.Fluid.gas.value, + _enums.InplaceVolumes.Fluid.oil.value, + ): + fluid_suffix = fluid.upper() + fluid_columns = [ + col for col in table.columns if col.endswith(f"_{fluid_suffix}") + ] if fluid_columns: fluid_table = table[table_index + fluid_columns].copy() # drop fluid suffix from columns to get standard names - fluid_table.columns = fluid_table.columns.str.replace(f"_{fluid}", "") + fluid_table.columns = fluid_table.columns.str.replace( + f"_{fluid_suffix}", "" + ) # add the fluid as column entry instead - fluid_table[_enums.InplaceVolumes.FLUID_COLUMN] = fluid.lower() + fluid_table[_enums.InplaceVolumes.FLUID_COLUMN] = fluid tables.append(fluid_table) diff --git a/tests/test_export_rms/test_export_rms_volumetrics.py b/tests/test_export_rms/test_export_rms_volumetrics.py index f34c9bc5e..6a7cd4223 100644 --- a/tests/test_export_rms/test_export_rms_volumetrics.py +++ b/tests/test_export_rms/test_export_rms_volumetrics.py @@ -15,6 +15,7 @@ InplaceVolumesResultRow, dump, ) +from fmu.dataio.export import _enums from tests.utils import inside_rms logger = null_logger(__name__) @@ -94,8 +95,6 @@ def test_rms_volumetrics_export_class(exportvolumetrics): def test_rms_volumetrics_export_class_table_index(voltable_standard, exportvolumetrics): """See mocks in local conftest.py""" - from fmu.dataio.export.rms import _enums - out = exportvolumetrics._export_volume_table() metadata = dataio.read_metadata(out.items[0].absolute_path) @@ -120,7 +119,6 @@ def test_convert_table_from_legacy_to_standard_format( """Test that a voltable with legacy format is converted to the expected standard format""" - from fmu.dataio.export.rms import _enums from fmu.dataio.export.rms.inplace_volumes import _ExportVolumetricsRMS monkeypatch.chdir(rmssetup_with_fmuconfig) @@ -299,7 +297,7 @@ def test_rms_volumetrics_export_function( ): """Test the public function.""" - from fmu.dataio.export.rms import _enums, export_inplace_volumes + from fmu.dataio.export.rms import export_inplace_volumes from fmu.dataio.export.rms.inplace_volumes import _ExportVolumetricsRMS monkeypatch.chdir(rmssetup_with_fmuconfig) @@ -360,8 +358,6 @@ def test_inplace_volumes_payload_validates_against_schema( def test_inplace_volumes_export_and_result_columns_are_the_same( mocked_rmsapi_modules, ) -> None: - from fmu.dataio.export.rms import _enums - assert _enums.InplaceVolumes.table_columns() == list( InplaceVolumesResultRow.model_fields.keys() )