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

ENH Deprecate settings interface #339

Open
4 tasks
drewejohnson opened this issue Sep 25, 2019 · 1 comment
Open
4 tasks

ENH Deprecate settings interface #339

drewejohnson opened this issue Sep 25, 2019 · 1 comment
Labels
API - Incompatible Incompatible changes to our API that require user actions Deprecations Features slated for deprecation and removal pythonicness
Projects

Comments

@drewejohnson
Copy link
Collaborator

I've been mulling something over for the past few months, and I think we can and should completely remove the settings interface. Instead, all of the functionality can be passed to the readers at construction.

Most of readers just pull from the rc global to create attributes during the construction.
Instead of

import serpentTools
serpentTools.settings.rc["depletion.materialVariables"] = ["ADENS", "MDENS"]
serpentTools.settings.rc["depletion.materials"] = ["fuel*"]
dep = serpentTools.read("my_dep.m")

one would instead use

import serpentTools
dep = serpentTools.read("my_dep.m", materials=["fuel*"], variables=["ADENS", "MDENS"])

The benefits are

  1. Remove a lot of code and tests [temporary settings using rc as a context manager]
  2. Cleaner API
  3. Changes can be made in isolation, i.e. if we want to add new options to a specific reader, we don't have to update settings, the reader, and the settings documentation. We just update the reader

The rc object and the capabilities allowed are a powerful feature of serpentTools IMHO. So naturally we will want to preserve this control, but try and reduce the pain of this switch.

Impact

Anyone who uses the rc object will be impacted. I frequently use these settings to control what data is read from depletion and result files.

Roll out

Version 0.9.0

  • Have rc.__setitem__ raise FutureWarnings indicating deprecation and swift removal
  • Modify __init__ methods for various readers that rely on these settings. If values are not explicitly provided, e.g. are None, pull the defaults from rc

Version 0.9.1 or later

  • Remove the entire serpentTools.settings interface
  • Pull defaults internally, not from rc
@drewejohnson drewejohnson added pythonicness API - Incompatible Incompatible changes to our API that require user actions proposal labels Sep 25, 2019
@drewejohnson drewejohnson added this to the 0.9.0 milestone Sep 25, 2019
@drewejohnson drewejohnson added the Deprecations Features slated for deprecation and removal label Sep 25, 2019
@drewejohnson drewejohnson added this to To do in Main Oct 4, 2019
@drewejohnson drewejohnson removed this from the 0.9.0 milestone Nov 15, 2019
@drewejohnson drewejohnson added this to the 0.10.0 milestone Nov 25, 2019
@drewejohnson
Copy link
Collaborator Author

When the settings interface is removed and/or deprecated, the command line interface subcommand list should be adjusted and/or removed

def _listDefaults(args):
"""List the default settings"""
from serpentTools.settings import defaultSettings
pattern = re.compile(args.pattern)
for name in sorted(defaultSettings.keys()):
if re.match(pattern, name):
values = defaultSettings[name]
print('{}: {}'.format(name, values[
'default' if args.q else 'description']))
if not args.q:
print(' default: {}'.format(values['default']))
if args.v and values.get('options', 'default') != 'default':
print(' options: {}'.format(values['options']))

drewejohnson added a commit to drewejohnson/serpent-tools that referenced this issue Aug 31, 2020
Interface outside of the rc object for expanding variable groups.
Abstracted away because the setting interface will eventually
be removed (GH CORE-GATECH-GROUP#339) as each reader (built from CORE-GATECH-GROUP#335 and CORE-GATECH-GROUP#400)
will control their own settings.
drewejohnson added a commit to drewejohnson/serpent-tools that referenced this issue Aug 31, 2020
Interface outside of the rc object for expanding variable groups.
Abstracted away because the setting interface will eventually
be removed (GH CORE-GATECH-GROUP#339) as each reader (built from CORE-GATECH-GROUP#335 and CORE-GATECH-GROUP#400)
will control their own settings.
drewejohnson added a commit to drewejohnson/serpent-tools that referenced this issue Aug 31, 2020
Interface outside of the rc object for expanding variable groups.
Abstracted away because the setting interface will eventually
be removed (GH CORE-GATECH-GROUP#339) as each reader (built from CORE-GATECH-GROUP#335 and CORE-GATECH-GROUP#400)
will control their own settings.
@drewejohnson drewejohnson removed this from the 0.10.0 milestone Aug 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API - Incompatible Incompatible changes to our API that require user actions Deprecations Features slated for deprecation and removal pythonicness
Projects
Main
To do
Development

No branches or pull requests

1 participant