From 5d4c9aa2b68b7f173b430506eec594c90849b963 Mon Sep 17 00:00:00 2001 From: mferrera Date: Thu, 19 Dec 2024 10:31:21 +0100 Subject: [PATCH] WIP --- src/fmu/dataio/export/_enums.py | 24 +++++++++++++++++++ src/fmu/dataio/export/rms/inplace_volumes.py | 2 +- .../test_export_rms_volumetrics.py | 9 +++++++ 3 files changed, 34 insertions(+), 1 deletion(-) diff --git a/src/fmu/dataio/export/_enums.py b/src/fmu/dataio/export/_enums.py index 8fdfd4bc5..0007ba357 100644 --- a/src/fmu/dataio/export/_enums.py +++ b/src/fmu/dataio/export/_enums.py @@ -43,11 +43,35 @@ def index_columns() -> list[str]: """Returns a list of the index columns.""" return [k.value for k in InplaceVolumes.TableIndexColumns] + @staticmethod + def required_index_columns() -> list[str]: + return [ + InplaceVolumes.TableIndexColumns.FLUID.value, + InplaceVolumes.TableIndexColumns.ZONE.value, + ] + @staticmethod def value_columns() -> list[str]: """Returns a list of the value columns.""" return [k.value for k in InplaceVolumes.VolumetricColumns] + @staticmethod + def required_value_columns() -> list[str]: + """Returns a list of the value columns.""" + return [ + InplaceVolumes.VolumetricColumns.BULK.value, + InplaceVolumes.VolumetricColumns.PORV.value, + InplaceVolumes.VolumetricColumns.HCPV.value, + ] + + @staticmethod + def required_columns() -> list[str]: + """Returns a list of the columns required at export.""" + return ( + InplaceVolumes.required_index_columns() + + InplaceVolumes.required_value_columns() + ) + @staticmethod def table_columns() -> list[str]: """Returns a list of all table columns.""" diff --git a/src/fmu/dataio/export/rms/inplace_volumes.py b/src/fmu/dataio/export/rms/inplace_volumes.py index 77bd63d02..68c944add 100644 --- a/src/fmu/dataio/export/rms/inplace_volumes.py +++ b/src/fmu/dataio/export/rms/inplace_volumes.py @@ -217,7 +217,7 @@ def _validate_table(self) -> None: # create list of missing or non-defined required columns missing_calculations = [] - for col in ["BULK", "PORV", "HCPV"]: + for col in _enums.InplaceVolumes.required_value_columns(): if self._is_column_missing_in_table(col): missing_calculations.append(col) diff --git a/tests/test_export_rms/test_export_rms_volumetrics.py b/tests/test_export_rms/test_export_rms_volumetrics.py index 4a396499f..9460ba412 100644 --- a/tests/test_export_rms/test_export_rms_volumetrics.py +++ b/tests/test_export_rms/test_export_rms_volumetrics.py @@ -375,3 +375,12 @@ def test_inplace_volumes_export_and_result_columns_are_the_same( assert _enums.InplaceVolumes.table_columns() == list( InplaceVolumesResultRow.model_fields.keys() ) + + +def test_that_required_columns_one_to_one_in_enum_and_schema() -> None: + schema_required_fields = [ + name + for name, field in InplaceVolumesResultRow.__fields__.items() + if field.required + ] + assert _enums.InplaceVolumes.required_columns == schema_required_fields