Categories

Versions

Create a deployment ZIP

This document describes how to create an endpoint that is independent of Altair AI Hub, for example on an edge device. See Install the endpoint infrastructure.

If your endpoint is meant to live on Altair AI Hub, return to Create an endpoint and select this AI Hub, where you will find a simpler workflow.

As discussed previously in Create a process, our purpose is to run the process ScoreIrisData, submitting our input data via the endpoint URL and obtaining the result of the process as output. To do so, we need to create an endpoint, in this case an endpoint that lives outside of Altair AI Hub.

To create or update this endpoint, we need to take four steps:

  1. download a deployment ZIP from Altair AI Hub,
  2. upload the ZIP to the external endpoint infrastructure,
  3. place the ZIP in the deployments folder, and
  4. restart the scoring agent.

This document will cover step 1. A programmatic solution, Use an API to create a deployment ZIP, is given below.

For steps 2., 3., and 4., consult the relevant documentation for your endpoint infrastructure:

Once your deployment ZIP is in place, and the scoring agent has been started / restarted, you are ready to request results!

other device

configure and then download a package to deploy elsewhere

Continuing where we left off (Where do you need an endpoint?), we select other device.

img/other-device.png

The resulting dialog

  • asks for the Base name of your deployment,
  • reminds you that connections cannot contain injected parameters, because your endpoint will have no further connection to Altair AI Hub, and
  • offers the option of running in continuous mode, meaning that the endpoint process will run either continuously or at regular intervals, without any need for an external trigger.

For our Base name, we choose iris. That name will reappear

  • in the name of the deployment ZIP, together with the project name,
  • as the basePath in the file config.json in the deployment ZIP, and
  • as the $deployment_path in the endpoint URL.

img/create-deployment.png

Click Create to create the deployment ZIP, and place the resulting ZIP file in the deployments folder belonging to your endpoint infrastructure. In case of doubt, see the links given in the introduction to this document.

Next: Request results

Use an API to create a deployment ZIP

The API for creating deployment ZIP files has changed from 10.1. to 10.2 to enable the inclusion of arbitrary files within a deployment on other/edge devices.

To trigger deployment creation for an edge device, invoke a POST request via command line, e.g., with the curl command to the following URL:

[POST] https://$RM_SERVER/api/v1/repositories/$PROJECT_ID/deployment/$REF

where

  • $RM_SERVER is the host name of the Server (e.g. localhost:8080)
  • $PROJECT_ID is the lower case ID of your project (e.g. sample-dev)
  • $REF is the reference exposed by the underlying Git (projects rely on Git under the hood), most likely it's master

The POST request's body defines the deployment name, processes of that Project to expose as endpoint and additional files which will be put into the ZIP file as dependencies.

Here's an example of such a request body which creates a deployment ZIP for edge devices from a given Project:

{
  "deploymentName": "example-deployment",
  "processLocations": [
    {
      "path": "myprocess",
      "processLocation": "processes/myprocess.rmp",
      "contextParameters": {
        "macro1": "macro1"
      }
    },
    {
      "path": "anotherprocess",
      "processLocation": "processes/myprocess2.rmp"
    }
  ],
  "additionalLocations": [
    "Connections/test-connection.conninfo",
    "data/My Data.rmhdf5table"
  ],
  "continuous": false,
  "sleep": 1
}
  • The deployment will be named example-deployment, so Scoring Agents will serve endpoints under /api/v1/services/example-deployment/<endpoint path>
  • The processLocations defines the exposed endpoints
    • alias is the name of the exposed endpoint, in the example the following endpoints would be available:
      • /api/v1/services/example-deployment/myprocess
      • /api/v1/services/example-deployment/anotherprocess
    • processLocation is the actual location of the process within the Project, alias doesn't need to match the name of the location itself
    • contextParameters is the optional mapping of input macros transposed to query parameters when defined within the selected process, it can be used to change given macro values by the caller of the endpoint
      • Example for alias myprocess: /api/v1/services/example-deployment/myprocess?macro1=<any input>
      • If the process has no default value for a macro exposed as query parameter, execution will likely fail if the macro is used within the underlying process
  • The additionalLocations property defines any additional data that can be put into the deployment ZIP such as Connections (make sure to not use Connections with injected parameters) or data sets the processes need
  • continuous is an optional flag to allow continuous re-execution while a deployment is enabled on the Scoring Agent
  • sleep is an optional number how long the Scoring Agent will wait before re-executing a deployment, only applies when continuous is enabled

To invoke deployment creation, you need a valid Bearer token. In addition, the token needs to have the admin role or the aihub:projects:deployment-creation role. When including connections the aihub:deployment-creation-connections is required in addition when the requesting token has no admin claim.

The actual curl command of the example would be the following saving the created ZIP file on your disk as file `deployment.zip:

curl "https://$RM_SERVER/api/v1/repositories/$PROJECT_ID/deployment/$REF" \
--header 'Authorization: Bearer <Your Token>' \
--header 'Content-Type: application/json' \
-X POST \
--data '{
  "deploymentName": "example-deployment",
  "processLocations": [
    {
      "path": "myprocess",
      "processLocation": "processes/myprocess.rmp",
      "contextParameters": {
        "macro1": "macro1"
      }
    },
    {
      "path": "anotherprocess",
      "processLocation": "processes/myprocess2.rmp"
    }
  ],
  "additionalLocations": [
    "Connections/test-connection.conninfo",
    "data/My Data.rmhdf5table"
  ],
  "continuous": false,
  "sleep": 1
}' \
-o deployment.zip

If any resource like a process, a data set or a Connection does not exist at the requested location within the Project, the API will return a bad request status code (400).

The Scoring Agent does not support connections with injected parameters. If you include a connection in your deployment ZIP, make sure it does not define any injected parameters.

Enable 'continuous mode' for deployment

You can enable the continuous mode during the download of a deployment by changing the request body's parameter continuous to true. You can also define a delay in milliseconds between each execution by adding the request body's properties sleep=5000 which would delay each execution by 5000 milliseconds. If you omit the sleep parameter a default of 1 milliseconds will be used but only if continuous mode is enabled.