lsst.pipe.base
13.0-12-gaf0c0ec+8
|
Base class for data processing tasks. More...
Public Member Functions | |
def | __init__ (self, config=None, name=None, parentTask=None, log=None) |
Create a Task. More... | |
def | emptyMetadata (self) |
Empty (clear) the metadata for this Task and all sub-Tasks. More... | |
def | getSchemaCatalogs (self) |
Return the schemas generated by this task. More... | |
def | getAllSchemaCatalogs (self) |
Call getSchemaCatalogs() on all tasks in the hiearchy, combining the results into a single dict. More... | |
def | getFullMetadata (self) |
Get metadata for all tasks. More... | |
def | getFullName (self) |
Return the task name as a hierarchical name including parent task names. More... | |
def | getName (self) |
Return the name of the task. More... | |
def | getTaskDict (self) |
Return a dictionary of all tasks as a shallow copy. More... | |
def | makeSubtask (self, name, keyArgs) |
Create a subtask as a new instance self. More... | |
def | timer (self, name, logLevel=Log.DEBUG) |
Context manager to log performance data for an arbitrary block of code. More... | |
def | makeField (cls, doc) |
Make an lsst.pex.config.ConfigurableField for this task. More... | |
def | __reduce__ (self) |
Public Attributes | |
metadata | |
log | |
config | |
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:
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.
def lsst.pipe.base.task.Task.__init__ | ( | self, | |
config = None , |
|||
name = None , |
|||
parentTask = None , |
|||
log = None |
|||
) |
Create a Task.
[in] | config | configuration for this task (an instance of self.ConfigClass, which is a task-specific subclass of lsst.pex.config.Config), or None. If None:
|
[in] | name | brief name of task, or None; if None then defaults to self._DefaultName |
[in] | parentTask | the parent task of this subtask, if any.
|
[in] | log | log (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). |
RuntimeError | if parentTask is None and config is None. |
RuntimeError | if parentTask is not None and name is None. |
RuntimeError | if name is None and _DefaultName does not exist. |
def lsst.pipe.base.task.Task.emptyMetadata | ( | self | ) |
def lsst.pipe.base.task.Task.getAllSchemaCatalogs | ( | self | ) |
Call getSchemaCatalogs() on all tasks in the hiearchy, combining the results into a single dict.
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.
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.
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:
def lsst.pipe.base.task.Task.getName | ( | self | ) |
def lsst.pipe.base.task.Task.getSchemaCatalogs | ( | self | ) |
Return the schemas generated by 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
def lsst.pipe.base.task.Task.getTaskDict | ( | self | ) |
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:
[in] | cls | this class |
[in] | doc | help text for the field |
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.
name | brief name of subtask |
**keyArgs | extra keyword arguments used to construct the task. The following arguments are automatically provided and cannot be overridden: "config" and "parentTask". |
def lsst.pipe.base.task.Task.timer | ( | self, | |
name, | |||
logLevel = Log.DEBUG |
|||
) |
Context manager to log performance data for an arbitrary block of code.
[in] | name | name of code being timed; data will be logged using item name: <name>Start<item> and <name>End<item> |
[in] | logLevel | one of the lsst.log.Log level constants |
Example of use:
See timer.logInfo for the information logged