Author: tmckay
Date: 2012-03-09 21:38:31 +0000 (Fri, 09 Mar 2012)
New Revision: 5245
Modified:
trunk/cumin/python/cumin/grid/job.py
trunk/sage/python/sage/aviary/aviaryoperations.py
trunk/sage/python/sage/qmf/qmfoperations.py
Log:
Add suspend and continue task links for job control
BZ756384
Modified: trunk/cumin/python/cumin/grid/job.py
===================================================================
--- trunk/cumin/python/cumin/grid/job.py 2012-03-07 15:03:24 UTC (rev 5244)
+++ trunk/cumin/python/cumin/grid/job.py 2012-03-09 21:38:31 UTC (rev 5245)
@@ -45,6 +45,8 @@
JobHold(app, self)
JobRelease(app, self)
+ JobSuspend(app, self)
+ JobContinue(app, self)
JobRemove(app, self)
# task not visible on page. used for edit submit
@@ -253,6 +255,8 @@
JobSelectionHold(app, self, "held")
JobSelectionRelease(app, self, "released")
+ JobSelectionSuspend(app, self, "suspended")
+ JobSelectionContinue(app, self, "continued")
JobSelectionRemove(app, self, "removed")
self.enable_csv_export(submission)
@@ -310,15 +314,16 @@
return super(JobSelectorTable, self).do_render(session)
class JobObjectSelectorTask(ObjectSelectorTask):
- def __init__(self, app, selector, verb):
+ def __init__(self, app, selector, verb, cmd):
super(JobObjectSelectorTask, self).__init__(app, selector)
self.form = JobObjectSelectorTaskForm(app, self.name, self, verb)
- self.method = None
+ self.cmd = cmd
def do_invoke(self, invoc, job_id, scheduler, reason, submission):
- assert self.method
- self.method(scheduler, job_id, reason, submission,
callback=invoc.make_callback())
+ self.app.remote.control_job(self.cmd, scheduler,
+ job_id, reason, submission,
+ callback=invoc.make_callback())
def do_enter(self, session, osession):
submission = self.selector.submission.get(osession)
@@ -330,31 +335,44 @@
class JobSelectionHold(JobObjectSelectorTask):
def __init__(self, app, selector, verb):
- super(JobSelectionHold, self).__init__(app, selector, verb)
+ super(JobSelectionHold, self).__init__(app, selector, verb,
+ "holdJob")
- self.method = self.app.remote.hold_job
-
def get_title(self, session):
return "Hold"
class JobSelectionRelease(JobObjectSelectorTask):
def __init__(self, app, selector, verb):
- super(JobSelectionRelease, self).__init__(app, selector, verb)
+ super(JobSelectionRelease, self).__init__(app, selector, verb,
+ "releaseJob")
- self.method = self.app.remote.release_job
-
def get_title(self, session):
return "Release"
class JobSelectionRemove(JobObjectSelectorTask):
def __init__(self, app, selector, verb):
- super(JobSelectionRemove, self).__init__(app, selector, verb)
+ super(JobSelectionRemove, self).__init__(app, selector, verb,
+ "removeJob")
- self.method = self.app.remote.remove_job
-
def get_title(self, session):
return "Remove"
+class JobSelectionSuspend(JobObjectSelectorTask):
+ def __init__(self, app, selector, verb):
+ super(JobSelectionSuspend, self).__init__(app, selector, verb,
+ "suspendJob")
+
+ def get_title(self, session):
+ return "Suspend"
+
+class JobSelectionContinue(JobObjectSelectorTask):
+ def __init__(self, app, selector, verb):
+ super(JobSelectionContinue, self).__init__(app, selector, verb,
+ "continueJob")
+
+ def get_title(self, session):
+ return "Continue"
+
class JobObjectSelectorTaskForm(ObjectSelectorTaskForm):
def __init__(self, app, name, task, verb):
super(JobObjectSelectorTaskForm, self).__init__(app, name, task)
@@ -1124,49 +1142,54 @@
return "Reason"
class JobAction(ObjectFrameTask):
- def __init__(self, app, frame, verb):
+ def __init__(self, app, frame, verb, cmd):
super(JobAction, self).__init__(app, frame)
self.form = JobActionForm(app, self.name, self, verb)
+ self.cmd = cmd
def do_enter(self, session, osession):
job_id = self.frame.job_id.get(osession)
self.form.job_id.set(session, job_id)
def do_invoke(self, invoc, scheduler, job_id, reason, submission):
- raise Exception("oops, not implemented!")
+ self.app.remote.control_job(self.cmd, scheduler, job_id,
+ reason, submission,
+ callback=invoc.make_callback())
class JobHold(JobAction):
def __init__(self, app, frame):
- super(JobHold, self).__init__(app, frame, "held")
+ super(JobHold, self).__init__(app, frame, "held", "holdJob")
- def do_invoke(self, invoc, scheduler, job_id, reason, submission):
- self.app.remote.hold_job(scheduler, job_id, reason, submission,
- callback=invoc.make_callback())
-
def get_title(self, session):
return "Hold Job"
class JobRelease(JobAction):
def __init__(self, app, frame):
- super(JobRelease, self).__init__(app, frame, "released")
+ super(JobRelease, self).__init__(app, frame, "released",
"releaseJob")
- def do_invoke(self, invoc, scheduler, job_id, reason, submission):
- self.app.remote.release_job(scheduler, job_id, reason, submission,
- callback=invoc.make_callback())
-
def get_title(self, session):
return "Release Job"
-class JobRemove(JobAction):
+class JobSuspend(JobAction):
def __init__(self, app, frame):
- super(JobRemove, self).__init__(app, frame, "removed")
+ super(JobSuspend, self).__init__(app, frame, "suspended",
"suspendJob")
- def do_invoke(self, invoc, scheduler, job_id, reason, submission):
- self.app.remote.remove_job(scheduler, job_id, reason, submission,
- callback=invoc.make_callback())
+ def get_title(self, session):
+ return "Suspend Job"
+class JobContinue(JobAction):
+ def __init__(self, app, frame):
+ super(JobContinue, self).__init__(app, frame, "continued",
"continueJob")
+
def get_title(self, session):
+ return "Continue Job"
+
+class JobRemove(JobAction):
+ def __init__(self, app, frame):
+ super(JobRemove, self).__init__(app, frame, "removed",
"removeJob")
+
+ def get_title(self, session):
return "Remove Job"
def do_enter(self, session, osession):
Modified: trunk/sage/python/sage/aviary/aviaryoperations.py
===================================================================
--- trunk/sage/python/sage/aviary/aviaryoperations.py 2012-03-07 15:03:24 UTC (rev 5244)
+++ trunk/sage/python/sage/aviary/aviaryoperations.py 2012-03-09 21:38:31 UTC (rev 5245)
@@ -189,64 +189,30 @@
t = CallThread(job_client.service.submitJob, my_callback, *args)
t.start()
- def hold_job(self, scheduler, job_id, reason, submission, *args, **kwargs):
+ def control_job(self, cmd, scheduler, job_id, reason, submission, *args, **kwargs):
'''
This method is asynchronous iff 'callback' is supplied.
- kwargs will be searched for 'callback', 'default' and
'timeout' arguments.
-
- These optional arguments were moved to kwargs for compatibility
- with another implementation of the same routine.
- '''
-
- callback = "callback" in kwargs and kwargs["callback"] or
None
- default = "default" in kwargs and kwargs["default"] or None
- timeout = "timeout" in kwargs and kwargs["timeout"] or 5
+ Values for cmd are case sensitive (although the first letter may
+ actually be either case) and may be one of the following:
+ 'holdJob', 'releaseJob', 'suspendJob',
'continueJob', 'removeJob'
- return self._control_job(scheduler, job_id, reason, submission,
- "holdJob",
- callback, default, timeout)
-
- def release_job(self, scheduler, job_id, reason, submission, *args, **kwargs):
- '''
- This method is asynchronous iff 'callback' is supplied.
-
kwargs will be searched for 'callback', 'default' and
'timeout' arguments.
-
- These optional arguments were moved to kwargs for compatibility
- with another implementation of the same routine.
'''
- callback = "callback" in kwargs and kwargs["callback"] or
None
- default = "default" in kwargs and kwargs["default"] or None
- timeout = "timeout" in kwargs and kwargs["timeout"] or 5
-
+ # Aviary and QMF command names for job control differ in one respect,
+ # which is that QMF uses an initial capital and Aviary does not.
+ cmd = cmd[0].lower() + cmd[1:]
return self._control_job(scheduler, job_id, reason, submission,
- "releaseJob",
- callback, default, timeout)
+ cmd, *args, **kwargs)
- def remove_job(self, scheduler, job_id, reason, submission, *args, **kwargs):
- '''
- This method is asynchronous iff 'callback' is supplied.
+ def _control_job(self, scheduler, job_id, reason, submission,
+ meth_name, *args, **kwargs):
- kwargs will be searched for 'callback', 'default' and
'timeout' arguments.
-
- These optional arguments were moved to kwargs for compatibility
- with another implementation of the same routine.
- '''
-
callback = "callback" in kwargs and kwargs["callback"] or
None
default = "default" in kwargs and kwargs["default"] or None
timeout = "timeout" in kwargs and kwargs["timeout"] or 5
- return self._control_job(scheduler, job_id, reason, submission,
- "removeJob",
- callback, default, timeout)
-
- def _control_job(self, scheduler, job_id, reason, submission,
- meth_name,
- callback, default, timeout):
-
client = self._setup_client(self.job_client_pool,
scheduler.Machine,
self.job_servers,
Modified: trunk/sage/python/sage/qmf/qmfoperations.py
===================================================================
--- trunk/sage/python/sage/qmf/qmfoperations.py 2012-03-07 15:03:24 UTC (rev 5244)
+++ trunk/sage/python/sage/qmf/qmfoperations.py 2012-03-09 21:38:31 UTC (rev 5245)
@@ -90,55 +90,27 @@
assert callback
self._call(scheduler, "SubmitJob", callback, 0, 0, ad)
- def hold_job(self, scheduler, job_id, reason, *args, **kwargs):
+ def control_job(self, cmd, scheduler, job_id, reason, *args, **kwargs):
'''
This method is asynchronous iff 'callback' is supplied.
- kwargs will be searched for 'callback', 'default' and
'timeout' arguments.
-
- These optional arguments were moved to kwargs for compatibility
- with another implementation of the same routine.
- '''
-
- callback = "callback" in kwargs and kwargs["callback"] or
None
- default = "default" in kwargs and kwargs["default"] or None
- timeout = "timeout" in kwargs and kwargs["timeout"] or 5
+ Values for cmd are case sensitive (although the first letter may
+ actually be either case) and may be one of the following:
+ 'HoldJob', 'ReleaseJob', 'SuspendJob',
'ContinueJob', 'RemoveJob'
- return self._call(scheduler, "HoldJob", callback, default,
- timeout, job_id, reason)
-
- def release_job(self, scheduler, job_id, reason, *args, **kwargs):
- '''
- This method is asynchronous iff 'callback' is supplied.
-
kwargs will be searched for 'callback', 'default' and
'timeout' arguments.
-
- These optional arguments were moved to kwargs for compatibility
- with another implementation of the same routine.
'''
- callback = "callback" in kwargs and kwargs["callback"] or
None
- default = "default" in kwargs and kwargs["default"] or None
- timeout = "timeout" in kwargs and kwargs["timeout"] or 5
+ # Aviary and QMF command names for job control differ in one respect,
+ # which is that QMF uses an initial capital and Aviary does not.
+ # Make sure initial letter is uppercase
+ cmd = cmd[0].upper() + cmd[1:]
- return self._call(scheduler, "ReleaseJob", callback, default,
- timeout, job_id, reason)
-
- def remove_job(self, scheduler, job_id, reason, *args, **kwargs):
- '''
- This method is asynchronous iff 'callback' is supplied.
-
- kwargs will be searched for 'callback', 'default' and
'timeout' arguments.
-
- These optional arguments were moved to kwargs for compatibility
- with another implementation of the same routine.
- '''
-
callback = "callback" in kwargs and kwargs["callback"] or
None
default = "default" in kwargs and kwargs["default"] or None
timeout = "timeout" in kwargs and kwargs["timeout"] or 5
- return self._call(scheduler, "RemoveJob", callback, default,
+ return self._call(scheduler, cmd, callback, default,
timeout, job_id, reason)
# jobserver operations