Returns True if all tasks were successfully finished
(self, jobs: Sequence[SubmittedJob], raise_on_error=True)
| 87 | return SubmittedJob(job=job, id=job_id) |
| 88 | |
| 89 | def wait_for_jobs(self, jobs: Sequence[SubmittedJob], raise_on_error=True) -> bool: |
| 90 | """Returns True if all tasks were successfully finished""" |
| 91 | |
| 92 | job_ids = tuple(job.id for job in jobs) |
| 93 | job_ids_str = ",".join(str(id) for id in job_ids) |
| 94 | if len(jobs) > 1: |
| 95 | job_ids_str = "{" + job_ids_str + "}" |
| 96 | logging.info(f"Waiting for {pluralize('job', len(jobs))} {job_ids_str} to finish") |
| 97 | |
| 98 | callback = create_progress_callback() |
| 99 | |
| 100 | failed_jobs = self.connection.wait_for_jobs(job_ids, callback) |
| 101 | if failed_jobs and raise_on_error: |
| 102 | failed_tasks = self.connection.get_failed_tasks(failed_jobs) |
| 103 | job_map = {job.id: job.job for job in jobs} |
| 104 | raise FailedJobsException(failed_tasks, job_map) |
| 105 | return len(failed_jobs) == 0 |
| 106 | |
| 107 | def get_failed_tasks(self, job: SubmittedJob) -> Dict[TaskId, FailedTaskContext]: |
| 108 | result = self.connection.get_failed_tasks([job.id]) |