From 2635bf20795412cadc4c6680d90a15bacf03835d Mon Sep 17 00:00:00 2001 From: Manuel Guenther <manuel.guenther@idiap.ch> Date: Thu, 30 Jan 2014 14:56:22 +0100 Subject: [PATCH] Corrected handling of grid ids. --- gridtk/manager.py | 6 +++--- gridtk/models.py | 2 +- gridtk/script/jman.py | 2 +- gridtk/sge.py | 13 ++++++++++++- 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/gridtk/manager.py b/gridtk/manager.py index 1644cd0..8f48763 100644 --- a/gridtk/manager.py +++ b/gridtk/manager.py @@ -191,9 +191,9 @@ class JobManager: self.unlock() return - array_format = "{0:>%d} {1:^%d} {2:^%d}" % lengths[:3] + array_format = "{0:^%d} {1:>%d} {2:^%d} {3:^%d}" % lengths[:4] delimiter = format.format(*['='*k for k in lengths]) - array_delimiter = array_format.format(*["-"*k for k in lengths[:3]]) + array_delimiter = array_format.format(*["-"*k for k in lengths[:4]]) header = [fields[k].center(lengths[k]) for k in range(len(lengths))] # print header @@ -233,7 +233,7 @@ class JobManager: def _write_array_jobs(array_jobs): for array_job in array_jobs: if unfinished or array_job.status in accepted_status: - print("Array Job", str(array_job.unique), ":") + print("Array Job", str(array_job.id), ":") _write_contents(array_job) self.lock() diff --git a/gridtk/models.py b/gridtk/models.py index 21a9cb6..69a1ab7 100644 --- a/gridtk/models.py +++ b/gridtk/models.py @@ -57,7 +57,7 @@ class ArrayJob(Base): queue = self.job.queue_name if self.machine_name is None else self.machine_name status = "%s" % self.status + (" (%d)" % self.result if self.result is not None else "" ) - return format.format(job_id, queue, status) + return format.format("", job_id, queue, status) class Job(Base): diff --git a/gridtk/script/jman.py b/gridtk/script/jman.py index abb64c7..361f4ae 100644 --- a/gridtk/script/jman.py +++ b/gridtk/script/jman.py @@ -160,7 +160,7 @@ def run_scheduler(args): def list(args): """Lists the jobs in the given database.""" jm = setup(args) - jm.list(job_ids=get_ids(args.job_ids), print_array_jobs=args.print_array_jobs, print_dependencies=args.print_dependencies, status=args.status, long=args.verbose > 1 or args.long, ids_only=args.ids_only, names=args.names) + jm.list(job_ids=get_ids(args.job_ids), print_array_jobs=args.print_array_jobs, print_dependencies=args.print_dependencies, status=args.status, long=args.long, ids_only=args.ids_only, names=args.names) def communicate(args): diff --git a/gridtk/sge.py b/gridtk/sge.py index b3a2233..eb0e1aa 100644 --- a/gridtk/sge.py +++ b/gridtk/sge.py @@ -10,7 +10,7 @@ from __future__ import print_function from .manager import JobManager from .setshell import environ -from .models import add_job +from .models import add_job, Job from .tools import logger, qsub, qstat, qdel, make_shell import os, sys @@ -155,6 +155,17 @@ class JobManagerSGE(JobManager): self.unlock() + def run_job(self, job_id, array_id = None): + """Overwrites the run-job command from the manager to extract the correct job id before calling base class implementation.""" + # get the unique job id from the given grid id + self.lock() + job = self.session.query(Job).filter(Job.id == job_id) + job_id = list(job)[0].unique + self.unlock() + # call base class implementation with the corrected job id + return JobManager.run_job(self, job_id, array_id) + + def stop_jobs(self, job_ids): """Stops the jobs in the grid.""" self.lock() -- GitLab