Skip to content

Commit

Permalink
Implemented automatic deletion of jobs when run using the --parallel …
Browse files Browse the repository at this point in the history
…option
  • Loading branch information
siebenkopf committed Dec 18, 2015
1 parent 4700cf8 commit 2f1d1a9
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
6 changes: 5 additions & 1 deletion bob/bio/base/test/test_scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ def _verify(parameters, test_dir, sub_dir, ref_modifier="", score_modifier=('sco
# assert that the values are OK
assert numpy.allclose(d[0][:,3].astype(float), d[1][:,3].astype(float), 1e-5)

assert not os.path.exists(os.path.join(test_dir, 'submitted.sql3'))

finally:
shutil.rmtree(test_dir)

Expand Down Expand Up @@ -133,7 +135,9 @@ def test_verify_parallel():
'-vs', 'test_parallel',
'--temp-directory', test_dir,
'--result-directory', test_dir,
'-g', 'bob.bio.base.grid.Grid(grid_type = "local", number_of_parallel_processes = 2, scheduler_sleep_time = 0.1)', '-G', test_database, '--run-local-scheduler', '--stop-on-failure',
'-g', 'bob.bio.base.grid.Grid(grid_type = "local", number_of_parallel_processes = 2, scheduler_sleep_time = 0.1)',
'-G', test_database, '--run-local-scheduler', '--stop-on-failure',
'-D', 'success',
'--import', 'bob.io.image'
]

Expand Down
2 changes: 2 additions & 0 deletions bob/bio/base/tools/command_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ def command_line_parser(description=__doc__, exclude_resources_from=[]):
help = 'Starts the local scheduler after submitting the jobs to the local queue (by default, local jobs must be started by hand, e.g., using ./bin/jman --local -vv run-scheduler -x)')
flag_group.add_argument('-N', '--nice', type=int, default=10,
help = 'Runs the local scheduler with the given nice value')
flag_group.add_argument('-D', '--delete-jobs-finished-with-status', choices = ('all', 'failure', 'success'),
help = 'If selected, local scheduler jobs that finished with the given status are deleted from the --gridtk-database-file; otherwise the jobs remain in the database')
flag_group.add_argument('-c', '--calibrate-scores', action='store_true',
help = 'Performs score calibration after the scores are computed.')
flag_group.add_argument('-z', '--zt-norm', action='store_true',
Expand Down
6 changes: 6 additions & 0 deletions bob/bio/base/tools/grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,9 @@ def execute_local(self):
if failures:
logger.error("The jobs with the following IDS did not finish successfully: '%s'.", ', '.join([str(f) for f in failures]))
self.job_manager.report(job_ids = failures[:1], output=False)

# delete the jobs that we have added
if self.args.delete_jobs_finished_with_status is not None:
logger.info("Deleting jman jobs that we have added")
status = ('success', 'failure') if self.args.delete_jobs_finished_with_status == 'all' else (self.args.delete_jobs_finished_with_status,)
self.job_manager.delete(job_ids=self.submitted_job_ids, status=status)

0 comments on commit 2f1d1a9

Please sign in to comment.