Commit 23c79fd4 authored by Manuel Günther's avatar Manuel Günther

Added '--name' sub-selection to jman list action; some small bug fixes in status of jobs.

parent def4cfd0
......@@ -167,7 +167,7 @@ class JobManagerLocal(JobManager):
while True:
# Flag that might be set in some rare cases, and that prevents the scheduler to die
repeat_execution = False
# FIRST, try if there are finished processes; this does not need a lock
# FIRST, try if there are finished processes
for task_index in range(len(running_tasks)-1, -1, -1):
task = running_tasks[task_index]
process = task[0]
......@@ -253,4 +253,4 @@ class JobManagerLocal(JobManager):
task[0].kill()
self.stop_job(task[1])
# stop all jobs that are currently running or queued
self.stop_jobs()
self.stop_jobs(job_ids)
......@@ -84,7 +84,7 @@ class JobManager:
q = self.session.query(Job)
if job_ids:
q = q.filter(Job.id.in_(job_ids))
return list(q)
return sorted(list(q), key=lambda job: job.unique)
def _job_and_array(self, job_id, array_id = None):
......@@ -170,7 +170,7 @@ class JobManager:
self.unlock()
def list(self, job_ids, print_array_jobs = False, print_dependencies = False, long = False, status=Status, ids_only=False):
def list(self, job_ids, print_array_jobs = False, print_dependencies = False, long = False, status=Status, names=None, ids_only=False):
"""Lists the jobs currently added to the database."""
# configuration for jobs
if print_dependencies:
......@@ -204,7 +204,7 @@ class JobManager:
self.lock()
for job in self.get_jobs(job_ids):
job.refresh()
if job.status in status:
if job.status in status and names is None or job.name in names:
print(job.format(format, dependency_length, None if long else 43))
if print_array_jobs and job.array:
print(array_delimiter)
......
......@@ -160,7 +160,7 @@ def run_scheduler(args):
def list(args):
"""Lists the jobs in the given database."""
jm = setup(args)
jm.list(job_ids=get_ids(args.job_ids), print_array_jobs=args.print_array_jobs, print_dependencies=args.print_dependencies, status=args.status, long=args.verbose > 1 or args.long, ids_only=args.ids_only)
jm.list(job_ids=get_ids(args.job_ids), print_array_jobs=args.print_array_jobs, print_dependencies=args.print_dependencies, status=args.status, long=args.verbose > 1 or args.long, ids_only=args.ids_only, names=args.names)
def communicate(args):
......@@ -297,6 +297,7 @@ def main(command_line_options = None):
# subcommand 'list'
list_parser = cmdparser.add_parser('list', aliases=['ls'], formatter_class=formatter, help='Lists jobs stored in the database. Use the -vv option to get a long listing.')
list_parser.add_argument('-j', '--job-ids', metavar='ID', nargs='+', help='List only the jobs with the given ids (by default, all jobs are listed)')
list_parser.add_argument('-n', '--names', metavar='NAME', nargs='+', help='List only the jobs with the given names (by default, all jobs are listed)')
list_parser.add_argument('-a', '--print-array-jobs', action='store_true', help='Also list the array ids.')
list_parser.add_argument('-l', '--long', action='store_true', help='Prints additional information about the submitted job.')
list_parser.add_argument('-x', '--print-dependencies', action='store_true', help='Print the dependencies of the jobs as well.')
......
......@@ -109,12 +109,17 @@ class JobManagerSGE(JobManager):
jobs = self.get_jobs(job_ids)
for job in jobs:
job.refresh()
if job.status in ('queued', 'executing'):
if job.status in ('queued', 'executing', 'waiting'):
status = qstat(job.id, context=self.context)
if len(status) == 0:
job.status = 'failure'
job.result = 70 # ASCII: 'F'
logger.warn("The job '%s' was not executed successfully (maybe a time-out happened). Please check the log files." % job)
for array_job in job.array:
if array_job.status in ('queued', 'executing'):
array_job.status = 'failure'
array_job.result = 70 # ASCII: 'F'
self.session.commit()
self.unlock()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment