Last modified 2025-09-05

Support

Start an AI/ML Training Run (Tutorial)

Abbreviations Key
AIartificial intelligencehphisepy
cpucentral processing unitsIDEintegrated development environment
dirsdirectoriesintinteger
gbgigabytesMLmachine learning
gpugraphics processing unitsSDKsoftware development kit
HISEHuman Immune System Explorerstrstring

At a Glance

This document explains how to use the HISE SDK and a Python script to launch a remote, resource-configurable training job for an AI/ML model. These jobs consume significant resources. Before you begin, make sure you have approval from your manager or project lead to use this SDK, and confirm that you have a large enough quota to accommodate the necessary training runs.

The box below shows the start_training_run() signature, and the method parameters follow. 

SDK Icon

 start_training_run()

hp.start_training_run(
    provider: str = 'ray',
    cpu_count: int = 1,
    gpu_count: int = 0,
    memory_size: int = 10,
    worker_count: int = 0,
    training_job_file_path: str,
    title: str,
    description: str,
    file_set_id: str,
    project: str,
    additional_dirs: list = [],
    additional_files: list = [],
    requirements_file_path: str = None,
    image_id: str = None,
    use_conda: bool = False,
    output_file_size: int = 5,
)
ParameterData typeRequired or optionalDefault
(if any)
Description
providerstringoptional'ray'Compute resource provider or backend for the training run
cpu_countintegeroptional1Number of CPUs allocated to the training job
gpu_countintegeroptional0Number of GPUs allocated to the training job
memory_sizeintegeroptional10Amount of memory (GB) allocated to the training job
worker_countintegeroptional0Number of worker nodes for distributed training
training_job_file_pathstringrequiredNAPath to the training job script
titlestringrequiredNATraining job titile
descriptionstring requiredNATraining job description
file_set_idstringrequiredNAFile set ID used as the training job input
projectstringoptionalProject selected on IDE creationShort name of project that the Ray job cost will be billed under
additional_dirslistoptional[]Additional directories your script requires
additional_fileslistoptional[]Additional files your script requires
requirements_file_pathstringoptionalNonePath to the requirements.in file (to install additional Python packages)
image_idstringoptionalNoneImage ID (e.g., Docker) for the training job
use_condabooleanoptionalFalse (pip)Indicator of whether to use Conda environment for training
output_file_sizeintegeroptional5Estimated output file size (GB)

  Get Help

If you get stuck during a start_training_run() call, refer to the steps of this tutorial. To use the baked-in help in your IDE, try one of the following commands. Still not working? Click Support to file a ticket.

PythonOutput
help(hp.start_training_run)Function signature, list of parameters, class, and a brief description of the method in a compact plain-text format
hp.start_training_run?Method signature, docstring (description), file location, and file type in more readable format
hp.start_training_run??Signature, docstring, file path, a verbose set of metadata, and the source code for the method

Instructions

TIPS

  • Explore the HISE AI/ML dashboard before you start. From the top navigation menu in HISE, choose RESEARCH > AI/ML.

  • In your Python script, include a main() function that handles every step in order—loading your data, training the model, and saving results.

  • Test your script end to end by running it locally with test data.

 Import libraries

To get started, set up your environment to interact with HISE programmatically and access all available SDK functions. For details, see Use Hise SDK Methods.

1. Navigate to HISE, and use your organizational email address to sign in.

2. Open an IDE. For instructions, see Create Your First HISE IDE (Tutorial).

3. Install the HISE SDK if you haven't already done so.

# Use pip to install the SDK
!pip install hisepy

4. To import hisepy, enter the following code into a new cell in your IDE.

# Import the Python SDK to enable programmatic access to HISE functions
import hisepy as hp

 Prepare your script 

1. Prepare your script, as in the following example.

# Ray is a unified open-source framework for scaling AI and Python applications. 
The time module provides various time-related functions. 
The random module provides functions for generating pseudo-random numbers and performing random operations.

import ray
import time
import random

def compute_square(x):
time.sleep(random.uniform(0.5, 1.5)) # Simulate some delay
return x * x

def main():
inputs = list(range(10))

# Launch tasks in a list comprehension
results = [compute_square(x) for x in inputs]

# write some random output
with open("/home/workspace/output/empty.txt", "w") as f:
pass
print("Results:", results)

if __name__ == "__main__":

Note on Ray Integration

When you use Ray, the HISE SDK automatically transforms your script for distributed execution. This allows your compute_square function (and similar tasks) to run in parallel, enabling efficient scaling and faster results. Here's how your script is adapted for Ray:

Transformed app.py for Ray Execution

import ray
import time
import random

# Decorate function so it can run in parallel as a Ray task
@ray.remote
def compute_square(x):
    time.sleep(random.uniform(0.5, 1.5))
    return x * x

def main():
    ray.init()  # Initialize Ray
    
    inputs = list(range(10))
          # Launch distributed Ray tasks
    futures = [compute_square.remote(x) for x in inputs]
    results = ray.get(futures)
    
    with open("/home/workspace/output/empty.txt", "w") as f:
        pass
    print("Results:", results)

if __name__ == "__main__":
    main()

 Call start_training_run()

1. In a new cell in your IDE, call hp.start_training_run() with all required and optional parameters.

hp.start_training_run(
  provider='ray',
  cpu_count=1,
  gpu_count=0,
  memory_size=4,
  worker_count=1,
  training_job_file_path="/home/workspace/app.py",
  title="Training Run Example",
  description="Simplified example of an AI/ML training run.",
  file_set_id="60b4e815-85e6-4aaa-84c2-000b48f5fff5",
  additional_dirs=[],
  additional_files=[]
)

A. If the run is successful, you receive a message similar to this one.

Using default project: aifiDevTest
Ray-conformant code written to: /home/workspace/.artifacts/app.py

B. At the prompts, make any necessary changes to the decorators.

i. Answer the prompts. If you're not sure, choose 2) None.

The following methods now have ray decorators: ['compute_square']. Please select the methods from which you want to remove the Ray decorators
 1) compute_square
 2) None
[1 - 2]
The following methods now have ray decorators: ['compute_square']. Please select the methods whose Ray decorator parameters you want to edit
 1) compute_square
 2) None
[1 - 2] 

ii. You receive a final success notification like this one.

{
'workflowName': 'hise-ray-workflow',
'executionId': '009bfa68-2748-4a71-9056-9c4969935714',
'status': 'ACTIVE',
'message': 'Execution Created',
'trainingJobId': '00000000-0000-0000-0000-000000000000',
'trainingImageId': '00000000-0000-0000-0000-000000000000',
'providerDashboard': 'https://stage.allenimmunology.org/orchestrate/ray/dashboard/workflow/be7327a2-6644-4bbb-8fc8-d94dba2c63eb',
'executionDetails': 'https://console.cloud.google.com/workflows/workflow/us-west1/hise-ray-workflow/execution/be7327a2-6644-4bbb-8fc8-d94dba2c63eb/summary?inv=1&invt=Abx65A&project=stage-pipeline-internal&supportedpurview=project'
}

C. If you encounter any issues, check the error message, and see the following Troubleshooting tips.

 TROUBLESHOOTING

  • Do not list hisepy in your requirements.in file. It’s a platform SDK and should not be managed as a dependency.

  • Use the correct, full path to your script and requirements files—use /private/your-folder/app.py if running outside that folder, or just app.py if running from within.

  • Ensure you enter a valid file_set_id (UUID) in the SDK call. Using a placeholder or short string will cause an “Invalid UUID length” error. For details, see Save Your Input File or File Set to a Study (Tutorial).

  • If you see a "No matching distribution found" or "Could not find a version" error, check your requirements.in for typos or packages that aren’t available on PyPI.

  • If you get a permissions error, make sure your script and data are located in an allowed, writable directory (such as /private).

 Monitor your run

1. To watch your job start, view logs, iterate on your script, and track progress, go to RESEARCH > AI/MLTraining Runs, and click View Details. To see the most recent runs, sort by date.  For details, see Review an AI/ML Training Run (Tutorial).


Related Resources

Review an AI/ML Training Run (Tutorial)

Navigate the AI/ML Hub

Submit a Help Ticket