Skip to main content

Launch algorithms with python

To launch an algorithm using python (rather than through the web interface:

import tator
import time
api = tator.get_api(host='https://cloud.tator.io', token=MY_TOKEN)
medias = api.get_media_list(project=PROJECT_ID) # Add other filters here to select media
media_ids = [media.id for media in medias]
spec = tator.models.AlgorithmLaunchSpec(algorithm_name='RetinaNet', media_ids=media_ids)
response = api.algorithm_launch(project=PROJECT_ID, algorithm_launch_spec=spec)

# Check the job status (optional)
job_ids = response.uid
job_group = response.gid

# You can query jobs by unique ID
while True:
for job_id in job_ids:
job = api.get_job(job_id)
print(f"Status of job {job_id}: {job.status}")
print("-----------------------")
time.sleep(10)

# Or you can query jobs by group ID
while True:
jobs = api.get_job_list(PROJECT_ID, gid=job_group)
for job in jobs:
print(f"Status of job {job.uid}: {job.status}")
print("-----------------------")
time.sleep(10)