Job Trigger Calculations
You can execute an engine from within the model calculation logic. The binding variable model
provides access to the ModelFormulaCalculationContext API which allows you to call the engine – i.e. start a Job Trigger Calculation.
Enabling a Job Trigger Calculation Image
In order to run a given engine/image, you need to have the image enabled on your partition, with a sufficient number of CPUs and enough memory. The most convenient way to request a new engine is via PlatformManager where you can specify the engine type and requested parameters.
This step is not needed for some of the accelerators because they already automatically configure job trigger. Still, the process in PlatformManager can be handy if you need to e.g. increase the allocated resources.
In case of issues or special requests, contact Pricefx Support.
Running a Job Trigger Calculation
Each image/engine accepts dedicated parameters which you supply in the method call startJobTriggerCalculation.
A model Step executing the calculation that starts a new Job Trigger Calculation will be considered as finished only when calculations, formula and Job Trigger are all finished. In terms of execution order, this follows the same rules as sequence calculations.
Example
Model class definition:
{
"uniqueName": "Job_Trigger_Calc_Sample",
"definition": {
"calculations": [
{
"name": "run-jtc",
"type": "formula",
"formulaName": "Job_Trigger_Calc"
}
],
"steps": [
{
"name": "step1",
"label": "Step 1",
"calculation": "run-jtc"
}
]
}
}
Model calculation logic Job_Trigger_Calc (of Nature model_calculation
):
model.startJobTriggerCalculation(
"cregistry.pricefx.eu/engineering/pricefx-optimization-engine", // name of the engine image
"latest", // tag of the engine image
api.jsonEncode([
// parameters required by the engine image
]),
"oe" // a name for the job, unique for this calculation and step
)
Parameters Size Limitation
Due to the way parameters
are passed to the engine, its size is limited by maximum length of the environment variable in the OS. Job Trigger won't accept parameters longer than 131000 bytes
by default, and will throw an exception. To pass large amount of data into calculation, store it in a table and fetch them in a script. (see: ARG_MAX limit)
Calculation Process Sequence
In a Model Object, when the user calculates the first step, this is what happens:
A new calculation and its corresponding Job Status Tracker is created with the calculation context
step1 / run-jtc
.The step is considered as started from the Model Object’s point of view.
The model calculation logic runs in the Pricefx cluster as usual.
At the end, a new calculation and its corresponding Job Status Tracker is created with the calculation context
step1 / run-jtc:oe
.Note, that if multiple Job Trigger Calculations are started in the same model calculation logic, they will be executed concurrently.
The calculation description is sent to the Job Trigger Service, that:
Verifies the Pricefx partition has the authorization to run this image.
Knows how much resources must be allocated for the execution.
Executes the Docker image with the provided parameters.
The image can communicate with the Pricefx cluster with the same level of security clearance as the user who started the calculation.
Monitors the job and report its progress to the Job Status Tracker.
At the end sends back the terminal status logs to the Pricefx cluster logs.
The step is considered as finished from the Model Object’s point of view.
Found an issue in documentation? Write to us.