From 8ae70714b18ef8d3c2c8e9e44d937668f8927a29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Therese=20Natter=C3=B8y?= <61694854+tnatt@users.noreply.github.com> Date: Thu, 19 Sep 2024 09:58:07 +0200 Subject: [PATCH] DEP: Change to deprecation warning for content not provided (#786) --- docs/src/dataio_3_migration.rst | 2 ++ src/fmu/dataio/_model/schema.py | 4 ++-- tests/test_units/test_dataio.py | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/docs/src/dataio_3_migration.rst b/docs/src/dataio_3_migration.rst index 7bd3303e8..72d90127d 100644 --- a/docs/src/dataio_3_migration.rst +++ b/docs/src/dataio_3_migration.rst @@ -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``. @@ -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, # ✅ diff --git a/src/fmu/dataio/_model/schema.py b/src/fmu/dataio/_model/schema.py index b95ec2c68..4fe266e67 100644 --- a/src/fmu/dataio/_model/schema.py +++ b/src/fmu/dataio/_model/schema.py @@ -121,10 +121,10 @@ def _deprecation_warning(self) -> InternalUnsetData: valid_contents = [m.value for m in enums.Content] warnings.warn( "The 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 diff --git a/tests/test_units/test_dataio.py b/tests/test_units/test_dataio.py index ac44d7545..23eda76da 100644 --- a/tests/test_units/test_dataio.py +++ b/tests/test_units/test_dataio.py @@ -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 is not provided"): + with pytest.warns(FutureWarning, match="The is not provided"): mymeta = eobj.generate_metadata(regsurf) assert mymeta["data"]["content"] == "unset"