-
Notifications
You must be signed in to change notification settings - Fork 1
How to deploy a Solution Run Template Handler
A Run template step handler resource is a Python project which is responsible to handle one of the Simulation life cycle step for a Run Template.
It can be deployed either localy or in a cloud storage.
A Run template step handler is a Python project which must have at least a mandatory main.py
file.
This main.py
file is the entry point of the handler.
You can define too a requirements.txt
file which will be used to install any dependencies for your project.
Your Python module must return a return code of 0 if everyting ran fine or another code in case of issue (by raising an exception for instance).
Apart this predefined settings, you can organize your project as you want.
Each handlers will receive from the platform a numbers of Environment Variables in order to handle data and collaborate with other cloud services.
Please find the list in the page Step Handler Env Vars.
Run templates step handlers must be available in Cosmo Tech project directory under code/run_templates/%CSM_RUN_TEMPLATE_ID%/. Each resource handler as its own directory:
- Parameters handler:
parameters-handler/
- Dataset validator:
validator/
- Pre-Run:
prerun/
- Engine:
engine/
- Post-Run:
postrun/
If the Run Template defined one of this step, it will be automatically triggered by the Cosmo Tech Platform when a Scenario associated to this Run Template is run.
Each time a Run template step handler is modified you must release a new Solution image and register it in the platform.
Default storageType in a Solution.yaml
file is local
but you can force it if you want.
For example for a Parameters handler:
parametersHandlerResource:
storageType: local
You can deploy a Run Template step handler in a Cloud Storage. This has the advantage to allow you to deploy only this resource without deploying the whole Solution.
In order to do so you must create a handler.zip
file of your handler directory with the main.py
file in the root.
Then you need to upload this file in the Cloud Storage container of your Organization with the following Cosmo Tech API endpoint:
/organizations/{organization_id}/solutions/{solution_id}/runtemplates/{run_template_id}/handler/{handler_id}
handler_id
can take one of this values: parameters_handler
,validator
,prerun
,engine
,postrun
Once this is done you can configure the Solution.yaml
manifest to use this resource for an handler and register it.
For example for a Parameters handler:
parametersHandlerResource:
storageType: cloudStorage