Commit 55e8f91f authored by Amir MOHAMMADI's avatar Amir MOHAMMADI

Accept a plus sign for specifying the job ranges

parent 8ee43071
Pipeline #21972 passed with stage
in 8 minutes and 56 seconds
...@@ -171,10 +171,12 @@ which will list only the jobs of the given job id(s): ...@@ -171,10 +171,12 @@ which will list only the jobs of the given job id(s):
$ jman -vv list -a -j [job_id_1] [job_id_2] $ jman -vv list -a -j [job_id_1] [job_id_2]
Note that the ``-j`` option is in general relatively smart. You can use it to Note that the ``-j`` option is in general relatively smart. You can use it to
select a range of job ids, e.g., ``-j 1-4 6-8``. In this case, please assert select a range of job ids, e.g., ``-j 1-4 6-8 10+2`` is the same as
that there are no spaces between job ids and the ``-`` separator. If any job ``-j 1 2 3 4 6 7 8 10 11 12``. In this case, please assert that there are no
id is specified, which is not available in the database, it will simply be spaces between job ids and the ``-`` and ``+`` separators. You cannot use both
ignored, including job ids that in the ranges. ``-`` and ``+`` in one part, i.e., something like ``-j 1-4+2`` will not work.
If any job id is specified, which is not available in the database, it will
simply be ignored, including job ids that are in the ranges.
Since version 1.3.0, GridTK also saves timing information about jobs, i.e., Since version 1.3.0, GridTK also saves timing information about jobs, i.e.,
time stamps when jobs were submitted, started and finished. You can use the time stamps when jobs were submitted, started and finished. You can use the
......
...@@ -80,15 +80,18 @@ def get_ids(jobs): ...@@ -80,15 +80,18 @@ def get_ids(jobs):
return None return None
indexes = [] indexes = []
for job in jobs: for job in jobs:
# check if a range is specified if '-' not in job and '+' not in job:
separator = job.find('-')
if separator == -1:
index = int(job) index = int(job)
indexes.append(index) indexes.append(index)
else: # check if a range is specified
first = int(job[0:separator]) elif '-' in job and '+' not in job:
last = int(job[separator+1:]) first, last = job.split('-', 1)
indexes.extend(range(first, last+1)) indexes.extend(range(int(first), int(last) + 1))
# check if a plus sign is specified
elif '+' in job and '-' not in job:
first, add = job.split('+', 1)
first, add = int(first), int(add)
indexes.extend(range(first, first + add + 1))
return indexes return indexes
......
...@@ -117,7 +117,7 @@ class GridTKTest(unittest.TestCase): ...@@ -117,7 +117,7 @@ class GridTKTest(unittest.TestCase):
self.scheduler_job = subprocess.Popen([self.jman, '--local', '--database', self.database, 'run-scheduler', '--sleep-time', '5', '--parallel', '2']) self.scheduler_job = subprocess.Popen([self.jman, '--local', '--database', self.database, 'run-scheduler', '--sleep-time', '5', '--parallel', '2'])
# sleep some time to assure that the scheduler was able to start the first job # sleep some time to assure that the scheduler was able to start the first job
time.sleep(4) time.sleep(5)
# ... and kill the scheduler # ... and kill the scheduler
self.scheduler_job.kill() self.scheduler_job.kill()
self.scheduler_job = None self.scheduler_job = None
...@@ -153,7 +153,7 @@ class GridTKTest(unittest.TestCase): ...@@ -153,7 +153,7 @@ class GridTKTest(unittest.TestCase):
self.scheduler_job = subprocess.Popen([self.jman, '--local', '--database', self.database, 'run-scheduler', '--sleep-time', '5', '--parallel', '2']) self.scheduler_job = subprocess.Popen([self.jman, '--local', '--database', self.database, 'run-scheduler', '--sleep-time', '5', '--parallel', '2'])
# sleep some time to assure that the scheduler was able to finish the first and start the second job # sleep some time to assure that the scheduler was able to finish the first and start the second job
time.sleep(9) time.sleep(10)
# ... and kill the scheduler # ... and kill the scheduler
self.scheduler_job.kill() self.scheduler_job.kill()
self.scheduler_job = None self.scheduler_job = None
...@@ -246,7 +246,7 @@ class GridTKTest(unittest.TestCase): ...@@ -246,7 +246,7 @@ class GridTKTest(unittest.TestCase):
jman.main([self.jman, '--database', self.database, 'report']) jman.main([self.jman, '--database', self.database, 'report'])
# clean-up # clean-up
jman.main([self.jman, '--local', '--database', self.database, 'delete', '--job-ids', '1-5']) jman.main([self.jman, '--local', '--database', self.database, 'delete', '--job-ids', '1+4'])
# check that the database and the log files are gone # check that the database and the log files are gone
self.assertEqual(len(os.listdir(self.temp_dir)), 0) self.assertEqual(len(os.listdir(self.temp_dir)), 0)
......
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