Skip to content

Commit

Permalink
Fix issue when parameters.txt is missing, cf. #258
Browse files Browse the repository at this point in the history
  • Loading branch information
jcrivenaes committed Oct 28, 2022
1 parent 17dc928 commit b32358f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
4 changes: 3 additions & 1 deletion src/fmu/dataio/_fmu_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,9 @@ def get_ert2_information(self):
nested_params = _utils.nested_parameters_dict(params)
self.ert2["params"] = nested_params
logger.debug("parameters.txt parsed.")
logger.debug("parameters.txt was not found")
else:
self.ert2["params"] = None
logger.debug("parameters.txt was not found")

# store jobs.json if required!
if self.dataio.include_ert2jobs:
Expand Down
22 changes: 16 additions & 6 deletions tests/test_units/test_fmuprovider_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,22 @@ def test_fmuprovider_ert2_provider(fmurun, globalconfig1):
assert myfmu.real_id == 0


def test_fmuprovider_ert2_provider_missing_parameter_txt(fmurun, globalconfig1):
"""Test for an ERT2 case, when missing file parameter.txt (e.g. pred. run)"""

os.chdir(fmurun)
(fmurun / "parameters.txt").unlink()

ex = dio.ExportData(fmu_context="realization", config=globalconfig1)
ex._rootpath = fmurun

myfmu = _FmuProvider(ex)
myfmu.detect_provider()
assert myfmu.case_name == "ertrun1"
assert myfmu.real_name == "realization-0"
assert myfmu.real_id == 0


def test_fmuprovider_prehook_case(globalconfig2, tmp_path):
"""The fmu run case metadata is initialized with Initialize case; then fet provider.
Expand All @@ -59,7 +75,6 @@ def test_fmuprovider_prehook_case(globalconfig2, tmp_path):
caseroot.mkdir(parents=True)

os.chdir(caseroot)
print("XXXX", caseroot)

exp = icase.export(
rootfolder=caseroot,
Expand All @@ -70,7 +85,6 @@ def test_fmuprovider_prehook_case(globalconfig2, tmp_path):
casemetafile = caseroot / "share/metadata/fmu_case.yml"
assert casemetafile.is_file()
assert exp == str(casemetafile.resolve())
print("Case metafile", casemetafile)

eobj = dio.ExportData(
config=globalconfig2,
Expand All @@ -82,10 +96,6 @@ def test_fmuprovider_prehook_case(globalconfig2, tmp_path):
casepath=caseroot,
)

print(eobj._rootpath)
print(eobj._pwd)
print(eobj._inside_rms)

myfmu = _FmuProvider(eobj, verbosity="INFO")
myfmu.detect_provider()
assert myfmu.case_name == "prehook"
Expand Down

0 comments on commit b32358f

Please sign in to comment.