From c00da88f0fcc1760e935cf0d79466fb7742a3b87 Mon Sep 17 00:00:00 2001 From: slefrancois Date: Wed, 31 Aug 2016 12:57:44 -0400 Subject: [PATCH 1/2] On helios, get PBS_JOBID associated with SRMJID --- scripts/smart-dispatch | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/scripts/smart-dispatch b/scripts/smart-dispatch index 1243851..f778e0e 100755 --- a/scripts/smart-dispatch +++ b/scripts/smart-dispatch @@ -20,6 +20,9 @@ from smartdispatch.filelock import open_with_lock import logging import smartdispatch +# For cluster job_id mismatch +import re + LOGS_FOLDERNAME = "SMART_DISPATCH_LOGS" CLUSTER_NAME = utils.detect_cluster() AVAILABLE_QUEUES = get_available_queues(CLUSTER_NAME) @@ -138,6 +141,14 @@ def main(): qsub_output = check_output('{launcher} {pbs_filename}'.format(launcher=LAUNCHER if args.launcher is None else args.launcher, pbs_filename=pbs_filename), shell=True) jobs_id += [qsub_output.strip()] + # On some clusters, SRMJID and PBS_JOBID don't match + if CLUSTER_NAME in ['helios']: + qstat_out = check_output(['qstat', '-f']).split('Job Id: ') + for job in qstat_out: + if re.search(r"SRMJID:{job_id}".format(job_id=jobs_id[-1]), job): + pbs_job_id = re.match(r"[0-9a-zA-Z.-]*", job).group() + jobs_id[-1] = 'PBS_JOBID: {pbs}, SRMJID: {srm}'.format(pbs=pbs_job_id, srm=jobs_id[-1]) + with open_with_lock(pjoin(path_job, "jobs_id.txt"), 'a') as jobs_id_file: jobs_id_file.writelines(t.strftime("## %Y-%m-%d %H:%M:%S ##\n")) jobs_id_file.writelines("\n".join(jobs_id) + "\n") From c39dc9972a365b2fcf935f51de04eb5b1f0768bb Mon Sep 17 00:00:00 2001 From: slefrancois Date: Mon, 12 Sep 2016 10:12:41 -0400 Subject: [PATCH 2/2] only return pbs_jobid --- scripts/smart-dispatch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/smart-dispatch b/scripts/smart-dispatch index f778e0e..97c7946 100755 --- a/scripts/smart-dispatch +++ b/scripts/smart-dispatch @@ -147,7 +147,7 @@ def main(): for job in qstat_out: if re.search(r"SRMJID:{job_id}".format(job_id=jobs_id[-1]), job): pbs_job_id = re.match(r"[0-9a-zA-Z.-]*", job).group() - jobs_id[-1] = 'PBS_JOBID: {pbs}, SRMJID: {srm}'.format(pbs=pbs_job_id, srm=jobs_id[-1]) + jobs_id[-1] = '{pbs}'.format(pbs=pbs_job_id) with open_with_lock(pjoin(path_job, "jobs_id.txt"), 'a') as jobs_id_file: jobs_id_file.writelines(t.strftime("## %Y-%m-%d %H:%M:%S ##\n"))