serpent-tools icon indicating copy to clipboard operation
serpent-tools copied to clipboard

ENH Deprecate settings interface

Open drewejohnson opened this issue 5 years ago • 3 comments

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 avatar Sep 25 '19 18:09 drewejohnson

When the settings interface is removed and/or deprecated, the command line interface subcommand list should be adjusted and/or removed https://github.com/CORE-GATECH-GROUP/serpent-tools/blob/d6b65c8d5dc605fe5ca429e75047eb2b7e56530c/serpentTools/main.py#L159-L171

drewejohnson avatar Jan 24 '20 15:01 drewejohnson

Tentative plan from #516

  • 0.10.2 (next release) : all readers support settings at construction. No changes to rc object
  • 0.11.0 : Changing a setting via rc[x] = y raises a deprecation warning encouraging users to configure the readers at construction. Tests are updated to avoid using the rc object
  • 0.13.0 or at least 6 months after 0.11.0 : rc object and all settings infrastructure is removed from the codebase.

drewejohnson avatar Jun 03 '24 20:06 drewejohnson

For a deprecation, it's technically API compatible. But the full removal will be not compatible

drewejohnson avatar Jun 17 '24 23:06 drewejohnson