armi.operators.settingsValidation module

A system to check user settings for validity and provide users with meaningful suggestions to fix.

This allows developers to specify 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.operators.settingsValidation.Query(condition, statement, question, correction)[source]

Bases: object

An individual query.

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.

isCorrective()[source]
resolve()[source]

Standard i/o prompt for resolution of an individual query.

class armi.operators.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

bool

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.

addQueryBadLocationWillLikelyFail(settingName)[source]

Add a query indicating the current path for settingName does not exist and will likely fail.

addQueryCurrentSettingMayNotSupportFeatures(settingName)[source]

Add a query that the current value for settingName may not support certain features.

armi.operators.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 for addQuery() is does the setting’s path exist. If more complicated callable arguments are needed, they can be passed in as the initialLambda setting.

armi.operators.settingsValidation.validateVersion(versionThis: str, versionRequired: str) bool[source]

Helper function to allow users to verify that their version matches the settings file.

Parameters
  • versionThis (str) – The version of this ARMI, App, or Plugin. This MUST be in the form: 1.2.3

  • versionRequired (str) – The version to compare against, say in a Settings file. This must be in one of the forms: 1.2.3, 1.2, or 1

Returns

Does this version match the version in the Settings file/object?

Return type

bool