CLI-driven Workflow
In this document, we will cover the common tasks involved in building a machine learning model and guide how you can use our CLI commands to accomplish these tasks:
Build a baseline machine learning model with Experiments.
Optimize hyperparameters using Sweep.
Update and store models on Model registry.
Here, we will use the MNIST database to create an image classification model. All our CLI commands are one-liners but you can also select from command option prompts.
Requirements
To follow this guide, you should first have the following setup.
Organization — a dedicated organization for you or your team
Project — a space for your machine learning model and mounted datasets
VESSL Client — Python SDK and CLI to manage ML workflows and resources on VESSL
If you have not created an Organization or a Project, first follow the instructions on the end-to-end guides.
1. Experiment — Build a baseline model
1-1. Configure your default organization and project
Let's start by configuring the client with the default organization and project we have created earlier. This is done by executing vessl configure
.
vessl configure \
--organization "YOUR_ORGANIZATION_NAME" \
--project "YOUR_PROJECT_NAME"

You also can check and re-configure your default organization and project by specifying options after vessl configure
.
vessl configure list # check your current default organization and project
vessl configure --renew-token # renew access token and default account
vessl configure organization # change your default organization
vessl configure project # change your default project
1-2. Create and mount a dataset
To create a dataset on VESSL, run vessl dataset create
. Let's create a dataset from the public AWS S3 dataset we have prepared: s3://savvihub-public-apne2/mnist
. You can check that your dataset was created successfully by clicking the output link.
vessl dataset create "vessl-mnist" \
--is-public --external-path "s3://savvihub-public-apne2/mnist"

1-3. Create a machine learning experiment
To create an experiment, use vessl experiment create
. Let's run an experiment using VESSL's managed clusters. First, specify the cluster and resources options. Then, specify the image URL — in this case, we are pulling a Docker image from VESSL's Amazon ECR Public Gallery. Next, we are going to mount the dataset we have created previously. Finally, let's specify the start command that will be executed in the experiment container. Here, we will use the MNIST Keras example from our GitHub repository.
vessl experiment create \
--cluster "aws-apne2-prod1" \
--resource "v1.cpu-4.mem-13" \
--image-url "public.ecr.aws/vessl/kernels:py36.full-cpu" \
--dataset "/input:vessl-mnist"\
--command "git clone https://github.com/vessl-ai/examples.git && pip install -r examples/mnist/keras/requirements.txt && python examples/mnist/keras/main.py --save-model --save-image"

Note that you can also integrate a GitHub repository with your project so you don't have to git clone
every time you create an experiment. For more information about these features, please refer to our doc's project repository & project dataset page.
1-4. View experiment results
The experiment may take a few minutes to complete. You can get the details of the experiment, including its status, using vessl experiment read
or by clicking the output link.
vessl experiment read "YOUR_EXPERIMENT_NAME"

1-5. Create a model
In VESSL, you can create a model from a completed experiment. First, let's start by creating a model repository using vessl model-repository create
and specifying the repository name.
vessl model-repository create "tutorial-mnist"

Then, let's get a list of experiments in the project and their experiment ID.
vessl experiment list

Finally, run vessl model create
with options including the destination repository and experiment ID. Make sure that the option value for --experiment-id
is an integer, not a string.
vessl model create "tutorial-mnist" \
--model-name "v0.0.1" \
--source "experiment" \
--experiment-id YOUR_EXPERIMENT_ID

You can see that the model has been created successfully by specifying the repository name and selecting the model number.
vessl model read "tutorial-mnist"

You can get a list of model repositories and models you have created inside the project by using the following commands.
vessl model-repository list # get a list of model repositories
vessl model list # get a list of models
2. Sweep — Optimize hyperparameters
So far, we ran a single machine learning experiment and saved it as a model inside a model repository. In this section, we will use a sweep to find the optimal hyperparameter value. First copy and paste the following command and while the sweep is running we will explain each options.
vessl sweep create \
--objective-type "maximize" \
--objective-goal "0.99" \
--objective-metric "val_accuracy" \
--num-experiments 4 --num-parallel 2 --num-failed 2 \
--parameter "optimizer categorical list adam sgd adadelta" \
--parameter "batch_size int space 64 256 8" \
--algorithm random \
--cluster "aws-apne2-prod1" \
--resource "v1.cpu-4.mem-13" \
--image-url "public.ecr.aws/vessl/kernels:py36.full-cpu" \
--dataset "/input:vessl-mnist" \
--command "git clone https://github.com/vessl-ai/examples.git && pip install -r examples/mnist/keras/requirements.txt && python examples/mnist/keras/main.py --save-model --save-image"
The first part of the command defines the key objective and number of experiments.
--objective-type
— target object (either to minimize or maximize the metric)--objective-goal
— target metric name as defined and logged usingvessl.log()
--objective-metric
— target metric value--num-experiments
— total number of experiments--num-parallel
— the number of experiments to run in parallel--num-failed
— the number of failed experiments before the sweep terminates
Next, we specified the details of the parameters and which algorithm to use. In this example, the optimizer
is a categorical
type and the option values are listed as an array. The batch_size
is an int value and the search space
is set using max, min, and step.
The command is then followed by cluster, resource, image, dataset, and command options, similar to the vessl experiment create
explained above.
You may find it easier to run vessl sweep create
and specify the options through command prompts. For more information on sweep, refer to our sweep documentation.

3. Model Registry — Update and store the best model
Now that we ran multiple experiments using a sweep, let's find the optimal experiment. vessl sweep best-experiment
returns the experiment information with the best specified metric value. In this example, the command will return the details of the experiment with the maximum val_accuracy
.
vessl sweep best-experiment "grove-scowl"

Let's create a v0.0.2
model with vessl model create
from the output of the best sweep experiment. You can get the experiment ID using the vessl experiment read
command.
vessl model create "tutorial-mnist" \
--model-name "v0.0.2" \
--source "experiment" \
--experiment-id 8589948240
Finally, you can view the performance of your model by using vessl model read
and specifying the model repository, followed by the model number.
vessl model read "tutorial-mnist" "2"

We covered the overall workflow of VESSL using the client CLI. We can also repeat the same process using the client SDK or through Web UI. Now, try this guide with your own code and dataset.
Last updated