Skip to content

Commit

Permalink
MAINT: Remove warning when using forcefolder
Browse files Browse the repository at this point in the history
  • Loading branch information
tnatt committed Oct 1, 2024
1 parent 5ecfef9 commit 9e5ce10
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 23 deletions.
8 changes: 1 addition & 7 deletions src/fmu/dataio/providers/objectdata/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from dataclasses import dataclass, field
from datetime import datetime
from typing import TYPE_CHECKING, Any, Final
from warnings import warn

from fmu.dataio._definitions import ConfigurationError, ValidFormats
from fmu.dataio._logging import null_logger
Expand Down Expand Up @@ -65,12 +64,7 @@ def __post_init__(self) -> None:
if self.dataio.forcefolder:
if self.dataio.forcefolder.startswith("/"):
raise ValueError("Can't use absolute path as 'forcefolder'")
msg = (
f"The standard folder name is overrided from {self.efolder} to "
f"{self.dataio.forcefolder}"
)
logger.info(msg)
warn(msg, UserWarning)
logger.info(f"Using forcefolder {self.dataio.forcefolder}")

content_model = self._get_validated_content(self.dataio.content)
strat_element = self._get_stratigraphy_element()
Expand Down
3 changes: 1 addition & 2 deletions tests/test_units/test_dataio.py
Original file line number Diff line number Diff line change
Expand Up @@ -1017,8 +1017,7 @@ def test_forcefolder(tmp_path, globalconfig2, regsurf):

ExportData._inside_rms = True
edata = ExportData(config=globalconfig2, content="depth", forcefolder="whatever")
with pytest.warns(UserWarning, match="The standard folder name is overrided"):
meta = edata.generate_metadata(regsurf)
meta = edata.generate_metadata(regsurf)
logger.info("RMS PATH %s", rmspath)
logger.info("\n %s", prettyprint_dict(meta))
assert meta["file"]["relative_path"].startswith("share/results/whatever/")
Expand Down
3 changes: 1 addition & 2 deletions tests/test_units/test_ert_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,7 @@ def test_cube_export_file_is_observation_forcefolder(
name="MyCube",
)

with pytest.warns(UserWarning, match="The standard folder name is overrided"):
output = edata.export(cube)
output = edata.export(cube)
logger.info("Output is %s", output)

assert str(output) == str(
Expand Down
3 changes: 1 addition & 2 deletions tests/test_units/test_filedataprovider_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,7 @@ def test_filedata_provider(regsurf, tmp_path, globalconfig2):
forcefolder="efolder",
content="depth",
)
with pytest.warns(UserWarning, match="folder name is overrided"):
objdata = objectdata_provider_factory(regsurf, cfg)
objdata = objectdata_provider_factory(regsurf, cfg)
objdata.name = "name"
t1 = "19000101"
t2 = "20240101"
Expand Down
3 changes: 1 addition & 2 deletions tests/test_units/test_prerealization_surfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,8 +326,7 @@ def test_preprocessed_with_rel_forcefolder_ok(rmssetup, rmsglobalconfig, regsurf
timedata=[[20240802, "moni"], [20200909, "base"]],
forcefolder="tmp",
)
with pytest.warns(UserWarning, match="The standard folder name is overrided"):
meta = edata.generate_metadata(regsurf)
meta = edata.generate_metadata(regsurf)

assert "preprocessed/tmp" in meta["file"]["relative_path"]

Expand Down
12 changes: 4 additions & 8 deletions tests/test_units/test_rms_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,8 +348,7 @@ def test_cube_export_file_set_name_as_observation_forcefolder(inside_rms_setup,
)

# use forcefolder to apply share/observations/seismic which trigger a warning
with pytest.warns(UserWarning, match="The standard folder name is overrided"):
output = edata.export(cube)
output = edata.export(cube)

logger.info("Output after force is %s", output)
assert str(output) == str(
Expand Down Expand Up @@ -411,8 +410,7 @@ def test_cube_export_as_observation_forcefolder_w_added_folder(inside_rms_setup,
)

# use forcefolder to apply share/observations/seismic
with pytest.warns(UserWarning, match="The standard folder name is overrided"):
output = edata.export(cube)
output = edata.export(cube)
logger.info("Output after force is %s", output)

assert str(output) == str(
Expand All @@ -439,8 +437,7 @@ def test_cube_export_as_observation_forcefolder_w_true_subfolder(
)

# use forcefolder to apply share/observations/seismic
with pytest.warns(UserWarning, match="The standard folder name is overrided"):
output = edata.export(cube)
output = edata.export(cube)
logger.info("Output after force is %s", output)

assert str(output) == str(
Expand Down Expand Up @@ -472,8 +469,7 @@ def test_cube_export_as_observation_forcefolder_w_subfolder_case(
)

# use forcefolder to apply share/observations/seismic
with pytest.warns(UserWarning, match="The standard folder name is overrided"):
output = edata.export(cube)
output = edata.export(cube)
logger.info("Output after force is %s", output)

assert str(output) == str(
Expand Down

0 comments on commit 9e5ce10

Please sign in to comment.