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 completefor job in jobs: assert job.get_state() == JobStates.completedA 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 completeOther available methods:
Section titled “Other available methods:”incomplete_job_count()-> returns a count of incomplete jobs in the groupjobs_with_error()-> returns a list of jobs from the group that completed with errorremove(job_name: str)-> removes all jobs from the group whose name matches the provided nameclear()-> removes all jobs from the groupget_jobs()-> returns the list of jobs in the group