|
def | applyOverrides (cls, config) |
|
def | parseAndRun (cls, args=None, config=None, log=None, doReturnResults=False) |
|
def | writeConfig (self, butler, clobber=False, doBackup=True) |
|
def | writeSchemas (self, butler, clobber=False, doBackup=True) |
|
def | writeMetadata (self, dataRef) |
|
def | writePackageVersions (self, butler, clobber=False, doBackup=True, dataset="packages") |
|
def | emptyMetadata (self) |
|
def | getSchemaCatalogs (self) |
|
def | getAllSchemaCatalogs (self) |
|
def | getFullMetadata (self) |
|
def | getFullName (self) |
|
def | getName (self) |
|
def | getTaskDict (self) |
|
def | makeSubtask (self, name, **keyArgs) |
|
def | timer (self, name, logLevel=Log.DEBUG) |
|
def | makeField (cls, doc) |
|
def | __reduce__ (self) |
|
Base class for command-line tasks: tasks that may be executed from the
command-line.
Notes
-----
See :ref:`task-framework-overview` to learn what tasks are and
:ref:`creating-a-command-line-task` for more information about writing
command-line tasks.
Subclasses must specify the following class variables:
- ``ConfigClass``: configuration class for your task (a subclass of
`lsst.pex.config.Config`, or if your task needs no configuration, then
`lsst.pex.config.Config` itself).
- ``_DefaultName``: default name used for this task (a `str`).
Subclasses may also specify the following class variables:
- ``RunnerClass``: a task runner class. The default is ``TaskRunner``,
which works for any task with a runDataRef method that takes exactly one
argument: a data reference. If your task does not meet this requirement
then you must supply a variant of ``TaskRunner``; see ``TaskRunner``
for more information.
- ``canMultiprocess``: the default is `True`; set `False` if your task
does not support multiprocessing.
Subclasses must specify a method named ``runDataRef``:
- By default ``runDataRef`` accepts a single butler data reference, but
you can specify an alternate task runner (subclass of ``TaskRunner``) as
the value of class variable ``RunnerClass`` if your run method needs
something else.
- ``runDataRef`` is expected to return its data in a
`lsst.pipe.base.Struct`. This provides safety for evolution of the task
since new values may be added without harming existing code.
- The data returned by ``runDataRef`` must be picklable if your task is to
support multiprocessing.
Definition at line 544 of file cmdLineTask.py.
def lsst.pipe.base.task.Task.getAllSchemaCatalogs |
( |
|
self | ) |
|
|
inherited |
Get schema catalogs for all tasks in the hierarchy, combining the
results into a single dict.
Returns
-------
schemacatalogs : `dict`
Keys are butler dataset type, values are a empty catalog (an
instance of the appropriate `lsst.afw.table` Catalog type) for all
tasks in the hierarchy, from the top-level task down
through all subtasks.
Notes
-----
This method may be called on any task in the hierarchy; it will return
the same answer, regardless.
The default implementation should always suffice. If your subtask uses
schemas the override `Task.getSchemaCatalogs`, not this method.
Definition at line 204 of file task.py.
def lsst.pipe.base.task.Task.getFullMetadata |
( |
|
self | ) |
|
|
inherited |
Get metadata for all tasks.
Returns
-------
metadata : `lsst.daf.base.PropertySet`
The `~lsst.daf.base.PropertySet` keys are the full task name.
Values are metadata for the top-level task and all subtasks,
sub-subtasks, etc.
Notes
-----
The returned metadata includes timing information (if
``@timer.timeMethod`` is used) and any metadata set by the task. The
name of each item consists of the full task name with ``.`` replaced
by ``:``, followed by ``.`` and the name of the item, e.g.::
topLevelTaskName:subtaskName:subsubtaskName.itemName
using ``:`` in the full task name disambiguates the rare situation
that a task has a subtask and a metadata item with the same name.
Definition at line 229 of file task.py.
def lsst.pipe.base.task.Task.getSchemaCatalogs |
( |
|
self | ) |
|
|
inherited |
Get the schemas generated by this task.
Returns
-------
schemaCatalogs : `dict`
Keys are butler dataset type, values are an empty catalog (an
instance of the appropriate `lsst.afw.table` Catalog type) for
this task.
Notes
-----
.. warning::
Subclasses that use schemas must override this method. The default
implementation returns an empty dict.
This method may be called at any time after the Task is constructed,
which means that all task schemas should be computed at construction
time, *not* when data is actually processed. This reflects the
philosophy that the schema should not depend on the data.
Returning catalogs rather than just schemas allows us to save e.g.
slots for SourceCatalog as well.
See also
--------
Task.getAllSchemaCatalogs
Definition at line 172 of file task.py.
def lsst.pipe.base.cmdLineTask.CmdLineTask.parseAndRun |
( |
|
cls, |
|
|
|
args = None , |
|
|
|
config = None , |
|
|
|
log = None , |
|
|
|
doReturnResults = False |
|
) |
| |
Parse an argument list and run the command.
Parameters
----------
args : `list`, optional
List of command-line arguments; if `None` use `sys.argv`.
config : `lsst.pex.config.Config`-type, optional
Config for task. If `None` use `Task.ConfigClass`.
log : `lsst.log.Log`-type, optional
Log. If `None` use the default log.
doReturnResults : `bool`, optional
If `True`, return the results of this task. Default is `False`.
This is only intended for unit tests and similar use. It can
easily exhaust memory (if the task returns enough data and you
call it enough times) and it will fail when using multiprocessing
if the returned data cannot be pickled.
Returns
-------
struct : `lsst.pipe.base.Struct`
Fields are:
``argumentParser``
the argument parser (`lsst.pipe.base.ArgumentParser`).
``parsedCmd``
the parsed command returned by the argument parser's
`~lsst.pipe.base.ArgumentParser.parse_args` method
(`argparse.Namespace`).
``taskRunner``
the task runner used to run the task (an instance of
`Task.RunnerClass`).
``resultList``
results returned by the task runner's ``run`` method, one entry
per invocation (`list`). This will typically be a list of
`Struct`, each containing at least an ``exitStatus`` integer
(0 or 1); see `Task.RunnerClass` (`TaskRunner` by default) for
more details.
Notes
-----
Calling this method with no arguments specified is the standard way to
run a command-line task from the command-line. For an example see
``pipe_tasks`` ``bin/makeSkyMap.py`` or almost any other file in that
directory.
If one or more of the dataIds fails then this routine will exit (with
a status giving the number of failed dataIds) rather than returning
this struct; this behaviour can be overridden by specifying the
``--noExit`` command-line option.
Definition at line 612 of file cmdLineTask.py.
def lsst.pipe.base.cmdLineTask.CmdLineTask.writeConfig |
( |
|
self, |
|
|
|
butler, |
|
|
|
clobber = False , |
|
|
|
doBackup = True |
|
) |
| |
Write the configuration used for processing the data, or check that
an existing one is equal to the new one if present.
Parameters
----------
butler : `lsst.daf.persistence.Butler`
Data butler used to write the config. The config is written to
dataset type `CmdLineTask._getConfigName`.
clobber : `bool`, optional
A boolean flag that controls what happens if a config already has
been saved:
- `True`: overwrite or rename the existing config, depending on
``doBackup``.
- `False`: raise `TaskError` if this config does not match the
existing config.
doBackup : bool, optional
Set to `True` to backup the config files if clobbering.
Definition at line 727 of file cmdLineTask.py.
def lsst.pipe.base.cmdLineTask.CmdLineTask.writePackageVersions |
( |
|
self, |
|
|
|
butler, |
|
|
|
clobber = False , |
|
|
|
doBackup = True , |
|
|
|
dataset = "packages" |
|
) |
| |
Compare and write package versions.
Parameters
----------
butler : `lsst.daf.persistence.Butler`
Data butler used to read/write the package versions.
clobber : `bool`, optional
A boolean flag that controls what happens if versions already have
been saved:
- `True`: overwrite or rename the existing version info, depending
on ``doBackup``.
- `False`: raise `TaskError` if this version info does not match
the existing.
doBackup : `bool`, optional
If `True` and clobbering, old package version files are backed up.
dataset : `str`, optional
Name of dataset to read/write.
Raises
------
TaskError
Raised if there is a version mismatch with current and persisted
lists of package versions.
Notes
-----
Note that this operation is subject to a race condition.
Definition at line 827 of file cmdLineTask.py.
def lsst.pipe.base.cmdLineTask.CmdLineTask.writeSchemas |
( |
|
self, |
|
|
|
butler, |
|
|
|
clobber = False , |
|
|
|
doBackup = True |
|
) |
| |
Write the schemas returned by
`lsst.pipe.base.Task.getAllSchemaCatalogs`.
Parameters
----------
butler : `lsst.daf.persistence.Butler`
Data butler used to write the schema. Each schema is written to the
dataset type specified as the key in the dict returned by
`~lsst.pipe.base.Task.getAllSchemaCatalogs`.
clobber : `bool`, optional
A boolean flag that controls what happens if a schema already has
been saved:
- `True`: overwrite or rename the existing schema, depending on
``doBackup``.
- `False`: raise `TaskError` if this schema does not match the
existing schema.
doBackup : `bool`, optional
Set to `True` to backup the schema files if clobbering.
Notes
-----
If ``clobber`` is `False` and an existing schema does not match a
current schema, then some schemas may have been saved successfully
and others may not, and there is no easy way to tell which is which.
Definition at line 770 of file cmdLineTask.py.