lsst.pipe.base  13.0-11-gdf6a56c+7
 All Classes Namespaces Files Functions Variables Pages
Public Member Functions | Public Attributes | List of all members
lsst.pipe.base.task.Task Class Reference

Base class for data processing tasks. More...

Inheritance diagram for lsst.pipe.base.task.Task:

Public Member Functions

def __init__
 Create a Task. More...
 
def emptyMetadata
 Empty (clear) the metadata for this Task and all sub-Tasks. More...
 
def getSchemaCatalogs
 Return the schemas generated by this task. More...
 
def getAllSchemaCatalogs
 Call getSchemaCatalogs() on all tasks in the hiearchy, combining the results into a single dict. More...
 
def getFullMetadata
 Get metadata for all tasks. More...
 
def getFullName
 Return the task name as a hierarchical name including parent task names. More...
 
def getName
 Return the name of the task. More...
 
def getTaskDict
 Return a dictionary of all tasks as a shallow copy. More...
 
def makeSubtask
 Create a subtask as a new instance self. More...
 
def timer
 Context manager to log performance data for an arbitrary block of code. More...
 
def makeField
 Make an lsst.pex.config.ConfigurableField for this task. More...
 
def __reduce__
 

Public Attributes

 metadata
 
 log
 
 config
 

Detailed Description

Base class for data processing tasks.

See pipe_base introduction to learn what tasks are, and how to write a task for more information about writing tasks. If the second link is broken (as it will be before the documentation is cross-linked) then look at the main page of pipe_tasks documentation for a link.

Useful attributes include:

Subclasses typically have a method named "run" to perform the main data processing. Details:

Deprecated:
Tasks other than cmdLineTask.CmdLineTasks should not accept a blob such as a butler data reference. How we will handle data references is still TBD, so don't make changes yet! RHL 2014-06-27

Subclasses must also have an attribute ConfigClass that is a subclass of lsst.pex.config.Config which configures the task. Subclasses should also have an attribute _DefaultName: the default name if there is no parent task. _DefaultName is required for subclasses of CmdLineTask and recommended for subclasses of Task because it simplifies construction (e.g. for unit tests).

Tasks intended to be run from the command line should be subclasses of CmdLineTask, not Task.

Definition at line 46 of file task.py.

Constructor & Destructor Documentation

def lsst.pipe.base.task.Task.__init__ (   self,
  config = None,
  name = None,
  parentTask = None,
  log = None 
)

Create a Task.

Parameters
[in]configconfiguration for this task (an instance of self.ConfigClass, which is a task-specific subclass of lsst.pex.config.Config), or None. If None:
  • If parentTask specified then defaults to parentTask.config.<name>
  • If parentTask is None then defaults to self.ConfigClass()
[in]namebrief name of task, or None; if None then defaults to self._DefaultName
[in]parentTaskthe parent task of this subtask, if any.
  • If None (a top-level task) then you must specify config and name is ignored.
  • If not None (a subtask) then you must specify name
[in]loglog (an lsst.log.Log) whose name is used as a log name prefix, or None for no prefix. Ignored if parentTask specifie, in which case parentTask.log's name is used as a prefix. The task's log name is prefix + "." + name if a prefix exists, else name. The task's log is then a child logger of parentTask.log (if parentTask specified), or a child logger of the log from the argument (if log is not None).
Exceptions
RuntimeErrorif parentTask is None and config is None.
RuntimeErrorif parentTask is not None and name is None.
RuntimeErrorif name is None and _DefaultName does not exist.

Definition at line 84 of file task.py.

Member Function Documentation

def lsst.pipe.base.task.Task.__reduce__ (   self)
Pickler

Definition at line 290 of file task.py.

def lsst.pipe.base.task.Task.emptyMetadata (   self)

Empty (clear) the metadata for this Task and all sub-Tasks.

Definition at line 138 of file task.py.

def lsst.pipe.base.task.Task.getAllSchemaCatalogs (   self)

Call getSchemaCatalogs() on all tasks in the hiearchy, combining the results into a single dict.

Returns
a dict of butler dataset type: 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

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 162 of file task.py.

def lsst.pipe.base.task.Task.getFullMetadata (   self)

Get metadata for all tasks.

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.: topLeveltTaskName: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.

Returns
metadata: an lsst.daf.base.PropertySet containing full task name: metadata for the top-level task and all subtasks, sub-subtasks, etc.

Definition at line 179 of file task.py.

def lsst.pipe.base.task.Task.getFullName (   self)

Return the task name as a hierarchical name including parent task names.

The full name consists of the name of the parent task and each subtask separated by periods. For example:

  • The full name of top-level task "top" is simply "top"
  • The full name of subtask "sub" of top-level task "top" is "top.sub"
  • The full name of subtask "sub2" of subtask "sub" of top-level task "top" is "top.sub.sub2".

Definition at line 197 of file task.py.

def lsst.pipe.base.task.Task.getName (   self)

Return the name of the task.

See getFullName to get a hierarchical name including parent task names

Definition at line 208 of file task.py.

def lsst.pipe.base.task.Task.getSchemaCatalogs (   self)

Return the schemas generated by this task.

Warning
Subclasses the use schemas must override this method. The default implemenation returns an empty dict.
Returns
a dict of butler dataset type: empty catalog (an instance of the appropriate lsst.afw.table Catalog type) for this task

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 143 of file task.py.

def lsst.pipe.base.task.Task.getTaskDict (   self)

Return a dictionary of all tasks as a shallow copy.

Returns
taskDict: a dict containing full task name: task object for the top-level task and all subtasks, sub-subtasks, etc.

Definition at line 215 of file task.py.

def lsst.pipe.base.task.Task.makeField (   cls,
  doc 
)

Make an lsst.pex.config.ConfigurableField for this task.

Provides a convenient way to specify this task is a subtask of another task. Here is an example of use:

1 class OtherTaskConfig(lsst.pex.config.Config)
2  aSubtask = ATaskClass.makeField("a brief description of what this task does")
Parameters
[in]clsthis class
[in]dochelp text for the field
Returns
a lsst.pex.config.ConfigurableField for this task

Definition at line 263 of file task.py.

def lsst.pipe.base.task.Task.makeSubtask (   self,
  name,
  keyArgs 
)

Create a subtask as a new instance self.

<name>

The subtask must be defined by self.config.<name>, an instance of pex_config ConfigurableField or RegistryField.

Parameters
namebrief name of subtask
**keyArgsextra keyword arguments used to construct the task. The following arguments are automatically provided and cannot be overridden: "config" and "parentTask".

Definition at line 223 of file task.py.

def lsst.pipe.base.task.Task.timer (   self,
  name,
  logLevel = Log.DEBUG 
)

Context manager to log performance data for an arbitrary block of code.

Parameters
[in]namename of code being timed; data will be logged using item name: <name>Start<item> and <name>End<item>
[in]logLevelone of the lsst.log.Log level constants

Example of use:

1 with self.timer("someCodeToTime"):
2  ...code to time...

See timer.logInfo for the information logged

Definition at line 241 of file task.py.

Member Data Documentation

lsst.pipe.base.task.Task.config

Definition at line 134 of file task.py.

lsst.pipe.base.task.Task.log

Definition at line 133 of file task.py.

lsst.pipe.base.task.Task.metadata

Definition at line 106 of file task.py.


The documentation for this class was generated from the following file: