serpent-tools
serpent-tools copied to clipboard
ENH Deprecate settings interface
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
- Remove a lot of code and tests [temporary settings using
rc
as a context manager] - Cleaner API
- 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__
raiseFutureWarnings
indicating deprecation and swift removal - [ ] Modify
__init__
methods for various readers that rely on these settings. If values are not explicitly provided, e.g. areNone
, pull the defaults fromrc
Version 0.9.1 or later
- [ ] Remove the entire
serpentTools.settings
interface - [ ] Pull defaults internally, not from
rc
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
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 therc
object - 0.13.0 or at least 6 months after 0.11.0 :
rc
object and all settings infrastructure is removed from the codebase.
For a deprecation, it's technically API compatible. But the full removal will be not compatible