Defining Custom Execution Modes
ExecMode
class.
LOAD
and
RUN
. A model can also define any number of additional custom execution modes, which can offer your app two additional forms of control:
- Executing different model code paths based on the execution mode selected by a user.
- Routing different kinds of Xpress Insight jobs to different worker resources configured on the server.
exec_resource_group_name
(string): The execution resource group to use for this execution mode. The execution resource group defines the resources (threads and memory) that the model should consume when running in this mode. If you do not specify an execution resource group, the execution mode uses theDEFAULT
resource group.preferred_service
(string): The execution service to map this execution mode to when importing the app. If an execution service of this name does not exist on the server, the app is still imported, but no automatic mapping is made to an execution service. If no mapping is specified, the execution mode uses the server's default service.clear_input
(boolean): Specifies whether:- model data should be loaded directly by the model rather than populated from the Insight server into the model.
- after model execution, all Insight input entity data gets populated to Insight from the model.
False
. Set toTrue
forLOAD
, whileRUN
hasclear_input
set toFalse
.descr
(string): A description of the execution mode to help a systems administrator determine the purpose or requirements of the execution mode. Defaults toempty description
.- Deprecated:
threads
(integer): The maximum number of threads that the model should consume when running in this mode. Defaults to unspecified which is interpreted as 1 by the Insight scheduler.Important: This attribute is supported only for backward compatibility with existing apps that have not yet been updated to use execution resource groups. You cannot usethreads
andexec_resource_group_name
in the same model. If your model contains any execution mode definitions that specifyexec_resource_group_name
,threads
is not supported for any execution mode in that model.
For more information about resource-based capacity scheduling, see Scenario Execution and Job Scheduling.
Limiting the Resources Allocated to a Job
The exec_resource_group_name
property specifies an execution resource group, which determines the number of threads and the amount of memory that the model should consume. A job using this execution mode is only scheduled on an execution worker that has the specified resources available; otherwise, the job is queued.
If a thread capacity or memory capacity are configured for the execution worker and the execution service mapping on the
page, the minimum of both are available to the job being executed. Note that multiple execution services can map to the same worker.The execution resource group specified by an execution mode specifies default resources (threads and memory) for the execution mode. However, these defaults can be overridden by an administrator. Your model can query the actual resources available at run time; for more information, see Querying Runtime Resources.
If you do not specify an execution resource group for the execution mode, the DEFAULT
resource group is used. This resource group specifies 1 thread and no memory limit.
threads
property for execution modes, Insight automatically generates an execution resource group (with no memory limit) for each unique thread count found in an execution mode definition. These automatically generated resource groups appear on the
page.
For more information about execution resource groups, see Defining Custom Execution Resource Groups.
Calling a Custom Execution Mode
Code Snippet
Years: xi.types.Index(dtype=xi.integer, alias="Years")
Cities: xi.types.Index(dtype=xi.string, alias="Cities")
InputArrayStr: xi.types.Series(index=['Years', 'Cities'], dtype=xi.string, alias="Input Array Of String")
MixedTable: xi.types.DataFrame(index='Years', columns=[
xi.Column("IntCol", dtype=xi.integer, alias="Input Integer Column"),
xi.Column("StrCol", dtype=xi.string, alias="Input String Column", update_after_execution=True),
xi.Column("ResultCol", dtype=xi.real, alias="Result Real Column", manage=xi.Manage.RESULT)
])
Example Custom Run function
@xi.ExecMode(name="CUSTOM_RUN", descr="Custom run execution mode.", clear_input=False)
def my_custom_run_mode(self):
print('CUSTOM_RUN mode...')
self.MixedTable['ResultCol'] = self.MixedTable.IntCol * 2.0
self.MixedTable.ResultCol.at[2020] = 999999
self.MixedTable.StrCol.at[2018] = 'Updated after CUSTOM_RUN mode'
print('CUSTOM_RUN finished.')
- The name is explicitly stated (
name="CUSTOM_RUN"
) - No execution resource group is specified, so the
DEFAULT
resource group (1 thread and no memory limit) is used. - The
clear_input
parameter (clear_input=False
) allows you to specify whether the custom execution mode behaves like the built-in load or run mode. In this case, it behaves like the built-in run mode. - When it is executed, all inputs are initialized, and all results are extracted and written to the database. Additionally, any Inputs marked as 'update after execution' are also updated—This is normally used when pre-processing data prior to final calculation.
Example Custom Load function
@xi.ExecMode(name="CUSTOM_LOAD", descr="Custom load execution mode.", clear_input=True)
def custom_load(self):
print('CUSTOM_LOAD mode...')
self.load_from_file('series.csv', 'data_frame.csv')
self.MixedTable.StrCol.at[2020] = 'CUSTOM LOAD MODE'
print('CUSTOM_LOAD finished.')
This example behaves the same as a standard load mode, but has an alternative name: CUSTOM_LOAD
.
© 2001-2025 Fair Isaac Corporation. All rights reserved. This documentation is the property of Fair Isaac Corporation (“FICO”). Receipt or possession of this documentation does not convey rights to disclose, reproduce, make derivative works, use, or allow others to use it except solely for internal evaluation purposes to determine whether to purchase a license to the software described in this documentation, or as otherwise set forth in a written software license agreement between you and FICO (or a FICO affiliate). Use of this documentation and the software described in it must conform strictly to the foregoing permitted uses, and no other use is permitted.