armi.settings.settingsValidation module
A system to check user settings for validity and provide users with meaningful suggestions to fix.
This allows developers to define a rich set of rules and suggestions for user settings. These then pop up during initialization of a run, either on the command line or as dialogues in the GUI. They say things like: “Your ___ setting has the value ___, which is impossible. Would you like to switch to ___?”
- class armi.settings.settingsValidation.Query(condition, statement, question, correction)[source]
Bases:
object
An individual setting validator.
Construct a query.
- Parameters:
condition (callable) – A callable that returns True or False. If True, then the query activates its question and potential correction.
statement (str) – A statement of the problem indicated by a True condition
question (str) – A question asking the user for confirmation of the proposed fix.
correction (callable) – A callable that when called fixes the situation. See
Inspector.NO_ACTION()
for no-ops.
- class armi.settings.settingsValidation.Inspector(cs)[source]
Bases:
object
This manages queries which assert certain states of the data model, generally presenting themselves to the user, offering information on the potential problem, a question and the action to take on an affirmative and negative answer from the user.
In practice very useful for making sure setting values are as intended and without bad interplay with one another.
One Inspector will contain multiple Queries and be associated directly with an
Operator
.Construct an inspector.
- Parameters:
cs (Settings) –
- static NO_ACTION()[source]
Convenience callable used to generate Queries that can’t be easily auto-resolved.
- run(cs=None)[source]
Run through each query and deal with it if possible.
- Returns:
correctionsMade – Whether or not anything was updated.
- Return type:
- Raises:
RuntimeError – When a programming error causes queries to loop.
- addQuery(condition, statement, question, correction)[source]
Convenience method, query must be resolved, else run fails.
- armi.settings.settingsValidation.createQueryRevertBadPathToDefault(inspector, settingName, initialLambda=None)[source]
Return a query to revert a bad path to its default.
- Parameters:
inspector (Inspector) – the inspector who’s settings are being queried
settingName (str) – name of the setting to inspect
initialLambda (None or callable function) – If
None
, the callable argument foraddQuery()
is does the setting’s path exist. If more complicated callable arguments are needed, they can be passed in as theinitialLambda
setting.