Uploading the changed configuration
Create a runtime definition file to map the custom software specification that you defined to the custom Watson Machine Learning image that you created on the Cloud Pak for Data cluster.
Some of the scripting commands provided here use jq
, an open source tool that is also known as JSON processor to help in formatting JSON files in a shell terminal.
-
Get the required API authorization token and save the token in the
MY_TOKEN
environment variable.export MY_TOKEN=<base64-encoded-user-api-pair>
For more information, see Generating an API authorization token.
-
Using the download runtime definition JSON
${myRuntimeDefinition}-server.json
as a template, create a new runtime definition for the custom image and copy it to the software specification JSON file$SW_SPEC_NAME-server.json
.For example, use the following code sample to create a new runtime definition and copy it to the software specification file:
Tip:Add
-server.json
followed by your custom image and software specification name.cp ${myRuntimeDefinition}-server.json $SW_SPEC_NAME-server.json
-
Update your parameters to get the runtime definition for your custom image by using
runtime_definition_template
withGET v2/runtime_definitions
.Follow these instructions to set the parameters of your new JSON file:
- Enter a name for your parameter in
.name
.Tip:To follow naming convention, keep the runtime definition name (value of the
name
parameter) same as the name of the software specification for your custom image. - Enter a short
.display_name
for your parameter. - Provide a brief
.description
for your parameter. - Set the value of
.runtime_type
to wml. - Enter the custom images software specification name in
.launch_configuration.software_specification_name
. - Enter the full registry path for your custom image in
.launch_configuration.image
. For more information, see Pushing the image to the registry.
Important:The
CUSTOM_IMAGE
parameter must be set to the required custom image with the full registry path of the private registry.You can use
jq
to update these fields.The following code snippet shows how to use
jq
to set the required parameters:jq --arg rdname "$SW_SPEC_NAME" \ --arg description "The description" \ --arg runtime_type "wml" \ --arg sw_spec_name "$SW_SPEC_NAME" \ --arg image "$CUSTOM_IMAGE" \ '.name = $rdname | .display_name = $rdname | .runtime_type = $runtime_type | .launch_configuration.software_specification_name = $sw_spec_name | .launch_configuration.image = $image' \ ${myRuntimeDefinition}-server.json > $SW_SPEC_NAME-server.json
You must make sure that the custom runtime definition JSON file is proper:
cat $SW_SPEC_NAME-server.json | jq "."
- Enter a name for your parameter in
-
Upload the runtime definition for your custom image by using
POST /v2/runtime_definitions
: For example, use the following code sample to upload your runtime definition:curl -ksS -X POST "$CPD_URL/v2/runtime_definitions" \ -H 'Content-Type: application/json' \ -H "Authorization: ZenApiKey ${MY_TOKEN}" \ -d @"$SW_SPEC_NAME-server.json" | jq "."
This code sample returns the following output:
{ "metadata": { "guid": "8112892c-38e0-5c15-82d3-0da9d5b2e793", "created_at": "2023-11-10T06:38:49.383Z" }, "entity": { "name": "ci-sw_spec", "display_name": "ci-sw_spec", "description": "Runtime definition for IBM Runtime 23.1 on Python 3.10 ", "author": "IBM", "tested": true, "is_service": true, "built_in": false, "features": [ "wml" ], "runtime_type": "wml", "software_configuration": {} } }
-
Check whether the new runtime definition is available in the REST endpoint by using GET /v2/runtime_definitions.
For example, use the following code sample to check whether new runtime definition is available:
curl -ksS -H "Authorization: ZenApiKey ${MY_TOKEN}" \ -X GET $CPD_URL/v2/runtime_definitions | jq ".resources[] | select(.entity.name == \"$SW_SPEC_NAME\")"
This code snippet returns the following output:
{ "metadata": { "guid": "8112892c-38e0-5c15-82d3-0da9d5b2e793", "created_at": "2023-11-10T06:38:49.383Z" }, "entity": { "name": "ci-sw_spec", "display_name": "ci-sw_spec", "description": "Runtime definition for IBM Runtime 23.1 on Python 3.10 ", "author": "IBM", "tested": true, "is_service": true, "built_in": false, "features": [ "wml" ], "runtime_type": "wml", "software_configuration": {} } }
You can now use the custom runtime and software specification in your deployments.
Next steps
Save the trained model that you want to deploy with the custom image to the Watson Machine Learning repository for the custom image.
Parent topic: Customizing deployment runtime images