Skip to content

Commit

Permalink
TST: Adapt Ert mode test to Ert 14
Browse files Browse the repository at this point in the history
Ert 14.0.0 deprecated 'iterative ensemble smoother' mode. While this
mode should also be removed from the Ert mode enum, we cannot do so
safely within pinning the Ert version above 14. We cannot do that until
we stop supporting Python 3.8.
  • Loading branch information
mferrera committed Mar 6, 2025
1 parent 15d3d49 commit a22169e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/fmu/dataio/_models/fmu_results/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ class ErtSimulationMode(str, Enum):
ensemble_smoother = "ensemble_smoother"
es_mda = "es_mda"
evaluate_ensemble = "evaluate_ensemble"
# TODO: Remove 'iterative_ensemble_smoother' when Python 3.8 deprecated. It was
# removed # with Ert 14.0.0.
iterative_ensemble_smoother = "iterative_ensemble_smoother"
manual_update = "manual_update"
test_run = "test_run"
Expand Down
15 changes: 13 additions & 2 deletions tests/test_units/test_fmuprovider_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,8 +411,13 @@ def test_fmuprovider_workflow_reference(fmurun_w_casemetadata, globalconfig2):
def test_ert_simulation_modes_one_to_one() -> None:
"""Ensure dataio known modes match those defined by Ert.
These are currently defined in `ert.mode_definitions`. `MODULE_MODE` is skipped due
to seemingly being relevant to Ert internally -- the modes are duplicated there."""
These are currently defined in `ert.mode_definitions`.
- `MODULE_MODE` is skipped due to seemingly being relevant to Ert internally.
The modes are duplicated there.
- `iterative_ensemble_mode` was removed in Ert 14. It must be ignored here for as
long as we support Python 3.8.
"""
ert_mode_definitions = importlib.import_module("ert.mode_definitions")
ert_modes = {
getattr(ert_mode_definitions, name)
Expand All @@ -422,4 +427,10 @@ def test_ert_simulation_modes_one_to_one() -> None:
and isinstance(getattr(ert_mode_definitions, name), str)
}
dataio_known_modes = {mode.value for mode in ErtSimulationMode}

# TODO: Remove this check when Python 3.8 deprecated.
ert_version = importlib.metadata.version("ert")
if int(ert_version.split(".")[0]) >= 14:
dataio_known_modes.discard("iterative_ensemble_smoother")

assert ert_modes == dataio_known_modes

0 comments on commit a22169e

Please sign in to comment.