Skip to content

Job groups

Job groups provide an easy interface to execute multiple jobs and wait for their completion. While sub jobs provide some of these capabilities, job groups allow for finer control, as well as running job groups outside an existing job.

job1 = (...)
job2 = (...)
jobs = [job1, job2]
(JobGroup(client) # initialize JobGroup
.add_jobs(jobs) # add jobs to the group
.start_all() # start all jobs in the group
.wait_all()) # wait for all of them to complete
for job in jobs:
assert job.get_state() == JobStates.completed

A JobGroup can also be initialized from a JobQueryResult object using the from_query_result() method. As an example, you could search for all jobs with a given tag, and wait for those jobs to finish. For more information, see here.

(JobGroup
.from_query_result(client, jobs) # initialize JobGroup using a JobQueryResult
.start_all() # start all jobs in the group
.wait_all()) # wait for all of them to complete
  • incomplete_job_count() -> returns a count of incomplete jobs in the group
  • jobs_with_error() -> returns a list of jobs from the group that completed with error
  • remove(job_name: str) -> removes all jobs from the group whose name matches the provided name
  • clear() -> removes all jobs from the group
  • get_jobs() -> returns the list of jobs in the group