Creating a base software specification for the custom image
After you create, register, and upload a custom image, you must create a custom software specification and runtime definition file to use the libraries and packages that you specified in the custom Watson Machine Learning image.
Follow these steps to create the software specification and runtime definition file. In the example steps, you use the Watson Machine Learning API to upload the files to the required paths in the specified volume.
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.
-
Use the
/v2/software_specifications
endpoint with theBasic ${TOKEN}
to create the custom Software specification. The token can be extracted fromwdp-service-id
as show by the following code sample:TOKEN=$(oc extract secret/wdp-service-id -n ${PROJECT_CPD_INST_OPERANDS} --keys=service-id-credentials --to=-)
-
Upload the custom software specification. Set the parameter values as follows:
- Set
built_in
tofalse
. - Set
type
tobase
. - Set
name
to the software specification name. - You can include extra packages under
package_extensions
. However, this array is informational; no validation is done. - Set platform
name
to the required platform. Supported platform names arepython
,spark
, andspss
. - Set platform
version
to the correct version of the image. Supported values are: for SPSS:18.2
; for Spark:3.3
; for Python: it must be the same as the Python version of the base image, for example,3.11
.
The following example shows how to create metadata:
SW_SPEC_NAME='ci-sw_spec' DISPLAY_NAME='test custom image' SW_SPEC_JSON=$(pwd)/${SW_SPEC_NAME}.json echo $SW_SPEC_JSON
echo '{ "name": "'"$SW_SPEC_NAME"'", "description": "'"$DESCRIPTION"'", "type": "base", "built_in": false, "package_extensions": [], "display_name": "'"$DISPLAY_NAME"'", "software_configuration": { "included_packages": [], "platform": { "name": "python", "version": "3.10" } } }' | jq . > $SW_SPEC_JSON
cat $SW_SPEC_JSON
Output sample:
{ "name": "ci-sw_spec", "description": "test custom image", "type": "base", "built_in": false, "package_extensions": [], "display_name": "test custom image", "software_configuration": { "included_packages": [], "platform": { "name": "python", "version": "3.10" } } }
- Set
-
Upload the new software specification.
curl -ksS -X POST \ $CPD_URL/v2/software_specifications \ -H "Authorization: Basic ${TOKEN}" \ -H "Content-Type: application/json" \ -d @"$SW_SPEC_JSON"
This returns the following output sample:
{"metadata":{"created_at":"2024-07-19T13:05:59.074Z","name":"ci-sw_spec","description":"test custom image","asset_type":"software_specification","asset_id":"0067eda0-cb32-4c08-9a5c-40c80ef719d7","href":"/v2/software_specifications/0067eda0-cb32-4c08-9a5c-40c80ef719d7"},"entity":{"software_specification":{"type":"base","built_in":false,"display_name":"test custom image","package_extensions":[],"software_configuration":{"included_packages":[],"platform":{"name":"python","version":"3.10"}}}}}
-
Confirm that the software specification is available from a REST endpoint.
Use the following code snippet to check whether the software specification is available:
curl -ksS -X GET \ $CPD_URL/v2/software_specifications?name=$SW_SPEC_NAME \ -H "Authorization: Basic ${TOKEN}" | jq "."
This returns the following output sample:
{ "total_results": 1, "resources": [ { "metadata": { "created_at": "2024-07-19T13:05:59.074Z", "name": "ci-sw_spec", "description": "test custom image", "asset_type": "software_specification", "asset_id": "0067eda0-cb32-4c08-9a5c-40c80ef719d7", "href": "/v2/software_specifications/0067eda0-cb32-4c08-9a5c-40c80ef719d7" }, "entity": { "software_specification": { "type": "base", "built_in": false, "display_name": "test custom image", "package_extensions": [], "software_configuration": { "included_packages": [], "platform": { "name": "python", "version": "3.10" } } } } } ] }
Next steps
Uploading the changed configuration
Parent topic: Customizing deployment runtime images