armi.settings.caseSettings module¶
This defines a Settings object that acts mostly like a dictionary. It is meant to be treated mostly like a singleton, where each custom ARMI object has access to it. It contains global user settings like the core power level, the input file names, the number of cycles to run, the run type, the environment setup, and hundreds of other things.
A settings object can be saved as or loaded from an YAML file. The ARMI GUI is designed to create this settings file, which is then loaded by an ARMI process on the cluster.
A primary case settings is created as masterCs
- class armi.settings.caseSettings.Settings(fName=None)[source]¶
Bases:
object
A container for global settings, such as case title, power level, and many run options.
It is accessible to most ARMI objects through self.cs (for ‘Case Settings’). It acts largely as a dictionary, and setting values are accessed by keys.
The settings object has a 1-to-1 correspondence with the ARMI settings input file. This file may be created by hand or by the GUI in submitter.py.
Notes
The actual settings in any instance of this class are immutable.
Instantiate a settings object
- Parameters
fName (str, optional) – Path to a valid yaml settings file that will be loaded
- instance = <Settings name:armiRun total:154 altered:30>¶
- defaultCaseTitle = 'armi'¶
- property inputDirectory¶
getter for settings file path
- property caseTitle¶
getter for settings case title
- property environmentSettings¶
getter for environment settings
- getSetting(key, default=None)[source]¶
Return a copy of an actual Setting object, instead of just its value.
Notes
This is used very rarely, try to organize your code to only need a Setting value.
- failOnLoad()[source]¶
This method is used to force loading a file to fail.
After command line processing of settings has begun, the settings should be fully defined. If the settings are loaded
- loadFromInputFile(fName, handleInvalids=True, setPath=True)[source]¶
Read in settings from an input YAML file.
Passes the reader back out in case you want to know something about how the reading went like for knowing if a file contained deprecated settings, etc.
- registerUserPlugins()[source]¶
Add any ad-hoc ‘user’ plugins that are referenced in the settings file.
- loadFromString(string, handleInvalids=True)[source]¶
Read in settings from a YAML string.
Passes the reader back out in case you want to know something about how the reading went like for knowing if a file contained deprecated settings, etc.
- initLogVerbosity()[source]¶
Central location to init logging verbosity
Notes
This means that creating a Settings object sets the global logging level of the entire code base.
- writeToYamlFile(fName, style='short')[source]¶
Write settings to a yaml file.
Notes
This resets the current CS’s path to the newly written path.
- writeToYamlStream(stream, style='short')[source]¶
Write settings in yaml format to an arbitrary stream.
- updateEnvironmentSettingsFrom(otherCs)[source]¶
Updates the environment settings in this object based on some other cs (from the GUI, most likely)
- Parameters
otherCs (Settings object) – A cs object that environment settings will be inherited from.
environment (This enables users to run tests with their environment rather than the reference) –
- modified(caseTitle=None, newSettings=None)[source]¶
Return a new Settings object containing the provided modifications.
- setModuleVerbosities(force=False)[source]¶
Attempt to grab the module-level logger verbosities from the settings file, and then set their log levels (verbosities).
- Parameters
force (bool, optional) – If force is False, don’t overwrite the log verbosities if the logger already exists. IF this needs to be used mid-run, force=False is safer.
Notes
This method is only meant to be called once per run.