legacy helpers

Legacy helpers for Data Lab. Most are deprecated.

class legacy.Querist(username='anonymous')[source]
__call__(query=None, outfmt='array', preview=0, async=False)[source]

Submit query string via queryClient.query(), and process the result.

  • query (str or None) –

    The query string (sql). Example:

    query = "SELECT ra,dec,g FROM ls_dr3.tractor_primary WHERE g != 'nan'"

    If None, and the async FIFO queue is not empty, this triggers an attempt to retrieve the query results for the first async job in int queue. See below for more details.

  • outfmt (str) –

    Desired output container type. The result of a query will be returned in this format. Possible values are:

    'string' (default) – A table as comma-separated string.

    'array' – Numpy array, with shape (ncols,nrows)

    'array' – Numpy structured / record array, with shape (ncols,), and column names.

    'pandas' – Pandas dataframe.

    'table' – Astropy.table Table object.

    'votable' – Astropy.io.votable. Note that this is much slower than e.g. ‘pandas’ or ‘array’.

  • preview (int) – Number of lines to preview on STDOUT. This does not count the header line. If outfmt=’votable’, preview is not very useful, because of the XML that votable carries around. Default: 0
  • async (bool) –

    If False (default), submit queries in sync mode, i.e. expecting results immediately.

    If True, submit query in async mode, storing the jobid in a FIFO queue (first-in-first-out). A subsequent call without arguments will attempt to retrieve the query result. If the query status is not yet COMPLETED, the jobid is re-inserted into the queue (at old position), and the user is instructed to try later.

    Not yet implemented: automatic re-submission of a sync query in async mode, if the queryManager / DB raise Exception that “the query not suitable for sync mode”.


Helper class to authenticate user with Data Lab, run queries, and convert results to the requested data type.

Parameters:username (str) –

User name, will be supplied to authClient.login() to obtain an authentication token. The default username is ‘anonymous’, which obtains an anonymous access token from authClient.login().

Other user names will trigger a password prompt.

The token can be cleared by calling clearToken().

__module__ = 'legacy'

Check the first async job in the FIFO queue (if queue is not empty).

  • Always returns a 3 tuple. If no async job was in the queue,
  • returns (None,None,None). If there was an async query in the
  • queue but its status did not return ‘COMPLETED’, re-inserts
  • the query at its old position in the queue, and returns
  • (None,None,None). If the status was ‘COMPLETED’, returns the
  • tuple (query result,outfmt,preview).

Clears the async job queue, i.e. they become unretrievable.


Sets to token to empty string. Useful e.g. before saving a notebook.


Pretty-print to STDOUT the available outfmt values.

Return type:Nothing

Pretty-print to STDOUT the available outfmt values.

Return type:Nothing