Create a model using the CLI
Follow the instructions on how to create models using the model CLI.
- Open a terminal window and log into cdswctl.
-
Obtain the project ID as described in the following steps:
-
Run the following command:
cdswctl projects list
The project ID, your username, and the project name are displayed. For example:1: john-smith/petal-length-predictor -
Note the project ID, which is a number in front of your project
name.
In this case, it is "1".
-
Run the following command:
-
Run the following command while specifying the project name and note the engine
image ID:
For projects configured to use legacy engines:
cdswctl engine-images list -p <project-name>
For example,cdswctl engine-images list -p john-smith/petal-length-predictor
For projects configured to use runtimes:cdswctl runtimes list
Depending on your local setup, you may get a more readable output by post-processing the result with the following command:
cdswctl runtimes list | python3 -m json.tool
For this example you should pick a runtime with a Python kernel and Workbench editor. Depending on your local setup, you may filter the results using the following command:cdswctl runtimes list | jq '.runtimes[] | select((.editor == "Workbench") and (.kernel | contains("Python")))'
-
Create a model by using the following command:
For projects configured to use legacy engines:
cdswctl models create --kernel="python3" --targetFilePath="predict.py" --targetFunctionName="predict" --name="Petal Length Predictor" --cpuMillicores=1000 --memoryMb=2000 --description="Model of the Iris dataset" --replicationType=fixed --numReplicas=1 --visibility="private" --autoBuildModel --autoDeployModel --projectId=<project ID> --examples='{"request":{"petal_length":1}}' --engineImageId=<engine image ID from before>
For projects configured to use runtimes:cdswctl models create --targetFilePath="predict.py" --targetFunctionName="predict" --name="Petal Length Predictor" --cpuMillicores=1000 --memoryMb=2000 --description="Model of the Iris dataset" --replicationType=fixed --numReplicas=1 --visibility="private" --autoBuildModel --autoDeployModel --projectId=<project ID> --examples='{"request":{"petal_length":1}}' --runtimeId=<runtime ID obtained above>
If the command runs successfully, the system displays the model details in a JSON format. -
For more information about the
models create
command parameters, run the following command:cdswctl models create --help