From a0ccc79b4736dbb78532d30e88cd67cdd2cbdcbc Mon Sep 17 00:00:00 2001 From: Jake Smith <jws52@cam.ac.uk> Date: Mon, 7 Dec 2020 16:27:10 +0000 Subject: [PATCH] Leave INPROGRESS jobs alone. --- Processor.py | 4 ++-- ProcessorUtils.py | 17 ++++++++++++++--- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/Processor.py b/Processor.py index 471ab5e..0822382 100755 --- a/Processor.py +++ b/Processor.py @@ -384,9 +384,9 @@ def run_Process(): # check for a status file in job directory if status.had_initial_status: - logger.error(f"Job path already exists and has status {status.status}") + logger.info(f"Job path already exists and has status {status.status}") - endJob(status,premature = status.status != 'SUCCESS') + endJob(status,ignore_inprogress=True,premature = status.status != 'SUCCESS') logger.info(f"Current status of job directory is {status.status}") diff --git a/ProcessorUtils.py b/ProcessorUtils.py index a6a4d46..23f9e69 100644 --- a/ProcessorUtils.py +++ b/ProcessorUtils.py @@ -132,19 +132,30 @@ def subprocess_and_log(cmd,description_short,description_long,check=True,**kwarg return process def endScript(premature=True): + if not premature: + logger.info(f'Script finished!') + else: + logger.info(f'Script finished prematurely') + logger.info(f'--------') + sys.exit() -def endJob(status,**kwargs): +def endJob(status,ignore_inprogress=False,**kwargs): + # get status file fresh, and ensure one exists status.status = status.get() + assert status.has_status - if status.is_inprogress(): - logger.warning(f'Workflow problem: {script_name} status is {status.status} but endJob called, forcing error status') + + if status.is_inprogress() & (ignore_inprogress == False): + + logger.warning(f'Workflow problem: status is {status.status} but endJob called, forcing error status') + status.reset('ERROR') endScript(**kwargs) -- GitLab