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

WIP: Deprecating access_ssdl argument #575

Closed

Conversation

perolavsvendsen
Copy link
Member

@perolavsvendsen perolavsvendsen commented Apr 4, 2024

Ref discussion related to #540 and other issues

Proposing to deprecate the access_ssdl input argument in favor of classification and rep_include.

This PR does:

  • Deprecate access_ssdl argument, introduces classification and rep_include arguments
  • This is a follow-up from non-merged PR Populate the access.classification field #320 which was only partially made
  • Stops modifying the config during runtime. Read it, then use the elements from it further.
  • Moves some of the logic related to the config from dataio.py to global_configuration.py.

Might not be merged as-is, but perhaps elements or principles from it will be useful.

Purpose:

  • Make the classification argument a bit more intuitive and readable
  • Remove impression that this is something specific to SSDL when it is in fact not.

History:
Initially, the access.ssdl block was specific to SSDL and inherited from early versions of metadata when SSDL defined the FMU metadata (largely). Then, the access.ssdl.access_level was used also for access control outside SSDL (i.e. Sumo). Then, we decided to deprecate it - but only go half-way there, because of multiple challenges. Essentially, it stopped after adding access.classification to outgoing metadata (temporarily synchronized with access.ssdl.access_level.

The (milestone) goal should be to remove access.ssdl.access_level completely in favor of access.classification and then us this also in the config.

In short, we want to go from this:

exp = ExportData(access_ssdl={"access_level": "internal", rep_include=False})

...to this:

exp = ExportData(classification="internal", rep_include=False)

And we want to do the same in the config, i.e. from:

access:
  ssdl:
    access_level: internal
    rep_include: True

to:

access:
  classification: internal
  ssdl:
    rep_include: True

Complicating factors:

  • We still need the rep_include parameter, so the access.ssdl block will remain for now
  • We allow missing or non-valid config, and must handle that throughout fmu-dataio. This complicates things.
  • We make changes to the config during runtime, which complicates things. (Changed in this PR.)
  • We allow arguments to be given both to the initialization of ExportData and to the call to .generate_metadata(). This makes it a bit tricky to keep things in synch, particularly when we change things as we check them. (And then check them again later.)

Todo:

  • Deprecate access_ssdl from input argument and from config (not discontinue it)
  • Make support for using access.classification also in the config (and test it).
  • Rewrite tests to primarily use the updated pattern (classification)
  • Stop altering the config during runtime. Parse it, check it, then just read it.
  • Discussion, and some more discussion

⚠️ This is work in progress, and not ready for merging. Perhaps it will never be.

@@ -39,6 +39,9 @@
from .datastructure.configuration import global_configuration
from .providers._fmu import FmuEnv

# always show PendingDeprecationWarnings
warnings.simplefilter("always", PendingDeprecationWarning)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had to include this to make warnings actually show, not sure if this is specific for me 🤷‍♂️

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Later learned that we should use other types of warnings to make sure they are actually seen by end users.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will remove this, but keeping it for now as a TODO: We need to make sure warnings are actually seen by end users/modellers. Possibly separate PR.

@perolavsvendsen
Copy link
Member Author

Just sketching at this point, but some sort of pattern is perhaps starting to emerge

@@ -403,9 +411,10 @@ class ExportData:
_inside_rms: ClassVar[bool] = False # developer only! if True pretend inside RMS

# input keys (alphabetic)
access_ssdl: dict = field(default_factory=dict)
access_ssdl: dict = field(default_factory=dict) # deprecated
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deprecating access_ssdl, adding classification and rep_include

@@ -519,6 +552,13 @@ def _show_deprecations_or_notimplemented(self) -> None:
PendingDeprecationWarning,
)

if self.access_ssdl:
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the deprecation warning intended for users who still use the access_ssdl argument

PendingDeprecationWarning, match="The 'access_ssdl' key is deprec"
):
ExportData(access_ssdl={"access_level": "internal", "rep_include": True})

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The patterns below are the once we want to promote going forward

@perolavsvendsen
Copy link
Member Author

ref discussion @tnatt
Possible "carve-out" from this:

  • Better handling of config.
  • Explicitly set the keys we need from config into class variables (Pydantic objects??), then not carry config further.

@perolavsvendsen
Copy link
Member Author

@tnatt: rep_include does not have to be in the config, it will always be false as default anyway. I agree.

@perolavsvendsen
Copy link
Member Author

Replaced by #628

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant