Module xg :: Class Job
[show private | hide private]
[frames | no frames]

Class Job


A class for working with an Xgrid job.
Method Summary
  __init__(self, jobID, connection)
An Xgrid job class.
  __repr__(self)
Job batch(self, specification, gridID, silent)
Submits a batch job to the specified grid.
  delete(self)
Deletes the job.
  info(self, update)
Return the current status information about a job.
  perform(self, action)
Performs an action on a job.
  printInfo(self, verbose)
Prints the info() dictionary of a job.
  printSpecification(self)
Print the job specification used to submit the job.
  restart(self)
Restarts the job.
  results(self, stdout, outdir, stderr, block, silent)
Retrive the results of an Xgrid job.
  resume(self)
Resumes the job.
  specification(self, update)
Return the Xgrid job specification.
  stop(self)
Stops the job.
Job submit(self, cmd, args, stdin, indir, email, gridID)
Submits a single task job to the specified grid.
  suspend(self)
Suspends the job.

Method Details

__init__(self, jobID=u'999999999', connection=None)
(Constructor)

An Xgrid job class.

This class allows a user to work with an Xgrid job. It provides capabilities for starting jobs, managing them and retrieving their results.

Job instances are created in two ways:
  1. By calling the job() or jobs() methods of the Grid or Controller classes.
  2. By simply creating a new Job object:
>>> j = Job(u'200')    # Create a new job with id of 200
Parameters:
jobID - The job identifier of the job. To create a new job, leave blank.
           (type=unicode, str or int)
connection - Instance of Connection class. If empty a default Connection object is used.
           (type=Connection)

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

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

delete(self)

Deletes the job.

info(self, update=1)

Return the current status information about a job.

The job info is a dictionary of keys describing the current state of the job. This includes start/stop dates, name, etc.

The method printInfo() prints the info() dictionary in a nice form.
Parameters:
update - A boolean flag that determines whether or not the internal state is updated upon creation. This involves a call to the Xgrid controller.
           (type=boolean)

perform(self, action)

Performs an action on a job.
Parameters:
action - The action to be performed as a string. Implemented actions are stop, resume, delete, restart, and suspend.
           (type=str)

printInfo(self, verbose=True)

Prints the info() dictionary of a job.

printSpecification(self)

Print the job specification used to submit the job.

restart(self)

Restarts the job.

results(self, stdout='', outdir='', stderr='', block=10, silent=False)

Retrive the results of an Xgrid job.

This method provides both a blocking and nonblocking method of getting the results of an Xgrid job. The job does not need to be completed to retrieve the results. Because of this, the results method can be used to get partial results while the job continues to run. It can also automatically name output files.
Parameters:
stdout - The local file in which to put the stdout stream of the remote job. If this is empty, the method will automatically generate a name in the local directory of the form: xgridjob-jobID.out. This file always is placed in the cwd rather than the outdir
           (type=str)
outdir - The local directory in which to put the files retrieved from the remote job. This is only for files other than the stdout and stderr files. When empty, the other files are not brought back. This is to prevent any accidental overwrites of results.
           (type=str)
stderr - The local file in which to put the stderr stream of the remote job. If this is empty, the method will automatically generate a name in the local directory of the form: xgridjob-jobID.err.
           (type=str)
block - Whether or not to block until the job is finished. If block=0, partially completed results are retrieved and the job will continue to run. If block > 0, the job status is queried every block seconds and the results are returned when the job is completed.
           (type=int)
silent - Silence all messages.
           (type=boolean)

resume(self)

Resumes the job.

specification(self, update=1)

Return the Xgrid job specification.

The Xgrid job specification is the dictionary that Xgrid uses to submit the job. It contains keys that describe the command arguments, directories, etc.

stop(self)

Stops the job.

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

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.

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

suspend(self)

Suspends the job.

Generated by Epydoc 2.1 on Thu Dec 22 15:15:21 2005 http://epydoc.sf.net