Skip to content

Commit

Permalink
DEP: Change to deprecation warning for content not provided (#786)
Browse files Browse the repository at this point in the history
  • Loading branch information
tnatt authored Sep 19, 2024
1 parent 3d517ab commit 8ae7071
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 2 additions & 0 deletions docs/src/dataio_3_migration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ but with replacements inplace.
a dictionary form to provide a reference together with the ``vertical_domain`` is deprecated, use
the ``domain_reference`` argument instead.
- ``workflow`` now only supports string input, example ``workflow='Structural modelling'``.
- ``content`` was previously optional, it should now be explicitly provided.
- ``content={'seismic': {'offset': '0-15'}}`` no longer works, use the key ``stacking_offset`` instead
of ``offset``.

Expand All @@ -44,6 +45,7 @@ Change to this instead 👇:
from fmu.dataio import ExportData
ExportData(
content='depth', # ✅ content must explicitly be provided
preprocessed=True, #
classification='restricted', # ✅ note the use of 'restricted' instead of 'asset'
rep_include=True, #
Expand Down
4 changes: 2 additions & 2 deletions src/fmu/dataio/_model/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,10 @@ def _deprecation_warning(self) -> InternalUnsetData:
valid_contents = [m.value for m in enums.Content]
warnings.warn(
"The <content> is not provided which will produce invalid metadata. "
"It is strongly recommended that content is given explicitly! "
"In the future 'content' will be required explicitly! "
f"\n\nValid contents are: {', '.join(valid_contents)} "
"\n\nThis list can be extended upon request and need.",
UserWarning,
FutureWarning,
)
return self

Expand Down
2 changes: 1 addition & 1 deletion tests/test_units/test_dataio.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ def test_unit_is_none(globalconfig1, regsurf):
def test_content_not_given(globalconfig1, regsurf):
"""When content is not explicitly given, warning shall be issued."""
eobj = ExportData(config=globalconfig1)
with pytest.warns(UserWarning, match="The <content> is not provided"):
with pytest.warns(FutureWarning, match="The <content> is not provided"):
mymeta = eobj.generate_metadata(regsurf)

assert mymeta["data"]["content"] == "unset"
Expand Down

0 comments on commit 8ae7071

Please sign in to comment.