LSST Applications  21.0.0+04719a4bac,21.0.0-1-ga51b5d4+f5e6047307,21.0.0-11-g2b59f77+a9c1acf22d,21.0.0-11-ga42c5b2+86977b0b17,21.0.0-12-gf4ce030+76814010d2,21.0.0-13-g1721dae+760e7a6536,21.0.0-13-g3a573fe+768d78a30a,21.0.0-15-g5a7caf0+f21cbc5713,21.0.0-16-g0fb55c1+b60e2d390c,21.0.0-19-g4cded4ca+71a93a33c0,21.0.0-2-g103fe59+bb20972958,21.0.0-2-g45278ab+04719a4bac,21.0.0-2-g5242d73+3ad5d60fb1,21.0.0-2-g7f82c8f+8babb168e8,21.0.0-2-g8f08a60+06509c8b61,21.0.0-2-g8faa9b5+616205b9df,21.0.0-2-ga326454+8babb168e8,21.0.0-2-gde069b7+5e4aea9c2f,21.0.0-2-gecfae73+1d3a86e577,21.0.0-2-gfc62afb+3ad5d60fb1,21.0.0-25-g1d57be3cd+e73869a214,21.0.0-3-g357aad2+ed88757d29,21.0.0-3-g4a4ce7f+3ad5d60fb1,21.0.0-3-g4be5c26+3ad5d60fb1,21.0.0-3-g65f322c+e0b24896a3,21.0.0-3-g7d9da8d+616205b9df,21.0.0-3-ge02ed75+a9c1acf22d,21.0.0-4-g591bb35+a9c1acf22d,21.0.0-4-g65b4814+b60e2d390c,21.0.0-4-gccdca77+0de219a2bc,21.0.0-4-ge8a399c+6c55c39e83,21.0.0-5-gd00fb1e+05fce91b99,21.0.0-6-gc675373+3ad5d60fb1,21.0.0-64-g1122c245+4fb2b8f86e,21.0.0-7-g04766d7+cd19d05db2,21.0.0-7-gdf92d54+04719a4bac,21.0.0-8-g5674e7b+d1bd76f71f,master-gac4afde19b+a9c1acf22d,w.2021.13
LSST Data Management Base Package
Public Member Functions | Public Attributes | Static Public Attributes | List of all members
lsst.pipe.drivers.multiBandDriver.MultiBandDriverTask Class Reference
Inheritance diagram for lsst.pipe.drivers.multiBandDriver.MultiBandDriverTask:
lsst.ctrl.pool.parallel.BatchPoolTask lsst.ctrl.pool.parallel.BatchCmdLineTask lsst.pipe.base.cmdLineTask.CmdLineTask lsst.pipe.base.task.Task

Public Member Functions

def __init__ (self, butler=None, schema=None, refObjLoader=None, reuse=tuple(), **kwargs)
 
def __reduce__ (self)
 
def batchWallTime (cls, time, parsedCmd, numCpus)
 Return walltime request for batch job. More...
 
def runDataRef (self, patchRefList)
 Run multiband processing on coadds. More...
 
def runDetection (self, cache, patchRef)
 Run detection on a patch. More...
 
def runMergeDetections (self, cache, dataIdList)
 Run detection merging on a patch. More...
 
def runDeblendMerged (self, cache, dataIdList)
 
def runMeasurements (self, cache, dataId)
 
def runMergeMeasurements (self, cache, dataIdList)
 Run measurement merging on a patch. More...
 
def runForcedPhot (self, cache, dataId)
 Run forced photometry on a patch for a single filter. More...
 
def writeMetadata (self, dataRef)
 
def parseAndRun (cls, *args, **kwargs)
 
def parseAndRun (cls, args=None, config=None, log=None, doReturnResults=False)
 
def parseAndSubmit (cls, args=None, **kwargs)
 
def batchCommand (cls, args)
 Return command to run CmdLineTask. More...
 
def logOperation (self, operation, catch=False, trace=True)
 Provide a context manager for logging an operation. More...
 
def applyOverrides (cls, config)
 
def writeConfig (self, butler, clobber=False, doBackup=True)
 
def writeSchemas (self, butler, clobber=False, doBackup=True)
 
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)
 

Public Attributes

 butler
 
 reuse
 
 measurementInput
 
 deblenderOutput
 
 coaddType
 
 metadata
 
 log
 
 config
 

Static Public Attributes

 ConfigClass = MultiBandDriverConfig
 
 RunnerClass = MultiBandDriverTaskRunner
 
bool canMultiprocess = True
 

Detailed Description

Multi-node driver for multiband processing

Definition at line 95 of file multiBandDriver.py.

Constructor & Destructor Documentation

◆ __init__()

def lsst.pipe.drivers.multiBandDriver.MultiBandDriverTask.__init__ (   self,
  butler = None,
  schema = None,
  refObjLoader = None,
  reuse = tuple(),
**  kwargs 
)
Parameters
[in]butlerthe butler can be used to retrieve schema or passed to the refObjLoader constructor in case it is needed.
[in]schemathe schema of the source detection catalog used as input.
[in]refObjLoaderan instance of LoadReferenceObjectsTasks that supplies an external reference catalog. May be None if the butler argument is provided or all steps requiring a reference catalog are disabled.

Definition at line 101 of file multiBandDriver.py.

101  def __init__(self, butler=None, schema=None, refObjLoader=None, reuse=tuple(), **kwargs):
102  """!
103  @param[in] butler: the butler can be used to retrieve schema or passed to the refObjLoader constructor
104  in case it is needed.
105  @param[in] schema: the schema of the source detection catalog used as input.
106  @param[in] refObjLoader: an instance of LoadReferenceObjectsTasks that supplies an external reference
107  catalog. May be None if the butler argument is provided or all steps requiring a reference
108  catalog are disabled.
109  """
110  BatchPoolTask.__init__(self, **kwargs)
111  if schema is None:
112  assert butler is not None, "Butler not provided"
113  schema = butler.get(self.config.coaddName +
114  "Coadd_det_schema", immediate=True).schema
115  self.butler = butler
116  self.reuse = tuple(reuse)
117  self.makeSubtask("detectCoaddSources")
118  self.makeSubtask("mergeCoaddDetections", schema=schema)
119  if self.config.measureCoaddSources.inputCatalog.startswith("deblended"):
120  # Ensure that the output from deblendCoaddSources matches the input to measureCoaddSources
121  self.measurementInput = self.config.measureCoaddSources.inputCatalog
122  self.deblenderOutput = []
123  self.deblenderOutput.append("deblendedFlux")
124  if self.measurementInput not in self.deblenderOutput:
125  err = "Measurement input '{0}' is not in the list of deblender output catalogs '{1}'"
126  raise ValueError(err.format(self.measurementInput, self.deblenderOutput))
127 
128  self.makeSubtask("deblendCoaddSources",
129  schema=afwTable.Schema(self.mergeCoaddDetections.schema),
130  peakSchema=afwTable.Schema(self.mergeCoaddDetections.merged.getPeakSchema()),
131  butler=butler)
132  measureInputSchema = afwTable.Schema(self.deblendCoaddSources.schema)
133  else:
134  measureInputSchema = afwTable.Schema(self.mergeCoaddDetections.schema)
135  self.makeSubtask("measureCoaddSources", schema=measureInputSchema,
136  peakSchema=afwTable.Schema(
137  self.mergeCoaddDetections.merged.getPeakSchema()),
138  refObjLoader=refObjLoader, butler=butler)
139  self.makeSubtask("mergeCoaddMeasurements", schema=afwTable.Schema(
140  self.measureCoaddSources.schema))
141  self.makeSubtask("forcedPhotCoadd", refSchema=afwTable.Schema(
142  self.mergeCoaddMeasurements.schema))
143  if self.config.hasFakes:
144  self.coaddType = "fakes_" + self.config.coaddName
145  else:
146  self.coaddType = self.config.coaddName
147 
Defines the fields and offsets for a table.
Definition: Schema.h:50
std::shared_ptr< FrameSet > append(FrameSet const &first, FrameSet const &second)
Construct a FrameSet that performs two transformations in series.
Definition: functional.cc:33

Member Function Documentation

◆ __reduce__()

def lsst.pipe.drivers.multiBandDriver.MultiBandDriverTask.__reduce__ (   self)
Pickler

Reimplemented from lsst.pipe.base.task.Task.

Definition at line 148 of file multiBandDriver.py.

148  def __reduce__(self):
149  """Pickler"""
150  return unpickle, (self.__class__, [], dict(config=self.config, name=self._name,
151  parentTask=self._parentTask, log=self.log,
152  butler=self.butler, reuse=self.reuse))
153 

◆ applyOverrides()

def lsst.pipe.base.cmdLineTask.CmdLineTask.applyOverrides (   cls,
  config 
)
inherited
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.

Parameters
----------
config : instance of task's ``ConfigClass``
    Task configuration.

Notes
-----
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.

.. warning::

   This is called by CmdLineTask.parseAndRun; other ways of
   constructing a config will not apply these overrides.

Reimplemented in lsst.pipe.drivers.constructCalibs.FringeTask, lsst.pipe.drivers.constructCalibs.FlatTask, lsst.pipe.drivers.constructCalibs.DarkTask, and lsst.pipe.drivers.constructCalibs.BiasTask.

Definition at line 587 of file cmdLineTask.py.

587  def applyOverrides(cls, config):
588  """A hook to allow a task to change the values of its config *after*
589  the camera-specific overrides are loaded but before any command-line
590  overrides are applied.
591 
592  Parameters
593  ----------
594  config : instance of task's ``ConfigClass``
595  Task configuration.
596 
597  Notes
598  -----
599  This is necessary in some cases because the camera-specific overrides
600  may retarget subtasks, wiping out changes made in
601  ConfigClass.setDefaults. See LSST Trac ticket #2282 for more
602  discussion.
603 
604  .. warning::
605 
606  This is called by CmdLineTask.parseAndRun; other ways of
607  constructing a config will not apply these overrides.
608  """
609  pass
610 

◆ batchCommand()

def lsst.ctrl.pool.parallel.BatchCmdLineTask.batchCommand (   cls,
  args 
)
inherited

Return command to run CmdLineTask.

    @param cls: Class
    @param args: Parsed batch job arguments (from BatchArgumentParser)

Definition at line 476 of file parallel.py.

476  def batchCommand(cls, args):
477  """!Return command to run CmdLineTask
478 
479  @param cls: Class
480  @param args: Parsed batch job arguments (from BatchArgumentParser)
481  """
482  job = args.job if args.job is not None else "job"
483  module = cls.__module__
484  script = ("import os; os.umask(%#05o); " +
485  "import lsst.base; lsst.base.disableImplicitThreading(); " +
486  "import lsst.ctrl.pool.log; lsst.ctrl.pool.log.jobLog(\"%s\"); ") % (UMASK, job)
487 
488  if args.batchStats:
489  script += ("import lsst.ctrl.pool.parallel; import atexit; " +
490  "atexit.register(lsst.ctrl.pool.parallel.printProcessStats); ")
491 
492  script += "import %s; %s.%s.parseAndRun();" % (module, module, cls.__name__)
493 
494  profilePre = "import cProfile; import os; cProfile.run(\"\"\""
495  profilePost = "\"\"\", filename=\"profile-" + job + "-%s-%d.dat\" % (os.uname()[1], os.getpid()))"
496 
497  return ("python -c '" + (profilePre if args.batchProfile else "") + script +
498  (profilePost if args.batchProfile else "") + "' " + shCommandFromArgs(args.leftover) +
499  " --noExit")
500 
def shCommandFromArgs(args)
Definition: parallel.py:42

◆ batchWallTime()

def lsst.pipe.drivers.multiBandDriver.MultiBandDriverTask.batchWallTime (   cls,
  time,
  parsedCmd,
  numCpus 
)

Return walltime request for batch job.

    @param time: Requested time per iteration
    @param parsedCmd: Results of argument parsing
    @param numCores: Number of cores

Reimplemented from lsst.ctrl.pool.parallel.BatchCmdLineTask.

Definition at line 165 of file multiBandDriver.py.

165  def batchWallTime(cls, time, parsedCmd, numCpus):
166  """!Return walltime request for batch job
167 
168  @param time: Requested time per iteration
169  @param parsedCmd: Results of argument parsing
170  @param numCores: Number of cores
171  """
172  numTargets = 0
173  for refList in parsedCmd.id.refList:
174  numTargets += len(refList)
175  return time*numTargets/float(numCpus)
176 

◆ emptyMetadata()

def lsst.pipe.base.task.Task.emptyMetadata (   self)
inherited
Empty (clear) the metadata for this Task and all sub-Tasks.

Definition at line 166 of file task.py.

166  def emptyMetadata(self):
167  """Empty (clear) the metadata for this Task and all sub-Tasks.
168  """
169  for subtask in self._taskDict.values():
170  subtask.metadata = dafBase.PropertyList()
171 
Class for storing ordered metadata with comments.
Definition: PropertyList.h:68

◆ getAllSchemaCatalogs()

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.

204  def getAllSchemaCatalogs(self):
205  """Get schema catalogs for all tasks in the hierarchy, combining the
206  results into a single dict.
207 
208  Returns
209  -------
210  schemacatalogs : `dict`
211  Keys are butler dataset type, values are a empty catalog (an
212  instance of the appropriate `lsst.afw.table` Catalog type) for all
213  tasks in the hierarchy, from the top-level task down
214  through all subtasks.
215 
216  Notes
217  -----
218  This method may be called on any task in the hierarchy; it will return
219  the same answer, regardless.
220 
221  The default implementation should always suffice. If your subtask uses
222  schemas the override `Task.getSchemaCatalogs`, not this method.
223  """
224  schemaDict = self.getSchemaCatalogs()
225  for subtask in self._taskDict.values():
226  schemaDict.update(subtask.getSchemaCatalogs())
227  return schemaDict
228 

◆ getFullMetadata()

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.

229  def getFullMetadata(self):
230  """Get metadata for all tasks.
231 
232  Returns
233  -------
234  metadata : `lsst.daf.base.PropertySet`
235  The `~lsst.daf.base.PropertySet` keys are the full task name.
236  Values are metadata for the top-level task and all subtasks,
237  sub-subtasks, etc.
238 
239  Notes
240  -----
241  The returned metadata includes timing information (if
242  ``@timer.timeMethod`` is used) and any metadata set by the task. The
243  name of each item consists of the full task name with ``.`` replaced
244  by ``:``, followed by ``.`` and the name of the item, e.g.::
245 
246  topLevelTaskName:subtaskName:subsubtaskName.itemName
247 
248  using ``:`` in the full task name disambiguates the rare situation
249  that a task has a subtask and a metadata item with the same name.
250  """
251  fullMetadata = dafBase.PropertySet()
252  for fullName, task in self.getTaskDict().items():
253  fullMetadata.set(fullName.replace(".", ":"), task.metadata)
254  return fullMetadata
255 
std::vector< SchemaItem< Flag > > * items
Class for storing generic metadata.
Definition: PropertySet.h:67

◆ getFullName()

def lsst.pipe.base.task.Task.getFullName (   self)
inherited
Get the task name as a hierarchical name including parent task
names.

Returns
-------
fullName : `str`
    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 256 of file task.py.

256  def getFullName(self):
257  """Get the task name as a hierarchical name including parent task
258  names.
259 
260  Returns
261  -------
262  fullName : `str`
263  The full name consists of the name of the parent task and each
264  subtask separated by periods. For example:
265 
266  - The full name of top-level task "top" is simply "top".
267  - The full name of subtask "sub" of top-level task "top" is
268  "top.sub".
269  - The full name of subtask "sub2" of subtask "sub" of top-level
270  task "top" is "top.sub.sub2".
271  """
272  return self._fullName
273 

◆ getName()

def lsst.pipe.base.task.Task.getName (   self)
inherited
Get the name of the task.

Returns
-------
taskName : `str`
    Name of the task.

See also
--------
getFullName

Definition at line 274 of file task.py.

274  def getName(self):
275  """Get the name of the task.
276 
277  Returns
278  -------
279  taskName : `str`
280  Name of the task.
281 
282  See also
283  --------
284  getFullName
285  """
286  return self._name
287 
std::string const & getName() const noexcept
Return a filter's name.
Definition: Filter.h:78

◆ getSchemaCatalogs()

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.

172  def getSchemaCatalogs(self):
173  """Get the schemas generated by this task.
174 
175  Returns
176  -------
177  schemaCatalogs : `dict`
178  Keys are butler dataset type, values are an empty catalog (an
179  instance of the appropriate `lsst.afw.table` Catalog type) for
180  this task.
181 
182  Notes
183  -----
184 
185  .. warning::
186 
187  Subclasses that use schemas must override this method. The default
188  implementation returns an empty dict.
189 
190  This method may be called at any time after the Task is constructed,
191  which means that all task schemas should be computed at construction
192  time, *not* when data is actually processed. This reflects the
193  philosophy that the schema should not depend on the data.
194 
195  Returning catalogs rather than just schemas allows us to save e.g.
196  slots for SourceCatalog as well.
197 
198  See also
199  --------
200  Task.getAllSchemaCatalogs
201  """
202  return {}
203 

◆ getTaskDict()

def lsst.pipe.base.task.Task.getTaskDict (   self)
inherited
Get a dictionary of all tasks as a shallow copy.

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

Definition at line 288 of file task.py.

288  def getTaskDict(self):
289  """Get a dictionary of all tasks as a shallow copy.
290 
291  Returns
292  -------
293  taskDict : `dict`
294  Dictionary containing full task name: task object for the top-level
295  task and all subtasks, sub-subtasks, etc.
296  """
297  return self._taskDict.copy()
298 
def getTaskDict(config, taskDict=None, baseName="")

◆ logOperation()

def lsst.ctrl.pool.parallel.BatchCmdLineTask.logOperation (   self,
  operation,
  catch = False,
  trace = True 
)
inherited

Provide a context manager for logging an operation.

    @param operation: description of operation (string)
    @param catch: Catch all exceptions?
    @param trace: Log a traceback of caught exception?

    Note that if 'catch' is True, all exceptions are swallowed, but there may
    be other side-effects such as undefined variables.

Definition at line 502 of file parallel.py.

502  def logOperation(self, operation, catch=False, trace=True):
503  """!Provide a context manager for logging an operation
504 
505  @param operation: description of operation (string)
506  @param catch: Catch all exceptions?
507  @param trace: Log a traceback of caught exception?
508 
509  Note that if 'catch' is True, all exceptions are swallowed, but there may
510  be other side-effects such as undefined variables.
511  """
512  self.log.info("%s: Start %s" % (NODE, operation))
513  try:
514  yield
515  except Exception:
516  if catch:
517  cls, e, _ = sys.exc_info()
518  self.log.warn("%s: Caught %s while %s: %s" % (NODE, cls.__name__, operation, e))
519  if trace:
520  self.log.info("%s: Traceback:\n%s" % (NODE, traceback.format_exc()))
521  return
522  raise
523  finally:
524  self.log.info("%s: Finished %s" % (NODE, operation))
525 
526 

◆ makeField()

def lsst.pipe.base.task.Task.makeField (   cls,
  doc 
)
inherited
Make a `lsst.pex.config.ConfigurableField` for this task.

Parameters
----------
doc : `str`
    Help text for the field.

Returns
-------
configurableField : `lsst.pex.config.ConfigurableField`
    A `~ConfigurableField` for this task.

Examples
--------
Provides a convenient way to specify this task is a subtask of another
task.

Here is an example of use:

.. code-block:: python

    class OtherTaskConfig(lsst.pex.config.Config):
        aSubtask = ATaskClass.makeField("brief description of task")

Definition at line 359 of file task.py.

359  def makeField(cls, doc):
360  """Make a `lsst.pex.config.ConfigurableField` for this task.
361 
362  Parameters
363  ----------
364  doc : `str`
365  Help text for the field.
366 
367  Returns
368  -------
369  configurableField : `lsst.pex.config.ConfigurableField`
370  A `~ConfigurableField` for this task.
371 
372  Examples
373  --------
374  Provides a convenient way to specify this task is a subtask of another
375  task.
376 
377  Here is an example of use:
378 
379  .. code-block:: python
380 
381  class OtherTaskConfig(lsst.pex.config.Config):
382  aSubtask = ATaskClass.makeField("brief description of task")
383  """
384  return ConfigurableField(doc=doc, target=cls)
385 

◆ makeSubtask()

def lsst.pipe.base.task.Task.makeSubtask (   self,
  name,
**  keyArgs 
)
inherited
Create a subtask as a new instance as the ``name`` attribute of this
task.

Parameters
----------
name : `str`
    Brief name of the subtask.
keyArgs
    Extra keyword arguments used to construct the task. The following
    arguments are automatically provided and cannot be overridden:

    - "config".
    - "parentTask".

Notes
-----
The subtask must be defined by ``Task.config.name``, an instance of
`~lsst.pex.config.ConfigurableField` or
`~lsst.pex.config.RegistryField`.

Definition at line 299 of file task.py.

299  def makeSubtask(self, name, **keyArgs):
300  """Create a subtask as a new instance as the ``name`` attribute of this
301  task.
302 
303  Parameters
304  ----------
305  name : `str`
306  Brief name of the subtask.
307  keyArgs
308  Extra keyword arguments used to construct the task. The following
309  arguments are automatically provided and cannot be overridden:
310 
311  - "config".
312  - "parentTask".
313 
314  Notes
315  -----
316  The subtask must be defined by ``Task.config.name``, an instance of
317  `~lsst.pex.config.ConfigurableField` or
318  `~lsst.pex.config.RegistryField`.
319  """
320  taskField = getattr(self.config, name, None)
321  if taskField is None:
322  raise KeyError(f"{self.getFullName()}'s config does not have field {name!r}")
323  subtask = taskField.apply(name=name, parentTask=self, **keyArgs)
324  setattr(self, name, subtask)
325 

◆ parseAndRun() [1/2]

def lsst.ctrl.pool.parallel.BatchPoolTask.parseAndRun (   cls,
args,
**  kwargs 
)
inherited
Run with a MPI process pool

Definition at line 534 of file parallel.py.

534  def parseAndRun(cls, *args, **kwargs):
535  """Run with a MPI process pool"""
536  pool = startPool()
537  super(BatchPoolTask, cls).parseAndRun(*args, **kwargs)
538  pool.exit()
539 
540 
def startPool(comm=None, root=0, killSlaves=True)
Start a process pool.
Definition: pool.py:1216

◆ parseAndRun() [2/2]

def lsst.pipe.base.cmdLineTask.CmdLineTask.parseAndRun (   cls,
  args = None,
  config = None,
  log = None,
  doReturnResults = False 
)
inherited
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.

612  def parseAndRun(cls, args=None, config=None, log=None, doReturnResults=False):
613  """Parse an argument list and run the command.
614 
615  Parameters
616  ----------
617  args : `list`, optional
618  List of command-line arguments; if `None` use `sys.argv`.
619  config : `lsst.pex.config.Config`-type, optional
620  Config for task. If `None` use `Task.ConfigClass`.
621  log : `lsst.log.Log`-type, optional
622  Log. If `None` use the default log.
623  doReturnResults : `bool`, optional
624  If `True`, return the results of this task. Default is `False`.
625  This is only intended for unit tests and similar use. It can
626  easily exhaust memory (if the task returns enough data and you
627  call it enough times) and it will fail when using multiprocessing
628  if the returned data cannot be pickled.
629 
630  Returns
631  -------
632  struct : `lsst.pipe.base.Struct`
633  Fields are:
634 
635  ``argumentParser``
636  the argument parser (`lsst.pipe.base.ArgumentParser`).
637  ``parsedCmd``
638  the parsed command returned by the argument parser's
639  `~lsst.pipe.base.ArgumentParser.parse_args` method
640  (`argparse.Namespace`).
641  ``taskRunner``
642  the task runner used to run the task (an instance of
643  `Task.RunnerClass`).
644  ``resultList``
645  results returned by the task runner's ``run`` method, one entry
646  per invocation (`list`). This will typically be a list of
647  `Struct`, each containing at least an ``exitStatus`` integer
648  (0 or 1); see `Task.RunnerClass` (`TaskRunner` by default) for
649  more details.
650 
651  Notes
652  -----
653  Calling this method with no arguments specified is the standard way to
654  run a command-line task from the command-line. For an example see
655  ``pipe_tasks`` ``bin/makeSkyMap.py`` or almost any other file in that
656  directory.
657 
658  If one or more of the dataIds fails then this routine will exit (with
659  a status giving the number of failed dataIds) rather than returning
660  this struct; this behaviour can be overridden by specifying the
661  ``--noExit`` command-line option.
662  """
663  if args is None:
664  commandAsStr = " ".join(sys.argv)
665  args = sys.argv[1:]
666  else:
667  commandAsStr = "{}{}".format(lsst.utils.get_caller_name(skip=1), tuple(args))
668 
669  argumentParser = cls._makeArgumentParser()
670  if config is None:
671  config = cls.ConfigClass()
672  parsedCmd = argumentParser.parse_args(config=config, args=args, log=log, override=cls.applyOverrides)
673  # print this message after parsing the command so the log is fully
674  # configured
675  parsedCmd.log.info("Running: %s", commandAsStr)
676 
677  taskRunner = cls.RunnerClass(TaskClass=cls, parsedCmd=parsedCmd, doReturnResults=doReturnResults)
678  resultList = taskRunner.run(parsedCmd)
679 
680  try:
681  nFailed = sum(((res.exitStatus != 0) for res in resultList))
682  except (TypeError, AttributeError) as e:
683  # NOTE: TypeError if resultList is None, AttributeError if it
684  # doesn't have exitStatus.
685  parsedCmd.log.warn("Unable to retrieve exit status (%s); assuming success", e)
686  nFailed = 0
687 
688  if nFailed > 0:
689  if parsedCmd.noExit:
690  parsedCmd.log.error("%d dataRefs failed; not exiting as --noExit was set", nFailed)
691  else:
692  sys.exit(nFailed)
693 
694  return Struct(
695  argumentParser=argumentParser,
696  parsedCmd=parsedCmd,
697  taskRunner=taskRunner,
698  resultList=resultList,
699  )
700 
def format(config, name=None, writeSourceLine=True, prefix="", verbose=False)
Definition: history.py:174

◆ parseAndSubmit()

def lsst.ctrl.pool.parallel.BatchCmdLineTask.parseAndSubmit (   cls,
  args = None,
**  kwargs 
)
inherited

Definition at line 435 of file parallel.py.

435  def parseAndSubmit(cls, args=None, **kwargs):
436  taskParser = cls._makeArgumentParser(doBatch=True, add_help=False)
437  batchParser = BatchArgumentParser(parent=taskParser)
438  batchArgs = batchParser.parse_args(config=cls.ConfigClass(), args=args, override=cls.applyOverrides,
439  **kwargs)
440 
441  if not cls.RunnerClass(cls, batchArgs.parent).precall(batchArgs.parent): # Write config, schema
442  taskParser.error("Error in task preparation")
443 
444  setBatchType(batchArgs.batch)
445 
446  if batchArgs.batch is None: # don't use a batch system
447  sys.argv = [sys.argv[0]] + batchArgs.leftover # Remove all batch arguments
448 
449  return cls.parseAndRun()
450  else:
451  if batchArgs.walltime > 0:
452  walltime = batchArgs.walltime
453  else:
454  numCores = batchArgs.cores if batchArgs.cores > 0 else batchArgs.nodes*batchArgs.procs
455  walltime = cls.batchWallTime(batchArgs.time, batchArgs.parent, numCores)
456 
457  command = cls.batchCommand(batchArgs)
458  batchArgs.batch.run(command, walltime=walltime)
459 
def setBatchType(batchType)
Definition: pool.py:101

◆ runDataRef()

def lsst.pipe.drivers.multiBandDriver.MultiBandDriverTask.runDataRef (   self,
  patchRefList 
)

Run multiband processing on coadds.

    Only the master node runs this method.

    No real MPI communication (scatter/gather) takes place: all I/O goes
    through the disk. We want the intermediate stages on disk, and the
    component Tasks are implemented around this, so we just follow suit.

    @param patchRefList:  Data references to run measurement

Definition at line 178 of file multiBandDriver.py.

178  def runDataRef(self, patchRefList):
179  """!Run multiband processing on coadds
180 
181  Only the master node runs this method.
182 
183  No real MPI communication (scatter/gather) takes place: all I/O goes
184  through the disk. We want the intermediate stages on disk, and the
185  component Tasks are implemented around this, so we just follow suit.
186 
187  @param patchRefList: Data references to run measurement
188  """
189  for patchRef in patchRefList:
190  if patchRef:
191  butler = patchRef.getButler()
192  break
193  else:
194  raise RuntimeError("No valid patches")
195  pool = Pool("all")
196  pool.cacheClear()
197  pool.storeSet(butler=butler)
198  # MultiBand measurements require that the detection stage be completed
199  # before measurements can be made.
200  #
201  # The configuration for coaddDriver.py allows detection to be turned
202  # of in the event that fake objects are to be added during the
203  # detection process. This allows the long co-addition process to be
204  # run once, and multiple different MultiBand reruns (with different
205  # fake objects) to exist from the same base co-addition.
206  #
207  # However, we only re-run detection if doDetection is explicitly True
208  # here (this should always be the opposite of coaddDriver.doDetection);
209  # otherwise we have no way to tell reliably whether any detections
210  # present in an input repo are safe to use.
211  if self.config.doDetection:
212  detectionList = []
213  for patchRef in patchRefList:
214  if ("detectCoaddSources" in self.reuse and
215  patchRef.datasetExists(self.coaddType + "Coadd_calexp", write=True)):
216  self.log.info("Skipping detectCoaddSources for %s; output already exists." %
217  patchRef.dataId)
218  continue
219  if not patchRef.datasetExists(self.coaddType + "Coadd"):
220  self.log.debug("Not processing %s; required input %sCoadd missing." %
221  (patchRef.dataId, self.config.coaddName))
222  continue
223  detectionList.append(patchRef)
224 
225  pool.map(self.runDetection, detectionList)
226 
227  patchRefList = [patchRef for patchRef in patchRefList if
228  patchRef.datasetExists(self.coaddType + "Coadd_calexp") and
229  patchRef.datasetExists(self.config.coaddName + "Coadd_det",
230  write=self.config.doDetection)]
231  dataIdList = [patchRef.dataId for patchRef in patchRefList]
232 
233  # Group by patch
234  patches = {}
235  tract = None
236  for patchRef in patchRefList:
237  dataId = patchRef.dataId
238  if tract is None:
239  tract = dataId["tract"]
240  else:
241  assert tract == dataId["tract"]
242 
243  patch = dataId["patch"]
244  if patch not in patches:
245  patches[patch] = []
246  patches[patch].append(dataId)
247 
248  pool.map(self.runMergeDetections, patches.values())
249 
250  # Deblend merged detections, and test for reprocessing
251  #
252  # The reprocessing allows us to have multiple attempts at deblending large footprints. Large
253  # footprints can suck up a lot of memory in the deblender, which means that when we process on a
254  # cluster, we want to refuse to deblend them (they're flagged "deblend.parent-too-big"). But since
255  # they may have astronomically interesting data, we want the ability to go back and reprocess them
256  # with a more permissive configuration when we have more memory or processing time.
257  #
258  # self.runDeblendMerged will return whether there are any footprints in that image that required
259  # reprocessing. We need to convert that list of booleans into a dict mapping the patchId (x,y) to
260  # a boolean. That tells us whether the merge measurement and forced photometry need to be re-run on
261  # a particular patch.
262  #
263  # This determination of which patches need to be reprocessed exists only in memory (the measurements
264  # have been written, clobbering the old ones), so if there was an exception we would lose this
265  # information, leaving things in an inconsistent state (measurements, merged measurements and
266  # forced photometry old). To attempt to preserve this status, we touch a file (dataset named
267  # "deepCoadd_multibandReprocessing") --- if this file exists, we need to re-run the measurements,
268  # merge and forced photometry.
269  #
270  # This is, hopefully, a temporary workaround until we can improve the
271  # deblender.
272  try:
273  reprocessed = pool.map(self.runDeblendMerged, patches.values())
274  finally:
275  if self.config.reprocessing:
276  patchReprocessing = {}
277  for dataId, reprocess in zip(dataIdList, reprocessed):
278  patchId = dataId["patch"]
279  patchReprocessing[patchId] = patchReprocessing.get(
280  patchId, False) or reprocess
281  # Persist the determination, to make error recover easier
282  reprocessDataset = self.config.coaddName + "Coadd_multibandReprocessing"
283  for patchId in patchReprocessing:
284  if not patchReprocessing[patchId]:
285  continue
286  dataId = dict(tract=tract, patch=patchId)
287  if patchReprocessing[patchId]:
288  filename = butler.get(
289  reprocessDataset + "_filename", dataId)[0]
290  open(filename, 'a').close() # Touch file
291  elif butler.datasetExists(reprocessDataset, dataId):
292  # We must have failed at some point while reprocessing
293  # and we're starting over
294  patchReprocessing[patchId] = True
295 
296  # Only process patches that have been identifiedz as needing it
297  pool.map(self.runMeasurements, [dataId1 for dataId1 in dataIdList if not self.config.reprocessing or
298  patchReprocessing[dataId1["patch"]]])
299  pool.map(self.runMergeMeasurements, [idList for patchId, idList in patches.items() if
300  not self.config.reprocessing or patchReprocessing[patchId]])
301  pool.map(self.runForcedPhot, [dataId1 for dataId1 in dataIdList if not self.config.reprocessing or
302  patchReprocessing[dataId1["patch"]]])
303 
304  # Remove persisted reprocessing determination
305  if self.config.reprocessing:
306  for patchId in patchReprocessing:
307  if not patchReprocessing[patchId]:
308  continue
309  dataId = dict(tract=tract, patch=patchId)
310  filename = butler.get(
311  reprocessDataset + "_filename", dataId)[0]
312  os.unlink(filename)
313 

◆ runDeblendMerged()

def lsst.pipe.drivers.multiBandDriver.MultiBandDriverTask.runDeblendMerged (   self,
  cache,
  dataIdList 
)
Run the deblender on a list of dataId's

Only slave nodes execute this method.

Parameters
----------
cache: Pool cache
    Pool cache with butler.
dataIdList: list
    Data identifier for patch in each band.

Returns
-------
result: bool
    whether the patch requires reprocessing.

Definition at line 349 of file multiBandDriver.py.

349  def runDeblendMerged(self, cache, dataIdList):
350  """Run the deblender on a list of dataId's
351 
352  Only slave nodes execute this method.
353 
354  Parameters
355  ----------
356  cache: Pool cache
357  Pool cache with butler.
358  dataIdList: list
359  Data identifier for patch in each band.
360 
361  Returns
362  -------
363  result: bool
364  whether the patch requires reprocessing.
365  """
366  with self.logOperation("deblending %s" % (dataIdList,)):
367  dataRefList = [getDataRef(cache.butler, dataId, self.coaddType + "Coadd_calexp") for
368  dataId in dataIdList]
369  reprocessing = False # Does this patch require reprocessing?
370  if ("deblendCoaddSources" in self.reuse and
371  all([dataRef.datasetExists(self.config.coaddName + "Coadd_" + self.measurementInput,
372  write=True) for dataRef in dataRefList])):
373  if not self.config.reprocessing:
374  self.log.info("Skipping deblendCoaddSources for %s; output already exists" % dataIdList)
375  return False
376 
377  # Footprints are the same every band, therefore we can check just one
378  catalog = dataRefList[0].get(self.config.coaddName + "Coadd_" + self.measurementInput)
379  bigFlag = catalog["deblend_parentTooBig"]
380  # Footprints marked too large by the previous deblender run
381  numOldBig = bigFlag.sum()
382  if numOldBig == 0:
383  self.log.info("No large footprints in %s" % (dataRefList[0].dataId))
384  return False
385 
386  # This if-statement can be removed after DM-15662
387  if self.config.deblendCoaddSources.simultaneous:
388  deblender = self.deblendCoaddSources.multiBandDeblend
389  else:
390  deblender = self.deblendCoaddSources.singleBandDeblend
391 
392  # isLargeFootprint() can potentially return False for a source that is marked
393  # too big in the catalog, because of "new"/different deblender configs.
394  # numNewBig is the number of footprints that *will* be too big if reprocessed
395  numNewBig = sum((deblender.isLargeFootprint(src.getFootprint()) for
396  src in catalog[bigFlag]))
397  if numNewBig == numOldBig:
398  self.log.info("All %d formerly large footprints continue to be large in %s" %
399  (numOldBig, dataRefList[0].dataId,))
400  return False
401  self.log.info("Found %d large footprints to be reprocessed in %s" %
402  (numOldBig - numNewBig, [dataRef.dataId for dataRef in dataRefList]))
403  reprocessing = True
404 
405  self.deblendCoaddSources.runDataRef(dataRefList)
406  return reprocessing
407 
bool all(CoordinateExpr< N > const &expr) noexcept
Return true if all elements are true.
def getDataRef(butler, dataId, datasetType="raw")
Definition: utils.py:16

◆ runDetection()

def lsst.pipe.drivers.multiBandDriver.MultiBandDriverTask.runDetection (   self,
  cache,
  patchRef 
)

Run detection on a patch.

   Only slave nodes execute this method.

   @param cache: Pool cache, containing butler
   @param patchRef: Patch on which to do detection

Definition at line 314 of file multiBandDriver.py.

314  def runDetection(self, cache, patchRef):
315  """! Run detection on a patch
316 
317  Only slave nodes execute this method.
318 
319  @param cache: Pool cache, containing butler
320  @param patchRef: Patch on which to do detection
321  """
322  with self.logOperation("do detections on {}".format(patchRef.dataId)):
323  idFactory = self.detectCoaddSources.makeIdFactory(patchRef)
324  coadd = patchRef.get(self.coaddType + "Coadd", immediate=True)
325  expId = int(patchRef.get(self.config.coaddName + "CoaddId"))
326  self.detectCoaddSources.emptyMetadata()
327  detResults = self.detectCoaddSources.run(coadd, idFactory, expId=expId)
328  self.detectCoaddSources.write(detResults, patchRef)
329  self.detectCoaddSources.writeMetadata(patchRef)
330 
void write(OutputArchiveHandle &handle) const override
def run(self, skyInfo, tempExpRefList, imageScalerList, weightList, altMaskList=None, mask=None, supplementaryData=None)
def writeMetadata(self, dataRefList)
No metadata to write, and not sure how to write it for a list of dataRefs.

◆ runForcedPhot()

def lsst.pipe.drivers.multiBandDriver.MultiBandDriverTask.runForcedPhot (   self,
  cache,
  dataId 
)

Run forced photometry on a patch for a single filter.

    Only slave nodes execute this method.

    @param cache: Pool cache, with butler
    @param dataId: Data identifier for patch

Definition at line 448 of file multiBandDriver.py.

448  def runForcedPhot(self, cache, dataId):
449  """!Run forced photometry on a patch for a single filter
450 
451  Only slave nodes execute this method.
452 
453  @param cache: Pool cache, with butler
454  @param dataId: Data identifier for patch
455  """
456  with self.logOperation("forced photometry on %s" % (dataId,)):
457  dataRef = getDataRef(cache.butler, dataId,
458  self.coaddType + "Coadd_calexp")
459  if ("forcedPhotCoadd" in self.reuse and
460  not self.config.reprocessing and
461  dataRef.datasetExists(self.config.coaddName + "Coadd_forced_src", write=True)):
462  self.log.info("Skipping forcedPhotCoadd for %s; output already exists" % dataId)
463  return
464  self.forcedPhotCoadd.runDataRef(dataRef)
465 

◆ runMeasurements()

def lsst.pipe.drivers.multiBandDriver.MultiBandDriverTask.runMeasurements (   self,
  cache,
  dataId 
)
Run measurement on a patch for a single filter

Only slave nodes execute this method.

Parameters
----------
cache: Pool cache
    Pool cache, with butler
dataId: dataRef
    Data identifier for patch

Definition at line 408 of file multiBandDriver.py.

408  def runMeasurements(self, cache, dataId):
409  """Run measurement on a patch for a single filter
410 
411  Only slave nodes execute this method.
412 
413  Parameters
414  ----------
415  cache: Pool cache
416  Pool cache, with butler
417  dataId: dataRef
418  Data identifier for patch
419  """
420  with self.logOperation("measurements on %s" % (dataId,)):
421  dataRef = getDataRef(cache.butler, dataId, self.coaddType + "Coadd_calexp")
422  if ("measureCoaddSources" in self.reuse and
423  not self.config.reprocessing and
424  dataRef.datasetExists(self.config.coaddName + "Coadd_meas", write=True)):
425  self.log.info("Skipping measuretCoaddSources for %s; output already exists" % dataId)
426  return
427  self.measureCoaddSources.runDataRef(dataRef)
428 

◆ runMergeDetections()

def lsst.pipe.drivers.multiBandDriver.MultiBandDriverTask.runMergeDetections (   self,
  cache,
  dataIdList 
)

Run detection merging on a patch.

    Only slave nodes execute this method.

    @param cache: Pool cache, containing butler
    @param dataIdList: List of data identifiers for the patch in different filters

Definition at line 331 of file multiBandDriver.py.

331  def runMergeDetections(self, cache, dataIdList):
332  """!Run detection merging on a patch
333 
334  Only slave nodes execute this method.
335 
336  @param cache: Pool cache, containing butler
337  @param dataIdList: List of data identifiers for the patch in different filters
338  """
339  with self.logOperation("merge detections from %s" % (dataIdList,)):
340  dataRefList = [getDataRef(cache.butler, dataId, self.coaddType + "Coadd_calexp") for
341  dataId in dataIdList]
342  if ("mergeCoaddDetections" in self.reuse and
343  dataRefList[0].datasetExists(self.config.coaddName + "Coadd_mergeDet", write=True)):
344  self.log.info("Skipping mergeCoaddDetections for %s; output already exists." %
345  dataRefList[0].dataId)
346  return
347  self.mergeCoaddDetections.runDataRef(dataRefList)
348 

◆ runMergeMeasurements()

def lsst.pipe.drivers.multiBandDriver.MultiBandDriverTask.runMergeMeasurements (   self,
  cache,
  dataIdList 
)

Run measurement merging on a patch.

    Only slave nodes execute this method.

    @param cache: Pool cache, containing butler
    @param dataIdList: List of data identifiers for the patch in different filters

Definition at line 429 of file multiBandDriver.py.

429  def runMergeMeasurements(self, cache, dataIdList):
430  """!Run measurement merging on a patch
431 
432  Only slave nodes execute this method.
433 
434  @param cache: Pool cache, containing butler
435  @param dataIdList: List of data identifiers for the patch in different filters
436  """
437  with self.logOperation("merge measurements from %s" % (dataIdList,)):
438  dataRefList = [getDataRef(cache.butler, dataId, self.coaddType + "Coadd_calexp") for
439  dataId in dataIdList]
440  if ("mergeCoaddMeasurements" in self.reuse and
441  not self.config.reprocessing and
442  dataRefList[0].datasetExists(self.config.coaddName + "Coadd_ref", write=True)):
443  self.log.info("Skipping mergeCoaddMeasurements for %s; output already exists" %
444  dataRefList[0].dataId)
445  return
446  self.mergeCoaddMeasurements.runDataRef(dataRefList)
447 

◆ timer()

def lsst.pipe.base.task.Task.timer (   self,
  name,
  logLevel = Log.DEBUG 
)
inherited
Context manager to log performance data for an arbitrary block of
code.

Parameters
----------
name : `str`
    Name of code being timed; data will be logged using item name:
    ``Start`` and ``End``.
logLevel
    A `lsst.log` level constant.

Examples
--------
Creating a timer context:

.. code-block:: python

    with self.timer("someCodeToTime"):
        pass  # code to time

See also
--------
timer.logInfo

Definition at line 327 of file task.py.

327  def timer(self, name, logLevel=Log.DEBUG):
328  """Context manager to log performance data for an arbitrary block of
329  code.
330 
331  Parameters
332  ----------
333  name : `str`
334  Name of code being timed; data will be logged using item name:
335  ``Start`` and ``End``.
336  logLevel
337  A `lsst.log` level constant.
338 
339  Examples
340  --------
341  Creating a timer context:
342 
343  .. code-block:: python
344 
345  with self.timer("someCodeToTime"):
346  pass # code to time
347 
348  See also
349  --------
350  timer.logInfo
351  """
352  logInfo(obj=self, prefix=name + "Start", logLevel=logLevel)
353  try:
354  yield
355  finally:
356  logInfo(obj=self, prefix=name + "End", logLevel=logLevel)
357 
def logInfo(obj, prefix, logLevel=Log.DEBUG)
Definition: timer.py:63

◆ writeConfig()

def lsst.pipe.base.cmdLineTask.CmdLineTask.writeConfig (   self,
  butler,
  clobber = False,
  doBackup = True 
)
inherited
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.

727  def writeConfig(self, butler, clobber=False, doBackup=True):
728  """Write the configuration used for processing the data, or check that
729  an existing one is equal to the new one if present.
730 
731  Parameters
732  ----------
733  butler : `lsst.daf.persistence.Butler`
734  Data butler used to write the config. The config is written to
735  dataset type `CmdLineTask._getConfigName`.
736  clobber : `bool`, optional
737  A boolean flag that controls what happens if a config already has
738  been saved:
739 
740  - `True`: overwrite or rename the existing config, depending on
741  ``doBackup``.
742  - `False`: raise `TaskError` if this config does not match the
743  existing config.
744  doBackup : `bool`, optional
745  Set to `True` to backup the config files if clobbering.
746  """
747  configName = self._getConfigName()
748  if configName is None:
749  return
750  if clobber:
751  butler.put(self.config, configName, doBackup=doBackup)
752  elif butler.datasetExists(configName, write=True):
753  # this may be subject to a race condition; see #2789
754  try:
755  oldConfig = butler.get(configName, immediate=True)
756  except Exception as exc:
757  raise type(exc)(f"Unable to read stored config file {configName} (exc); "
758  "consider using --clobber-config")
759 
760  def logConfigMismatch(msg):
761  self.log.fatal("Comparing configuration: %s", msg)
762 
763  if not self.config.compare(oldConfig, shortcut=False, output=logConfigMismatch):
764  raise TaskError(
765  f"Config does not match existing task config {configName!r} on disk; "
766  "tasks configurations must be consistent within the same output repo "
767  "(override with --clobber-config)")
768  else:
769  butler.put(self.config, configName)
770 
table::Key< int > type
Definition: Detector.cc:163

◆ writeMetadata()

def lsst.pipe.drivers.multiBandDriver.MultiBandDriverTask.writeMetadata (   self,
  dataRef 
)
We don't collect any metadata, so skip

Reimplemented from lsst.pipe.base.cmdLineTask.CmdLineTask.

Definition at line 466 of file multiBandDriver.py.

466  def writeMetadata(self, dataRef):
467  """We don't collect any metadata, so skip"""
468  pass

◆ writePackageVersions()

def lsst.pipe.base.cmdLineTask.CmdLineTask.writePackageVersions (   self,
  butler,
  clobber = False,
  doBackup = True,
  dataset = "packages" 
)
inherited
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 829 of file cmdLineTask.py.

829  def writePackageVersions(self, butler, clobber=False, doBackup=True, dataset="packages"):
830  """Compare and write package versions.
831 
832  Parameters
833  ----------
834  butler : `lsst.daf.persistence.Butler`
835  Data butler used to read/write the package versions.
836  clobber : `bool`, optional
837  A boolean flag that controls what happens if versions already have
838  been saved:
839 
840  - `True`: overwrite or rename the existing version info, depending
841  on ``doBackup``.
842  - `False`: raise `TaskError` if this version info does not match
843  the existing.
844  doBackup : `bool`, optional
845  If `True` and clobbering, old package version files are backed up.
846  dataset : `str`, optional
847  Name of dataset to read/write.
848 
849  Raises
850  ------
851  TaskError
852  Raised if there is a version mismatch with current and persisted
853  lists of package versions.
854 
855  Notes
856  -----
857  Note that this operation is subject to a race condition.
858  """
859  packages = Packages.fromSystem()
860 
861  if clobber:
862  return butler.put(packages, dataset, doBackup=doBackup)
863  if not butler.datasetExists(dataset, write=True):
864  return butler.put(packages, dataset)
865 
866  try:
867  old = butler.get(dataset, immediate=True)
868  except Exception as exc:
869  raise type(exc)(f"Unable to read stored version dataset {dataset} ({exc}); "
870  "consider using --clobber-versions or --no-versions")
871  # Note that because we can only detect python modules that have been
872  # imported, the stored list of products may be more or less complete
873  # than what we have now. What's important is that the products that
874  # are in common have the same version.
875  diff = packages.difference(old)
876  if diff:
877  versions_str = "; ".join(f"{pkg}: {diff[pkg][1]} vs {diff[pkg][0]}" for pkg in diff)
878  raise TaskError(
879  f"Version mismatch ({versions_str}); consider using --clobber-versions or --no-versions")
880  # Update the old set of packages in case we have more packages that
881  # haven't been persisted.
882  extra = packages.extra(old)
883  if extra:
884  old.update(packages)
885  butler.put(old, dataset, doBackup=doBackup)
886 

◆ writeSchemas()

def lsst.pipe.base.cmdLineTask.CmdLineTask.writeSchemas (   self,
  butler,
  clobber = False,
  doBackup = True 
)
inherited
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 771 of file cmdLineTask.py.

771  def writeSchemas(self, butler, clobber=False, doBackup=True):
772  """Write the schemas returned by
773  `lsst.pipe.base.Task.getAllSchemaCatalogs`.
774 
775  Parameters
776  ----------
777  butler : `lsst.daf.persistence.Butler`
778  Data butler used to write the schema. Each schema is written to the
779  dataset type specified as the key in the dict returned by
780  `~lsst.pipe.base.Task.getAllSchemaCatalogs`.
781  clobber : `bool`, optional
782  A boolean flag that controls what happens if a schema already has
783  been saved:
784 
785  - `True`: overwrite or rename the existing schema, depending on
786  ``doBackup``.
787  - `False`: raise `TaskError` if this schema does not match the
788  existing schema.
789  doBackup : `bool`, optional
790  Set to `True` to backup the schema files if clobbering.
791 
792  Notes
793  -----
794  If ``clobber`` is `False` and an existing schema does not match a
795  current schema, then some schemas may have been saved successfully
796  and others may not, and there is no easy way to tell which is which.
797  """
798  for dataset, catalog in self.getAllSchemaCatalogs().items():
799  schemaDataset = dataset + "_schema"
800  if clobber:
801  butler.put(catalog, schemaDataset, doBackup=doBackup)
802  elif butler.datasetExists(schemaDataset, write=True):
803  oldSchema = butler.get(schemaDataset, immediate=True).getSchema()
804  if not oldSchema.compare(catalog.getSchema(), afwTable.Schema.IDENTICAL):
805  raise TaskError(
806  f"New schema does not match schema {dataset!r} on disk; "
807  "schemas must be consistent within the same output repo "
808  "(override with --clobber-config)")
809  else:
810  butler.put(catalog, schemaDataset)
811 

Member Data Documentation

◆ butler

lsst.pipe.drivers.multiBandDriver.MultiBandDriverTask.butler

Definition at line 115 of file multiBandDriver.py.

◆ canMultiprocess

bool lsst.pipe.base.cmdLineTask.CmdLineTask.canMultiprocess = True
staticinherited

Definition at line 584 of file cmdLineTask.py.

◆ coaddType

lsst.pipe.drivers.multiBandDriver.MultiBandDriverTask.coaddType

Definition at line 144 of file multiBandDriver.py.

◆ config

lsst.pipe.base.task.Task.config
inherited

Definition at line 162 of file task.py.

◆ ConfigClass

lsst.pipe.drivers.multiBandDriver.MultiBandDriverTask.ConfigClass = MultiBandDriverConfig
static

Definition at line 97 of file multiBandDriver.py.

◆ deblenderOutput

lsst.pipe.drivers.multiBandDriver.MultiBandDriverTask.deblenderOutput

Definition at line 122 of file multiBandDriver.py.

◆ log

lsst.pipe.base.task.Task.log
inherited

Definition at line 161 of file task.py.

◆ measurementInput

lsst.pipe.drivers.multiBandDriver.MultiBandDriverTask.measurementInput

Definition at line 121 of file multiBandDriver.py.

◆ metadata

lsst.pipe.base.task.Task.metadata
inherited

Definition at line 134 of file task.py.

◆ reuse

lsst.pipe.drivers.multiBandDriver.MultiBandDriverTask.reuse

Definition at line 116 of file multiBandDriver.py.

◆ RunnerClass

lsst.pipe.drivers.multiBandDriver.MultiBandDriverTask.RunnerClass = MultiBandDriverTaskRunner
static

Definition at line 99 of file multiBandDriver.py.


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