def parse_standard_calls(cls, parentid, name, calls) -> List[RunJobModel]: jobs = [] parents: Dict[str, RunJobModel] = {} for c in calls: job = cls.parse_standard_call(parentid, name, c) if job.shard is None: jobs.append(job) else: if job.parent in parents: parents[job.parent].jobs.append(job) else: parents[job.parent] = RunJobModel( submission_id=job.submission_id, run_id=job.run_id, id_=job.parent, parent=parentid, jobs=[job], name=job.name, status=TaskStatus.PROCESSING, ) for parent in parents.values(): parent.start = min(j.start for j in parent.jobs) finishes = [j.finish for j in parent.jobs] if all(f is not None for f in finishes): parent.finish = max(finishes) parent.status = TaskStatus.collapse_states([j.status for j in parent.jobs]) return [*parents.values(), *jobs]
def do_wait(args): wids = args.wid statuses = {} for wid in wids: wm = ConfigManager.get_from_path_or_submission_lazy(wid, readonly=True) Logger.info(f"Waiting for '{wid}' to finish") status = wm.database.get_uncached_status() while not status.is_in_final_state(): sleep(2) status = wm.database.get_uncached_status() statuses[wid] = (wm.submission_id, status) Logger.info( f"Workflow {wid} finished with status: {status.to_string()}") collapsed_status = TaskStatus.collapse_states( [s[1] for s in statuses.values()]) rc = collapsed_status.get_exit_code() Logger.info( f"All workflows finished with collapsed status {collapsed_status.to_string()}, exiting with rc={rc}" ) sys.exit(rc)