gavo.protocols.tap module

TAP: schema maintenance, job/parameter definition incl. upload and UWS actions.

class gavo.protocols.tap.LocalFile(jobId, wd, fileName)[source]

Bases: object

A sentinel class representing a file within a job work directory (as resulting from an upload).

getURL()[source]

returns the URL the file is retrievable under for the life time of the job.

class gavo.protocols.tap.PlanAction[source]

Bases: JobAction

retrieve a query plan.

This is actually a TAP action; as we add UWSes, we’ll need to think about how we can customize uwsactions my UWS type.

doGET(job, request)[source]
formatPlan(qTableAndPlan)[source]
getPlan(job, request)[source]
name = 'plan'
class gavo.protocols.tap.TAPCore(parent, **kwargs)[source]

Bases: Core

A core for the TAP renderer.

attrSeq = [<gavo.base.parsecontext.IdAttribute object>, <gavo.base.complexattrs.StructAttribute object>, <gavo.base.parsecontext.OriginalAttribute object>, <gavo.base.complexattrs.StructAttribute object>, <gavo.base.complexattrs.PropertyAttribute object>, <gavo.rscdef.common.RDAttribute object>]
clearProperty(name)
completedCallbacks = []
getFullId()
getProperty(name, default=<Undefined>)
getRelevantTables()[source]

returns a sequence of “published tables”.

This is for VOSI tables, and hence what’s a “published table” is a bit fuzzy. By default we return the output table if it looks non-trivial, or else nothing at all.

hasProperty(name)
inputTableXML = '\n\t\t<inputTable>\n\t\t\t<inputKey name="request" type="text" required="True"\n\t\t\t\tstd="True" multiplicity="force-single"\n\t\t\t\tdescription="Type of operation requested; this can be doQuery\n\t\t\t\t\tor getCapabilities.  Preferably, don\'t pass it at all.">\n\t\t\t\t<values default="doQuery"/>\n\t\t\t</inputKey>\n\t\t\t<inputKey name="lang" type="text" required="True"\n\t\t\t\tstd="True" multiplicity="force-single"\n\t\t\t\tdescription="A name of a language that QUERY should be parsed as.\n\t\t\t\t\tSee capabilities for what you can pass in here.">\n\t\t\t</inputKey>\n\t\t\t<inputKey name="query" type="text" required="True"\n\t\t\t\tstd="True" multiplicity="force-single"\n\t\t\t\tdescription="The query to be executed.">\n\t\t\t</inputKey>\n\t\t\t<inputKey name="version" type="text"\n\t\t\t\tstd="True"\n\t\t\t\tdescription="Don\'t use this parameter.  You\'ll only break stuff.">\n\t\t\t\t<values default="1.1"/>\n\t\t\t\t<preparse>\n\t\t\t\t\tif input!="1.1":\n\t\t\t\t\t\traise ValueError(\n\t\t\t\t\t\t\t"Version mismatch; this service only supports"\n\t\t\t\t\t\t\t" TAP version 1.1.")\n\t\t\t\t</preparse>\n\t\t\t</inputKey>\n\t\t\t<inputKey name="format" type="text"\n\t\t\t\tdescription="Deprecated alias of RESPONSEFORMAT"/>\n\t\t\t<inputKey name="upload" type="raw"\n\t\t\t\tdescription="A TAP-compliant upload; roughly:\n\t\t\t\t\t(tablename,source-uri), where source-uri can also have\n\t\t\t\t\ta param: scheme.">\n\t\t\t</inputKey>\n\t\t\t<FEED source="//pql#DALIPars">\n\t\t\t\t<PRUNE name="VERB"/>\n\t\t\t</FEED>\n\t\t</inputTable>'
managedAttrs = {'id': <gavo.base.parsecontext.IdAttribute object>, 'inputTable': <gavo.base.complexattrs.StructAttribute object>, 'original': <gavo.base.parsecontext.OriginalAttribute object>, 'outputTable': <gavo.base.complexattrs.StructAttribute object>, 'properties': <gavo.base.complexattrs.PropertyAttribute object>, 'property': <gavo.base.complexattrs.PropertyAttribute object>, 'rd': <gavo.rscdef.common.RDAttribute object>}
name_ = 'tapCore'
property rd
run(service, inputTable, queryMeta)[source]
setProperty(name, value)
workerSystem = <gavo.protocols.tap.TAPUWS object>
exception gavo.protocols.tap.TAPError(msg, jobId=None, sourceEx=None, hint=None)[source]

Bases: UWSError

here for backward compatibility.

Deprecated.

class gavo.protocols.tap.TAPJob(props, uws, writable=False)[source]

Bases: UWSJobWithWD

prepareForDestruction()[source]

is called before the job’s database row is torn down.

Self is writable at this point.

property quote

returns an estimation of the job completion.

This currently is very naive: we give each job that’s going to run before this one 10 minutes.

This method needs to be changed when the dequeueing algorithm is changed.

class gavo.protocols.tap.TAPTransitions[source]

Bases: ProcessBasedUWSTransitions

The transition function for TAP jobs.

There’s a hack here: After each transition, when you’ve released your lock on the job, call checkProcessQueue (in reality, only PhaseAction does this).

completeJob(newPhase, wjob, ignored)[source]

pushes a job into the completed state.

errorOutJob(newPhase, wjob, ignored)[source]

pushes a job to an error state.

This is called by a worker; leaving the error message itself is part of the worker’s duty; here, exception will just be logged.

getCommandLine(wjob)[source]
killJob(newPhase, wjob, ignored)[source]

tries to kill/abort job.

Actually, there are two different scenarios here: Either the job has a non-NULL startTime. In that case, the child job is in control and will manage the state itself. Then kill -INT will do the right thing.

However, if startTime is NULL, the child is still starting up. Sending a kill -INT may do many things, and most of them we don’t want. So, in this case we kill -TERM the child, do state management ourselves and hope for the best.

queueJob(newState, wjob, ignored)[source]

puts a job on the queue.

class gavo.protocols.tap.TAPUWS[source]

Bases: UWSWithQueueing

The UWS responsible for processing async TAP requests.

property baseURL
getURLForId(jobId)[source]

returns a fully qualified URL for the job with jobId.

jobdocPreamble = "<?xml-stylesheet href='/static/xsl/tap-job-to-html.xsl' type='text/xsl'?>"
joblistPreamble = "<?xml-stylesheet href='/static/xsl/tap-joblist-to-html.xsl' type='text/xsl'?>"
property parameterGrammar

A grammar to be used to process parameters in UWS calls.

gavo.protocols.tap.getAccessibleTables()[source]

returns a list of qualified table names for the TAP-published tables.

gavo.protocols.tap.getSupportedLanguages()[source]

returns a list of tuples for the supported languages.

This is SUPPORTED_LANGUAGES in a format suitable for the TAP capabilities element.

Each tuple returned is made up of (name, description, [(version, ivo-id)…]).

gavo.protocols.tap.getSupportedOutputFormats()[source]

yields tuples for the supported output formats.

This is OUTPUT_FORMATS in a format suitable for the TAP capabilities element.

Each tuple is made up of (mime, aliases, description, ivoId).

gavo.protocols.tap.getUploadGrammar()[source]
gavo.protocols.tap.mangleUploads(request)[source]

parses TAP-compliant UPLOAD specifications in request and return something that the core can handle.

This is being executed from the sync/async renderers and probably can’t be used anywhere else.

The underlying trouble is that the core cannot see the request any more, and thus could not resolve param: uploads.

Since this is different in TAP than in DALI, we have extra code here vs. dali.mangleUploads.

gavo.protocols.tap.parseUploadString(uploadString)[source]

iterates over pairs of tableName, uploadSource from a TAP upload string.

gavo.protocols.tap.publishToTAP(rd, connection)[source]

publishes info for all ADQL-enabled tables of rd to the TAP_SCHEMA.

gavo.protocols.tap.unpublishFromTAP(rd, connection)[source]

removes all information originating from rd from TAP_SCHEMA.