Commit 3b086aa2 authored by Manuel Günther's avatar Manuel Günther

Added option to list jobs ids only (useful to automatically add dependencies).

parent 5d175660
......@@ -165,7 +165,7 @@ class JobManager:
self.unlock()
def list(self, job_ids, print_array_jobs = False, print_dependencies = False, long = False, status=Status):
def list(self, job_ids, print_array_jobs = False, print_dependencies = False, long = False, status=Status, ids_only=False):
"""Lists the jobs currently added to the database."""
# configuration for jobs
if print_dependencies:
......@@ -179,6 +179,13 @@ class JobManager:
format = "{0:^%d} {1:^%d} {2:^%d} {3:^%d} {4:<%d}" % lengths
dependency_length = 0
if ids_only:
self.lock()
for job in self.get_jobs():
print(job.id, end=" ")
self.unlock()
return
array_format = "{0:>%d} {1:^%d} {2:^%d}" % lengths[:3]
delimiter = format.format(*['='*k for k in lengths])
array_delimiter = array_format.format(*["-"*k for k in lengths[:3]])
......
......@@ -121,7 +121,7 @@ def run_scheduler(args):
def list(args):
"""Lists the jobs in the given database."""
jm = setup(args)
jm.list(job_ids=args.job_ids, print_array_jobs=args.print_array_jobs, print_dependencies=args.print_dependencies, status=args.status, long=args.verbose > 1)
jm.list(job_ids=args.job_ids, print_array_jobs=args.print_array_jobs, print_dependencies=args.print_dependencies, status=args.status, long=args.verbose > 1, ids_only=args.ids_only)
def communicate(args):
......@@ -253,6 +253,7 @@ def main(command_line_options = None):
list_parser.add_argument('-j', '--job-ids', metavar='ID', nargs='*', type=int, help='List only the jobs with the given ids (by default, all jobs are listed)')
list_parser.add_argument('-a', '--print-array-jobs', action='store_true', help='Report only the jobs with the given array ids. If specified, a single job-id must be given as well.')
list_parser.add_argument('-x', '--print-dependencies', action='store_true', help='Print the dependencies of the jobs as well.')
list_parser.add_argument('-o', '--ids-only', action='store_true', help='Prints ONLY the job ids (so that they can be parsed by automatic scripts).')
list_parser.add_argument('-s', '--status', nargs='+', choices = Status, default = Status, help='Delete only jobs that have the given statuses; by default all jobs are deleted.')
list_parser.set_defaults(func=list)
......
......@@ -9,7 +9,7 @@ if sys.version_info[:2] < (2, 7) or ((3,0) <= sys.version_info[:2] < (3,2)):
setup(
name='gridtk',
version='1.0.3a1',
version='1.0.4a1',
description='SGE Grid and Local Submission and Monitoring Tools for Idiap',
url='https://github.com/idiap/gridtk',
......
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