Module xg
[show private | hide private]
[frames | no frames]

Module xg

PyXG provides a python interface to Apple's Xgrid.

Xgrid is Apple's software for building and managing clusters of Macintosh computers for use in high performance computation. See http://www.apple.com/server/macosx/features/xgrid.html for more details.

This module wraps the xgrid command line in Tiger. It will not work with the Technonogy Previews of Xgrid. The command line is wrapped in this module as the goal is to provide an interface to Xgrid that can be used from an interactive python prompt. The Cocoa API for Xgrid (XgridFoundation) is based on an event-loop paradigm and is less well suited for interactive work. If you want to use Xgrid and python from within a Cocoa application, you should use XgridFoundation and PyObjC.

Features

  1. Use Xgrid from within python scripts as well as in interactive python sessions.
  2. Create, submit and manage simple (one task) and batch (many task) Xgrid jobs using python's elegant syntax.
  3. Work with multiple Xgrid controllers simultaneouly.
  4. List available grids for each controller and query their status.

Quick Start

Import xg, create a Connection and Controller object:
>>> from xg import *
>>> conn = Connection(hostname='xgrid.work.com',password='secret')
>>> cont = Controller(conn)
List the grids managed by the controller:
>>> cont.gridIDs()
(0, 3)

>>> cont.grids()
[<Grid with gridID = 0>, <Grid with gridID = 3>]
Work with the default grid, listing active jobs:
>>> g = cont.grid(0)
>>> g.jobIDs()
(229, 230, 231, 232)

>>> g.printJobs()
##################################################
id   Date Started             Status     CPU Power 
##################################################
229  2005-12-22 11:18:47 -0800 Finished   0         
230  2005-12-22 11:18:50 -0800 Finished   0         
231  2005-12-22 11:18:52 -0800 Finished   0         
232  2005-12-22 11:18:55 -0800 Finished   0
Get a job from the default grid and work with it:
>>> j = g.job(229)      
>>> j.printInfo()
{
    name:  /usr/bin/cal
    jobStatus:  Finished
    taskCount:  1
    undoneTaskCount:  0
    percentDone:  100
}

>>> j.printInfo(verbose=False)
229  2005-12-22 11:18:47 -0800 Finished   0

>>> j.printSpecification()
{
    applicationIdentifier :  com.apple.xgrid.cli
    taskSpecifications :  {0 = {arguments = (); command = "/usr/bin/cal"; }; }
    name :  /usr/bin/cal
    inputFiles :  {}
    submissionIdentifier :  abc
}
Get job results:
>>> j.results(stdout="job229.out",stderr="job229.err")
Job stdout saved in file: job229.out
Use a Grid object to submit a single task job:
>>> j = g.submit(cmd='/usr/bin/cal')
Job submitted with id:  234

>>> j.printInfo(verbose=False)
234  2005-12-22 13:09:52 -0800 Finished   0

Classes
Connection Track information needed to connect to an XGrid controller.
Controller A class for working with an Xgrid controller.
Grid A class for working with jobs on a specific Xgrid grid.
GridManager Manage the grids of a given Xgrid controller.
InvalidAction Invalide action exception.
InvalidGridIdentifier Invalide grid identifier exception.
InvalidIdentifier Xgrid exception for invalid job or grid identifiers.
InvalidIdentifierType Invalid job or grid identifier type.
InvalidJobIdentifier Invalide job identifier exception.
Job A class for working with an Xgrid job.
JobManager Manage a set of Xgrid jobs.
JobSpecification A class used for constructing multi-task batch jobs.
XgridError Xgrid exception class.

Function Summary
  processID(id)
Makes sure that the id is a unicode string
  xgridParse(cmd)
Submits and parses output from the xgrid command line.

Variable Summary
NoneType defaultXgridHostname = None                                                                  
str defaultXgridPassword = ''
bool PYXGRID_DEBUG = False
str VERSION = '0.2.0'

Function Details

processID(id)

Makes sure that the id is a unicode string

xgridParse(cmd='xgrid -grid list')

Submits and parses output from the xgrid command line.

The output of the xgrid CLI is a (sometimes illegal) old-style plist. This function runs an xgrid command and parses the output of the command into a valid NSDictionary (a python dict).

To handle the illegal plists returned by the xgrid CLI, we use the xGridPropertyList: method of NSString (defined above).

See the xgrid man pages for details on the xgrid command. This fuction will return a nested python structure that reflects the output of the xgrid command.

Variable Details

defaultXgridHostname

Type:
NoneType
Value:
None                                                                  

defaultXgridPassword

Type:
str
Value:
''                                                                     

PYXGRID_DEBUG

Type:
bool
Value:
False                                                                  

VERSION

Type:
str
Value:
'0.2.0'                                                                

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