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

ENH: Set Region required in inplace_volumes #948

Merged
merged 1 commit into from
Jan 3, 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/_products/inplace_volumes.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class InplaceVolumesResultRow(BaseModel):

FLUID: InplaceVolumes.Fluid
ZONE: str
REGION: Optional[str] = Field(default=None)
REGION: str
FACIES: Optional[str] = Field(default=None)
LICENSE: Optional[str] = Field(default=None)

Expand Down
1 change: 1 addition & 0 deletions src/fmu/dataio/export/_enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ def required_index_columns() -> list[str]:
return [
InplaceVolumes.TableIndexColumns.FLUID.value,
InplaceVolumes.TableIndexColumns.ZONE.value,
InplaceVolumes.TableIndexColumns.REGION.value,
]

@staticmethod
Expand Down
13 changes: 11 additions & 2 deletions src/fmu/dataio/export/rms/inplace_volumes.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,10 +240,19 @@ def _is_column_missing_in_table(self, column: str) -> bool:
def _validate_table(self) -> None:
"""
Validate that the final table with volumes is according to the standard
defined for the inplace_volumes product.
defined for the inplace_volumes product. The table should have the required
index and value columns, and at least one of the main types 'oil' or 'gas'.
"""
_logger.debug("Validating the dataframe...")

# check that all required index columns are present
for col in _enums.InplaceVolumes.required_index_columns():
if self._is_column_missing_in_table(col):
raise RuntimeError(
f"Required index column {col} is missing in the volumetric table. "
"Please update and rerun the volumetric job before export."
)

has_oil = (
"oil" in self._dataframe[_enums.InplaceVolumes.FLUID_COLUMN.value].values
)
Expand All @@ -259,7 +268,7 @@ def _validate_table(self) -> None:
"before export."
)

# create list of missing or non-defined required columns
# check that all required value columns are present
missing_calculations = []
for col in _enums.InplaceVolumes.required_value_columns():
if self._is_column_missing_in_table(col):
Expand Down
3 changes: 1 addition & 2 deletions tests/test_export_rms/test_export_rms_volumetrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,12 +354,11 @@ def test_total_volumes_required(exportvolumetrics, voltable_legacy):
exportvolumetrics._compute_water_zone_volumes_from_totals(df)


@pytest.mark.parametrize("required_col", ["BULK", "PORV", "HCPV"])
@pytest.mark.parametrize("required_col", _enums.InplaceVolumes.required_columns())
def test_validate_table_required_col_missing(
exportvolumetrics, voltable_standard, required_col
):
"""Test that the job fails if a required volumetric column is missing"""

df = voltable_standard.drop(columns=required_col)
exportvolumetrics._dataframe = df

Expand Down
Loading