From 241f0553a68aa7e0a50d384303b497887b7f9001 Mon Sep 17 00:00:00 2001 From: cfuselli Date: Wed, 23 Oct 2024 15:58:47 +0200 Subject: [PATCH] add run ranges and special ledcal --- .../auto_processing_new/offline_processing.py | 19 +++++++++++++++++++ amstrax/auto_processing_new/process.py | 1 + 2 files changed, 20 insertions(+) diff --git a/amstrax/auto_processing_new/offline_processing.py b/amstrax/auto_processing_new/offline_processing.py index 0d849237..b7c98a0c 100644 --- a/amstrax/auto_processing_new/offline_processing.py +++ b/amstrax/auto_processing_new/offline_processing.py @@ -100,6 +100,25 @@ def check_for_production(args): raise ValueError("Output folder not specified.") +def check_existing_jobs(job_name): + """ + Check if a job with the same name is already running, idle, or held. + """ + try: + result = subprocess.run(['condor_q', '-nobatch'], stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) + if result.returncode != 0: + raise RuntimeError(f"condor_q command failed: {result.stderr}") + + for line in result.stdout.splitlines(): + if job_name in line and " C " not in line: # Ignore completed jobs + log.error(f"Job with name '{job_name}' is already running, idle, or held.") + raise ValueError(f"Job with name '{job_name}' is already running, idle, or held.") + + except Exception as e: + log.error(f"Error while checking existing jobs: {e}") + sys.exit(1) + + def get_run_ids_from_args(args): run_ids = [] diff --git a/amstrax/auto_processing_new/process.py b/amstrax/auto_processing_new/process.py index d57f1cca..c1ff68eb 100644 --- a/amstrax/auto_processing_new/process.py +++ b/amstrax/auto_processing_new/process.py @@ -39,6 +39,7 @@ def __init__(self, args): self.setup_amstrax() self.setup_production() self.run_doc = self.db_utils.get_run_doc(self.run_id) + self.get_run_doc_info() def setup_amstrax(self):