Module xg :: Class Controller
[hide private]
[frames] | no frames]

Class Controller

source code

 object --+    
          |    
 JobManager --+
              |
 object --+   |
          |   |
GridManager --+
              |
             Controller

A class for working with an Xgrid controller.

Instance Methods [hide private]
 
__init__(self, connection=None, update=0)
This class provides an interface to an Xgrid controller.
source code
 
_update(self)
Updates all instance variables for active grids and jobs.
source code
Job
submit(self, cmd, args='', stdin='', indir='', email='', gridID=u'0')
Submits a single task job to the specified grid.
source code
Job
batch(self, specification, gridID=u'0', silent=False)
Submits a batch job to the specified grid.
source code

Inherited from JobManager: deleteAll, job, jobIDs, jobs, perform, printJobs, restartAll, resumeAll, stopAll, suspendAll

Inherited from JobManager (private): _checkGridID, _updateJobs

Inherited from GridManager: grid, gridIDs, grids

Inherited from GridManager (private): _updateGrids

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, connection=None, update=0)
(Constructor)

source code 

This class provides an interface to an Xgrid controller.

An Xgrid controller is a single machine that manages a set of of grids. Each grid in turn, consists of a set of agents and jobs running on the agents.

This class provides access to the grids and jobs managed by the controller. In Xgrid, both grids and jobs have identifiers, which are unicode strings, like u'0', but this module can take identifiers as strings or integers as well.

Controller and Grid objects can be used to submit Xgrid jobs, but the Job class is used to retrieve job results.

The Controller is only the JobManager for the default Grid. To access the jobs of other grids, create instances of their Grid objects.

Examples

>>> cn = Connection('myhost','mypassword')
>>> c = Controller(cn)
>>> c.jobIDs()
(1, 2, 3)
>>> j1 = c.job('1')     # Get an initialized Job object with id = '1'
>>> j1
<Job with id = 1>
>>> c.grid_ids()        # List the grid ids
('0',)
>>> c.grid('10')        # Get an initialized Grid object with id = '10'
<Grid with gridID = 10>
>>> c.grid()            # Get the Grid boject for the default grid
Parameters:
  • connection (Connection) - Instance of Connection class. If empty a default Connection object is used.
  • update (boolean) - A boolean flag that determines whether or not the internal state is updated upon creation. This involves a call to the Xgrid controller.
Overrides: object.__init__

submit(self, cmd, args='', stdin='', indir='', email='', gridID=u'0')

source code 

Submits a single task job to the specified grid.

This is a nonblocking job submission method for a single job with no sub-tasks. For more complicated jobs with sub-tasks, use the batch() method and the JobSpecification class.

Job results can be obtained by calling the results() method of the Job object.

Parameters:
  • cmd (str) - The command the execute as a string. The executable is not copied if the full path is given, otherwise it is.
  • args (list or str) - The command line arguments to be passed to the command.
  • stdin (str) - A local file to use as the stdin stream for the job.
  • indir (str) - A local directory to copy to the remote agent.
  • email (str) - An email to which notification will be send of various job state changes.
  • gridID (unicode, str or int) - The identifier of the Grid to which the job will be submitted. If empty, the default grid u'0' is used.
Returns: Job
Initialized Job object for sumbitted job.

batch(self, specification, gridID=u'0', silent=False)

source code 

Submits a batch job to the specified grid.

This is a nonblocking job submission method used for submitting complex multi-task jobs. For single task jobs, use submit().

To retrieve job results, use the results() method of the Job object.

Parameters:
  • specification (JobSpecification) - The job specification of the job, which must be an instance of the JobSpecification class. See the docstring for JobSpecification for more details.
  • gridID (unicode, str or int) - The identifier of the Grid to which the job will be submitted. If empty, the default grid u'0' is used.
  • silent (boolean) - If set to True will slience all messages.
Returns: Job
Initialized Job object for sumbitted job.