Base class for command-line tasks: tasks that may be executed from the command line. More...
Public Member Functions | |
def | applyOverrides |
A hook to allow a task to change the values of its config after the camera-specific overrides are loaded but before any command-line overrides are applied. More... | |
def | parseAndRun |
Parse an argument list and run the command. More... | |
def | writeConfig |
Write the configuration used for processing the data, or check that an existing one is equal to the new one if present. More... | |
def | writeSchemas |
Write the schemas returned by getAllSchemaCatalogs. More... | |
def | writeMetadata |
Write the metadata produced from processing the data. More... | |
def | writePackageVersions |
Compare and write package versions. More... | |
Static Public Attributes | |
RunnerClass = TaskRunner | |
canMultiprocess = True | |
Base class for command-line tasks: tasks that may be executed from the command line.
See pipe_base introduction to learn what tasks are, and how to write a command-line task for more information about writing command-line 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.
Subclasses must specify the following class variables:
Subclasses may also specify the following class variables:
Subclasses must specify a method named "run":
run
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.run
is expected to return its data in a Struct. This provides safety for evolution of the task since new values may be added without harming existing code.run
must be picklable if your task is to support multiprocessing. Definition at line 426 of file cmdLineTask.py.
def lsst.pipe.base.cmdLineTask.CmdLineTask.applyOverrides | ( | cls, | |
config | |||
) |
A hook to allow a task to change the values of its config after the camera-specific overrides are loaded but before any command-line overrides are applied.
This is necessary in some cases because the camera-specific overrides may retarget subtasks, wiping out changes made in ConfigClass.setDefaults. See LSST Trac ticket #2282 for more discussion.
[in] | cls | the class object |
[in] | config | task configuration (an instance of cls.ConfigClass) |
Definition at line 460 of file cmdLineTask.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.
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.
cls | the class object |
args | list of command-line arguments; if None use sys.argv |
config | config for task (instance of pex_config Config); if None use cls.ConfigClass() |
log | log (instance of lsst.log.Log); if None use the default log |
doReturnResults | Return the collected results from each invocation of the task? 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. |
None
unless doReturnResults is True
; see cls.RunnerClass (TaskRunner by default) for more information. Definition at line 476 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.
[in] | butler | data butler used to write the config. The config is written to dataset type self._getConfigName() |
[in] | clobber | a boolean flag that controls what happens if a config already has been saved:
|
[in] | doBackup | if clobbering, should we backup the old files? |
Definition at line 541 of file cmdLineTask.py.
def lsst.pipe.base.cmdLineTask.CmdLineTask.writeMetadata | ( | self, | |
dataRef | |||
) |
Write the metadata produced from processing the data.
[in] | dataRef | butler data reference used to write the metadata. The metadata is written to dataset type self._getMetadataName() |
Definition at line 605 of file cmdLineTask.py.
def lsst.pipe.base.cmdLineTask.CmdLineTask.writePackageVersions | ( | self, | |
butler, | |||
clobber = False , |
|||
doBackup = True , |
|||
dataset = "packages" |
|||
) |
Compare and write package versions.
We retrieve the persisted list of packages and compare with what we're currently using. We raise TaskError if there's a version mismatch.
Note that this operation is subject to a race condition.
[in] | butler | data butler used to read/write the package versions |
[in] | clobber | a boolean flag that controls what happens if versions already have been saved:
|
[in] | doBackup | if clobbering, should we backup the old files? |
[in] | dataset | name of dataset to read/write |
Definition at line 618 of file cmdLineTask.py.
def lsst.pipe.base.cmdLineTask.CmdLineTask.writeSchemas | ( | self, | |
butler, | |||
clobber = False , |
|||
doBackup = True |
|||
) |
Write the schemas returned by getAllSchemaCatalogs.
[in] | 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 getAllSchemaCatalogs. |
[in] | clobber | a boolean flag that controls what happens if a schema already has been saved:
|
[in] | doBackup | if clobbering, should we backup the old files? |
Definition at line 576 of file cmdLineTask.py.
|
static |
Definition at line 457 of file cmdLineTask.py.
|
static |
Definition at line 456 of file cmdLineTask.py.