Commit 0b032425 authored by Amir MOHAMMADI's avatar Amir MOHAMMADI

Do not delete the logs of the jobs that are not resubmitted

parent 7d2916aa
Pipeline #27366 passed with stage
in 5 minutes and 45 seconds
......@@ -62,7 +62,7 @@ class JobManagerLocal(JobManager):
return job_id
def resubmit(self, job_ids = None, also_success = False, running_jobs = False, new_command=None, **kwargs):
def resubmit(self, job_ids = None, also_success = False, running_jobs = False, new_command=None, keep_logs=False, **kwargs):
"""Re-submit jobs automatically"""
self.lock()
# iterate over all jobs
......@@ -81,6 +81,8 @@ class JobManagerLocal(JobManager):
else:
# re-submit job to the grid
logger.info("Re-submitted job '%s' to the database", job)
if not keep_logs:
self.delete_logs(job)
job.submit('local')
self.session.commit()
......
......@@ -325,6 +325,14 @@ class JobManager:
self.unlock()
def delete_logs(self, job):
out_file, err_file = job.std_out_file(), job.std_err_file()
if out_file and os.path.exists(out_file):
os.remove(out_file)
logger.debug("Removed output log file '%s'" % out_file)
if err_file and os.path.exists(err_file):
os.remove(err_file)
logger.debug("Removed error log file '%s'" % err_file)
def delete(self, job_ids, array_ids = None, delete_logs = True, delete_log_dir = False, status = Status, delete_jobs = True):
"""Deletes the jobs with the given ids from the database."""
......@@ -336,13 +344,7 @@ class JobManager:
def _delete(job, try_to_delete_dir=False):
# delete the job from the database
if delete_logs:
out_file, err_file = job.std_out_file(), job.std_err_file()
if out_file and os.path.exists(out_file):
os.remove(out_file)
logger.debug("Removed output log file '%s'" % out_file)
if err_file and os.path.exists(err_file):
os.remove(err_file)
logger.debug("Removed error log file '%s'" % err_file)
self.delete_logs(job)
if try_to_delete_dir:
_delete_dir_if_empty(job.log_dir)
if delete_jobs:
......
......@@ -161,8 +161,6 @@ def submit(args):
def resubmit(args):
"""Re-submits the jobs with the given ids."""
jm = setup(args)
if not args.keep_logs:
jm.delete(job_ids=get_ids(args.job_ids), delete_jobs=False)
kwargs = {
'cwd': True,
......@@ -184,8 +182,7 @@ def resubmit(args):
if args.no_io_big:
kwargs['io_big'] = False
jm.resubmit(get_ids(args.job_ids), args.also_success, args.running_jobs, args.overwrite_command, **kwargs)
jm.resubmit(get_ids(args.job_ids), args.also_success, args.running_jobs, args.overwrite_command, keep_logs=args.keep_logs, **kwargs)
def run_scheduler(args):
......
......@@ -132,7 +132,7 @@ class JobManagerSGE(JobManager):
self.unlock()
def resubmit(self, job_ids = None, also_success = False, running_jobs = False, new_command=None, verbosity=0, **kwargs):
def resubmit(self, job_ids = None, also_success = False, running_jobs = False, new_command=None, verbosity=0, keep_logs=False, **kwargs):
"""Re-submit jobs automatically"""
self.lock()
# iterate over all jobs
......@@ -159,6 +159,8 @@ class JobManagerSGE(JobManager):
del arguments[arg]
job.set_arguments(kwargs=arguments)
# delete old status and result of the job
if not keep_logs:
self.delete_logs(job)
job.submit()
if job.queue_name == 'local' and 'queue' not in arguments:
logger.warn("Re-submitting job '%s' locally (since no queue name is specified)." % job)
......
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