AppInterface.exec_mode
AppInterface.exec_mode |
Purpose
Property for the execution mode in which Xpress Insight is running the model.
Synopsis
exec_mode: str
Return value
The name of the current execution mode, as specified in the execution mode decorators. This can be a user-defined value, or can be one of these pre-defined standard values:
xi.ExecMode.LOAD (when a scenario is being loaded),
xi.ExecMode.RUN (when a scenario is being run),
xi.ExecMode.NONE (when the application is being executed outside of Xpress Insight and no execution mode function is currently being executed).
Example
Demonstration of setting the execution mode (test mode only).
>>> insight.exec_mode = 'CALCULATE_STATS'
Demonstration of getting the execution mode then outputting it.
>>> print('execution mode = ', insight.exec_mode) execution mode = CALCULATE_STATS
Further information
1. The
exec_mode property can only be set in test mode.
2. In the
LOAD execution mode function (or other user-defined execution modes with
clear_input=True) your app should initialize its input data. In the
RUN execution mode function (or user-defined execution modes with
clear_input=False) it should then initialize its result data.
3. Used to mock the execution mode that requested the scenario execution, when testing code outside of an Insight scenario. By default,
insight.exec_mode will be initialized automatically if you call an execution mode function. However, if you want to test another function, which is not an execution mode function, then it could make sense to set the
exec_mode property manually.
4. Modifying this property when
insight.test_mode is
False will cause the model to abort with a runtime error.