Package gavo :: Package protocols :: Module uws :: Class UWS
[frames] | no frames]

Class UWS

source code

object --+
         |
        UWS
Known Subclasses:

a facade for a universal worker service (UWS).

You must construct it with the job class (see UWSJob) and a uwsactions.JobActions instance

The UWS then provides methods to access the jobs table, create jobs and and deserialize jobs from the jobs table.

We have a "statements cache" in here, where we used the UWS table defintion to create query strings we can later pass to the database. Don't worry about this any more. Just write text queries when adding features. It's more readable and just about as stable against code evolution.

You must override the getURLForId(jobId) method in your concrete implementation.

You should also override jobdocPreamble and joblistPreamble. This is raw XML that is prepended to job and list documents. This is primarily for PIs giving stylesheets, but given we don't use doctypes you could provide internal subsets there, too. Anyway, see the TAP UWS runner for examples.

Instance Methods
 
__init__(self, jobClass, jobActions)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
runCanned(self, statementId, args, conn)
runs the canned statement statementId with args through the DB connection conn.
source code
 
getNewJobId(self, **kws)
creates a new job and returns its id.
source code
 
getNewIdFromRequest(self, request, service)
returns the id of a new TAP job created from request.
source code
 
getJob(self, jobId)
returns a read-only UWSJob for jobId.
source code
 
getNewJob(self, **kws)
creates a new job and returns a read-only instance for it.
source code
 
changeableJob(*args, **kwds)
a context manager for job manipulation.
source code
 
changeToPhase(self, jobId, newPhase, input=None, timeout=0.1) source code
 
destroy(self, jobId)
removes the job with jobId from the UWS.
source code
 
countRunningJobs(self)
returns the number of EXECUTING jobs in the jobsTable.
source code
 
countQueuedJobs(self)
returns the number of QUEUED jobs in jobsTable.
source code
 
getJobIds(self)
returns a list of all currently existing job ids.
source code
 
getIdsAndPhases(self, owner=None, phase=None, last=None, after=None, initFragments=None, initPars=None)
returns pairs for id and phase for all jobs in the UWS.
source code
 
cleanupJobsTable(self, includeFailed=False, includeCompleted=False, includeAll=False, includeForgotten=False)
removes expired jobs from the UWS jobs table.
source code
 
getURLForId(self, jobId)
returns the handling URL for the job with jobId.
source code

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

Class Variables
  cleanupInterval = 43200
  joblistPreamble = ''
hash(x)
  jobdocPreamble = ''
hash(x)
Properties

Inherited from object: __class__

Method Details

__init__(self, jobClass, jobActions)
(Constructor)

source code 

x.__init__(...) initializes x; see help(type(x)) for signature

Overrides: object.__init__
(inherited documentation)

runCanned(self, statementId, args, conn)

source code 

runs the canned statement statementId with args through the DB connection conn.

This will return row dictionaries of the result if there is a result.

getNewJobId(self, **kws)

source code 

creates a new job and returns its id.

kws can be properties of the new job or the special key timeout giving after how many seconds we should give up trying to lock the db.

getNewIdFromRequest(self, request, service)

source code 

returns the id of a new TAP job created from request.

Request has to be a nevow request or similar, with request arguments in request.args.

This calls setParamsFromRequest(wjob, request) to do the actual work; this latter method is what individual UWSes should override.

getJob(self, jobId)

source code 

returns a read-only UWSJob for jobId.

Note that by the time you do something with the information here, the "true" state in the database may already be different. There should be no way to write whatever information you have in here, so any "racing" here shouldn't hurt.

changeableJob(*args, **kwds)

source code 

a context manager for job manipulation.

This is done such that any changes to the job's properties within the controlled section get propagated to the database. As long as you are in the controlled section, nobody else can change the job.

Decorators:
  • @contextlib.contextmanager

destroy(self, jobId)

source code 

removes the job with jobId from the UWS.

This calls the job's prepareForDestruction method while the job is writable.

getIdsAndPhases(self, owner=None, phase=None, last=None, after=None, initFragments=None, initPars=None)

source code 

returns pairs for id and phase for all jobs in the UWS.

phase, last, after are the respective parameters from UWS 1.1.

cleanupJobsTable(self, includeFailed=False, includeCompleted=False, includeAll=False, includeForgotten=False)

source code 

removes expired jobs from the UWS jobs table.

The constructor arranged for this to be called now and then (cleanupFrequency class attribute, defaulting to 12*3600).

The functionality is also exposed through gavo admin cleanuws; this also lets you use the includeFailed and includeCompleted flags. These should not be used on production services since you'd probably nuke jobs still interesting to your users.

getURLForId(self, jobId)

source code 

returns the handling URL for the job with jobId.

You must override this in deriving classes.