Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX, DEP: rename from export_rms_volumetrics to export_volumetrics #798

Merged
merged 2 commits into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions docs/src/rms_oneliners.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,19 @@ Example:

.. code-block:: python

from fmu.dataio.export.rms import export_rms_volumetrics
from fmu.dataio.export.rms import export_volumetrics
...

# here 'Geogrid' is the grid model name, and 'geogrid_volumes' is the name of the volume job
outfiles = export_rms_volumetrics(project, "Geogrid", "geogrid_volumes")
outfiles = export_volumetrics(project, "Geogrid", "geogrid_volumes")

print(f"Output volumes to {outfiles}")

Most ``dataio`` settings are here defaulted, but some keys can be altered optionally, e.g.:

.. code-block:: python

outfiles = export_rms_volumetrics(
outfiles = export_volumetrics(
project,
"Geogrid",
"geogrid_volumes",
Expand Down
17 changes: 17 additions & 0 deletions src/fmu/dataio/export/_decorators.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import warnings
from functools import wraps


def experimental(func): # type: ignore
"""Decorator to mark functions as experimental."""

@wraps(func)
def wrapper(*args, **kwargs): # type: ignore
warnings.warn(
f"{func.__name__} is experimental and may change in future versions.",
UserWarning,
stacklevel=2,
)
return func(*args, **kwargs)

return wrapper
4 changes: 2 additions & 2 deletions src/fmu/dataio/export/rms/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from .volumetrics import export_rms_volumetrics
from .volumetrics import export_rms_volumetrics, export_volumetrics

__all__ = ["export_rms_volumetrics"]
__all__ = ["export_volumetrics", "export_rms_volumetrics"]
21 changes: 20 additions & 1 deletion src/fmu/dataio/export/rms/volumetrics.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import annotations

import warnings
from dataclasses import dataclass, field
from pathlib import Path
from typing import Any, Final
Expand All @@ -12,6 +13,7 @@
from fmu.config.utilities import yaml_load
from fmu.dataio._logging import null_logger

from .._decorators import experimental
from ._conditional_rms_imports import import_rms_package

_modules = import_rms_package()
Expand Down Expand Up @@ -191,7 +193,8 @@ def export(self) -> dict[str, str]:
return self._export_volume_table()


def export_rms_volumetrics(
@experimental
def export_volumetrics(
project: Any,
grid_name: str,
volume_job_name: str,
Expand Down Expand Up @@ -228,6 +231,9 @@ def export_rms_volumetrics(
classification: Optional. Use 'internal' or 'restricted' (default).
workflow: Optional. Information about the work flow; defaulted to
'rms volumetrics'.

Note:
This function is experimental and may change in future versions.
"""

return _ExportVolumetricsRMS(
Expand All @@ -242,3 +248,16 @@ def export_rms_volumetrics(
classification=classification,
workflow=workflow,
).export()


# keep the old name for now but not log (will be removed soon as we expect close to
# zero usage so far)
def export_rms_volumetrics(*args, **kwargs) -> dict[str, str]: # type: ignore
"""Deprecated function. Use export_volumetrics instead."""
warnings.warn(
"export_rms_volumetrics is deprecated and will be removed in a future release. "
"Use export_volumetrics instead.",
FutureWarning,
stacklevel=2,
)
return export_volumetrics(*args, **kwargs)
4 changes: 2 additions & 2 deletions tests/test_export_rms/test_export_rms_volumetrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@ def test_rms_volumetrics_export_function(
):
"""Test the public function."""

from fmu.dataio.export.rms import export_rms_volumetrics
from fmu.dataio.export.rms import export_volumetrics

os.chdir(rmssetup_with_fmuconfig)

result = export_rms_volumetrics(mock_project_variable, "Geogrid", "geogrid_volume")
result = export_volumetrics(mock_project_variable, "Geogrid", "geogrid_volume")
vol_table_file = result["volume_table"]

assert Path(vol_table_file).is_file()
Expand Down