Skip to content

Commit

Permalink
DEP: Drop support for adding jobs.json (#672)
Browse files Browse the repository at this point in the history
  • Loading branch information
tnatt authored Jun 10, 2024
1 parent 40a0573 commit 9c7e6f1
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 50 deletions.
11 changes: 0 additions & 11 deletions docs/example_surface.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,6 @@ fmu:
- KVKH_US: 0.6
- FAULT_SEAL_SCALING: 0.1
- FWL_CENTRAL: 1677
jobs: # directly pass jobs.json. This is a lot of content, only a stub is included here.
umask: "0002"
DATA_ROOT: /some/path/20.4.0_20201106/ert/model
anything: something
something:
anything: something
global_update_path: {}
jobList:
- name: MAKE_DIRECTORY
min_arg: 1
anything: something

file:
relative_path: share/results/maps/volantis_gp_base--amplitude.gri
Expand Down
8 changes: 6 additions & 2 deletions src/fmu/dataio/dataio.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ class ExportData:
cube_fformat: ClassVar[str] = "segy"
filename_timedata_reverse: ClassVar[bool] = False # reverse order output file name
grid_fformat: ClassVar[str] = "roff"
include_ertjobs: ClassVar[bool] = False # if True, include jobs.json from ERT
include_ertjobs: ClassVar[bool] = False # deprecated
legacy_time_format: ClassVar[bool] = False # deprecated
meta_format: ClassVar[Literal["yaml", "json"]] = "yaml"
polygons_fformat: ClassVar[str] = "csv" # or use "csv|xtgeo"
Expand Down Expand Up @@ -589,6 +589,11 @@ def _show_deprecations_or_notimplemented(self) -> None:
"Please remove it from the argument list.",
UserWarning,
)
if self.include_ertjobs:
warn(
"The 'include_ertjobs' option is deprecated and should be removed.",
UserWarning,
)

def _validate_and_establish_fmucontext(self) -> None:
"""
Expand Down Expand Up @@ -708,7 +713,6 @@ def _get_fmu_provider(self) -> FmuProvider:
model=self.config.get("model"),
fmu_context=self.fmu_context,
casepath_proposed=Path(self.casepath) if self.casepath else None,
include_ertjobs=self.include_ertjobs,
workflow=self.workflow,
)

Expand Down
16 changes: 0 additions & 16 deletions src/fmu/dataio/providers/_fmu.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@

from __future__ import annotations

import json
import os
from dataclasses import dataclass, field
from enum import Enum, auto
Expand Down Expand Up @@ -101,13 +100,11 @@ class FmuProvider(Provider):
model: Name of the model (usually from global config)
fmu_context: The FMU context this is ran in; see FmuContext enum class
casepath_proposed: Proposed casepath. Needed if FmuContext is CASE
include_ertjobs: True if we want to include ....
workflow: Descriptive work flow info
"""

model: dict | None = None
fmu_context: FmuContext = FmuContext.REALIZATION
include_ertjobs: bool = False
casepath_proposed: Optional[Path] = None
workflow: Optional[Union[str, dict[str, str]]] = None

Expand Down Expand Up @@ -268,18 +265,6 @@ def _get_ert_parameters(self) -> meta.Parameters | None:
# does contains check, will fail.
return meta.Parameters(root=_utils.nested_parameters_dict(params)) # type: ignore

def _get_ert_jobs(self) -> dict | None:
logger.debug("Read ERT jobs")
assert self._runpath is not None
jobs_file = self._runpath / "jobs.json"
if not jobs_file.exists():
logger.debug("jobs.json was not found")
return None

with open(jobs_file) as stream:
logger.debug("parsing jobs.json.")
return json.load(stream)

def _get_iteration_and_real_uuid(self, case_uuid: UUID) -> tuple[UUID, UUID]:
iter_uuid = _utils.uuid_from_string(f"{case_uuid}{self._iter_name}")
real_uuid = _utils.uuid_from_string(f"{case_uuid}{iter_uuid}{self._real_id}")
Expand All @@ -300,7 +285,6 @@ def _get_realization_meta(self, real_uuid: UUID) -> meta.Realization:
id=self._real_id,
name=self._real_name,
parameters=self._get_ert_parameters(),
jobs=self._get_ert_jobs() if self.include_ertjobs else None,
uuid=real_uuid,
)

Expand Down
22 changes: 7 additions & 15 deletions tests/test_units/test_ert_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,24 +33,16 @@ def test_regsurf_generate_metadata(fmurun_w_casemetadata, rmsglobalconfig, regsu
assert "jobs" not in meta["fmu"]["realization"]


def test_regsurf_generate_metadata_incl_jobs(
fmurun_w_casemetadata, rmsglobalconfig, regsurf
):
"""As above but now with jobs.json stuff included via class variable flag."""
logger.info("Active folder is %s", fmurun_w_casemetadata)
os.chdir(fmurun_w_casemetadata)
def test_incl_jobs_warning(rmsglobalconfig):
"""Check that usning the deprecated class variable include_ertjobs gives warning."""

dataio.ExportData.include_ertjobs = True

edata = dataio.ExportData(
config=rmsglobalconfig,
content="depth",
)

meta = edata.generate_metadata(regsurf)
assert meta["fmu"]["realization"]["jobs"]["umask"] == "0002"

dataio.ExportData.include_ertjobs = False
with pytest.warns(UserWarning, match="deprecated"):
dataio.ExportData(
config=rmsglobalconfig,
content="depth",
)


def test_regsurf_metadata_with_timedata(
Expand Down
6 changes: 0 additions & 6 deletions tests/test_units/test_fmuprovider_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ def test_fmuprovider_no_provider():
model=GLOBAL_CONFIG_MODEL,
fmu_context=FmuContext.REALIZATION,
casepath_proposed="",
include_ertjobs=False,
workflow=WORKFLOW,
)
with pytest.raises(
Expand Down Expand Up @@ -69,7 +68,6 @@ def test_fmuprovider_ert_provider_guess_casemeta_path(fmurun):
model=GLOBAL_CONFIG_MODEL,
fmu_context=FmuContext.REALIZATION,
casepath_proposed="", # if casepath is undef, try deduce from, _ERT_RUNPATH
include_ertjobs=False,
workflow=WORKFLOW,
)

Expand All @@ -90,7 +88,6 @@ def test_fmuprovider_ert_provider_missing_parameter_txt(fmurun_w_casemetadata):
myfmu = FmuProvider(
model=GLOBAL_CONFIG_MODEL,
fmu_context=FmuContext.REALIZATION,
include_ertjobs=True,
workflow=WORKFLOW,
)
with pytest.warns(UserWarning, match="parameters.txt file was not found"):
Expand All @@ -108,7 +105,6 @@ def test_fmuprovider_arbitrary_iter_name(fmurun_w_casemetadata_pred):
myfmu = FmuProvider(
model=GLOBAL_CONFIG_MODEL,
fmu_context=FmuContext.REALIZATION,
include_ertjobs=True,
workflow=WORKFLOW,
)
assert myfmu._case_name == "ertrun1"
Expand All @@ -128,7 +124,6 @@ def test_fmuprovider_get_real_and_iter_from_env(fmurun_non_equal_real_and_iter):
myfmu = FmuProvider(
model=GLOBAL_CONFIG_MODEL,
fmu_context=FmuContext.REALIZATION,
include_ertjobs=True,
workflow=WORKFLOW,
)
assert myfmu._runpath == fmurun_non_equal_real_and_iter
Expand Down Expand Up @@ -196,7 +191,6 @@ def test_fmuprovider_prehook_case(tmp_path, globalconfig2, fmurun_prehook):
myfmu = FmuProvider(
model=GLOBAL_CONFIG_MODEL,
fmu_context=FmuContext.CASE,
include_ertjobs=False,
workflow=WORKFLOW,
casepath_proposed=caseroot,
)
Expand Down

0 comments on commit 9c7e6f1

Please sign in to comment.