In this guide, we’ll deploy a Job to train a machine learning model. The model will learn to predict the species of an iris flower based on its sepal length, sepal width, petal length, and petal width. There are three species: Iris setosa, Iris versicolor, and Iris virginica.

The model has 4 inputs: sepal length, sepal width, petal length, and petal width and ouputs the confidence scores for each species in the following format:

{
  "predictions": [
    {
      "label": "setosa",
      "score": 2.1184377821359003e-16
    },
    {
      "label": "versicolor",
      "score": 3.264647319023382e-9
    },
    {
      "label": "virginica",
      "score": 0.9999999967353526
    }
  ]
}

We’ve already created a Training script that trains a model on the Iris dataset, and you can find the code in our GitHub Repository.

Please visit the repository to familiarise yourself with the code you’ll be deploying. The project files are organized as follows:

Directory Structure
.
├── train.py - Contains the training script code.
└── requirements.txt - Contains the list of all dependencies.

Getting Started With Deployment

To deploy a job, you’ll need a workspace. If you don’t have one, you can create it using this guide: Creating a Workspace or seek assistance from your cluster administrator in case you don’t have permission to create a workspace.

In TrueFoundry, you can either deploy code from your Github repository or from your local machine in case the code is not pushed to a Github repository.

In the above walkthrough, we did the following steps:

  1. Select a workspace to deploy the job. This basically decides which cluster and environment the job will be deployed to.
  2. Select the Job option since this is a job.
  3. We chose the Github option since the code is already pushed to a Github repository.

The key fields that we need to fill up in the deployment form are:

  1. Repo Url: This is the URL of the Github repository that contains the code for the job. For this example, the repo url is https://github.com/truefoundry/getting-started-examples
  2. Path to build context: This is the path to the directory in the Github repository that contains the code for the job. For this example, the path to the build context is ./train-model/
  3. Command: This is the command to run the job. For this example, the command is python train.py

On filling up the form, we can press the Submit button to deploy the job.

View your deployed job

Congratulations! You’ve successfully deployed your job.

Once you click Submit, your deployment will be successful in a few seconds, and your job will be displayed as Suspended, indicating that it’s successfully deployed but not running.

You can view all the information about your job following the steps below:

Run your job

To run your Job you will have to trigger it manually. You can trigger it by clicking the Run button on the dashboard or programatically

FAQ