Skip to content
Snippets Groups Projects
Commit 07a414d5 authored by Manuel Günther's avatar Manuel Günther
Browse files

Local scheduler now returns list of failed job ids.

parent 5b8b8c2d
No related branches found
No related tags found
No related merge requests found
......@@ -169,6 +169,7 @@ class JobManagerLocal(JobManager):
def run_scheduler(self, parallel_jobs = 1, job_ids = None, sleep_time = 0.1, die_when_finished = False, no_log = False, nice = None):
"""Starts the scheduler, which is constantly checking for jobs that should be ran."""
running_tasks = []
finished_tasks = set()
try:
# keep the scheduler alive until every job is finished or the KeyboardInterrupt is caught
......@@ -190,6 +191,7 @@ class JobManagerLocal(JobManager):
result = "%s (%d)" % (job.status, job.result) if job.result is not None else "%s (?)" % job.status
self.unlock()
logger.info("Job '%s' finished execution with result %s" % (self._format_log(job_id, array_id), result))
finished_tasks.add(job_id)
# in any case, remove the job from the list
del running_tasks[task_index]
......@@ -262,3 +264,10 @@ class JobManagerLocal(JobManager):
self.stop_job(task[1])
# stop all jobs that are currently running or queued
self.stop_jobs(job_ids)
# check the result of the jobs that we have run, and return the list of failed jobs
self.lock()
jobs = self.get_jobs(finished_tasks)
failures = [job.unique for job in jobs if job.status != 'success']
self.unlock()
return sorted(failures)
......@@ -180,7 +180,7 @@ class JobManager:
print ("WARNING: Stopped dependent jobs '%s' since this job failed." % str(deps), file=sys.stderr)
except Exception as e:
print ("ERROR: Caught exception '%s'" % e)
print ("ERROR: Caught exception '%s'" % e, file=sys.stderr)
pass
finally:
if hasattr(self, 'session'):
......@@ -240,8 +240,8 @@ class JobManager:
def _write_contents(job):
# Writes the contents of the output and error files to command line
out_file, err_file = job.std_out_file(), job.std_err_file()
logger.info("Contents of output file: '%s'" % out_file)
if output and out_file is not None and os.path.exists(out_file) and os.stat(out_file).st_size > 0:
logger.info("Contents of output file: '%s'" % out_file)
print(open(out_file).read().rstrip())
print("-"*20)
if error and err_file is not None and os.path.exists(err_file) and os.stat(err_file).st_size > 0:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment