Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DM-32226: Replace pipe.base.timeMethod with utils.timer #588

Merged
merged 1 commit into from
Oct 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion bin.src/dumpTaskMetadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import lsst.daf.base as dafBase
import lsst.pex.config as pexConfig
import lsst.pipe.base as pipeBase
from lsst.utils.timer import timeMethod

__all__ = ["DumpTaskMetadataTask", ]

Expand All @@ -42,7 +43,7 @@ class DumpTaskMetadataTask(pipeBase.CmdLineTask):
ConfigClass = DumpTaskMetadataConfig
_DefaultName = "DumpTaskMetadata"

@pipeBase.timeMethod
@timeMethod
def runDataRef(self, dataRef):
"""Report task metadata
"""
Expand Down
3 changes: 2 additions & 1 deletion bin.src/reportImagesInPatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import lsst.afw.geom as afwGeom
import lsst.pipe.base as pipeBase
from lsst.pipe.tasks.selectImages import WcsSelectImagesTask
from lsst.utils.timer import timeMethod

__all__ = ["ReportImagesInPatchTask", ]

Expand Down Expand Up @@ -56,7 +57,7 @@ def __init__(self, *args, **kwargs):
pipeBase.CmdLineTask.__init__(self, *args, **kwargs)
self.makeSubtask("select")

@pipeBase.timeMethod
@timeMethod
def runDataRef(self, patchRef):
"""Select images for a region and report how many are in each tract and patch

Expand Down
3 changes: 2 additions & 1 deletion bin.src/reportImagesToCoadd.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import lsst.afw.geom as afwGeom
import lsst.pipe.base as pipeBase
from lsst.pipe.tasks.selectImages import WcsSelectImagesTask
from lsst.utils.timer import timeMethod

__all__ = ["ReportImagesToCoaddTask", ]

Expand Down Expand Up @@ -67,7 +68,7 @@ def __init__(self, *args, **kwargs):
pipeBase.CmdLineTask.__init__(self, *args, **kwargs)
self.makeSubtask("select")

@pipeBase.timeMethod
@timeMethod
def runDataRef(self, dataRef):
"""Select images across the sky and report how many are in each tract and patch

Expand Down
3 changes: 2 additions & 1 deletion bin.src/reportPatches.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import lsst.pex.config as pexConfig
import lsst.afw.geom as afwGeom
import lsst.pipe.base as pipeBase
from lsst.utils.timer import timeMethod

__all__ = ["ReportPatchesTask", ]

Expand Down Expand Up @@ -58,7 +59,7 @@ class ReportPatchesTask(pipeBase.CmdLineTask):
def __init__(self, *args, **kwargs):
pipeBase.CmdLineTask.__init__(self, *args, **kwargs)

@pipeBase.timeMethod
@timeMethod
def runDataRef(self, dataRef):
"""Report tracts and patches that are within a given region of a skymap

Expand Down
3 changes: 2 additions & 1 deletion bin.src/reportTaskTiming.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import lsst.pex.config as pexConfig
import lsst.pipe.base as pipeBase
from lsst.pipe.tasks.getRepositoryData import DataRefListRunner
from lsst.utils.timer import timeMethod


class ReportTaskTimingConfig(pexConfig.Config):
Expand Down Expand Up @@ -144,7 +145,7 @@ class ReportTaskTimingTask(pipeBase.CmdLineTask):
def __init__(self, *args, **kwargs):
pipeBase.CmdLineTask.__init__(self, *args, **kwargs)

@pipeBase.timeMethod
@timeMethod
def runDataRef(self, dataRefList):
"""Report timing statistics for a collection of task metadata

Expand Down
9 changes: 5 additions & 4 deletions python/lsst/pipe/tasks/assembleCoadd.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
from .healSparseMapping import HealSparseInputMapTask
from lsst.meas.algorithms import SourceDetectionTask, AccumulatorMeanStack
from lsst.daf.butler import DeferredDatasetHandle
from lsst.utils.timer import timeMethod

__all__ = ["AssembleCoaddTask", "AssembleCoaddConnections", "AssembleCoaddConfig",
"SafeClipAssembleCoaddTask", "SafeClipAssembleCoaddConfig",
Expand Down Expand Up @@ -488,7 +489,7 @@ def runQuantum(self, butlerQC, inputRefs, outputRefs):
butlerQC.put(retStruct, outputRefs)
return retStruct

@pipeBase.timeMethod
@timeMethod
def runDataRef(self, dataRef, selectDataList=None, warpRefList=None):
"""Assemble a coadd from a set of Warps.

Expand Down Expand Up @@ -759,7 +760,7 @@ def prepareStats(self, mask=None):
statsFlags = afwMath.stringToStatisticsProperty(self.config.statistic)
return pipeBase.Struct(ctrl=statsCtrl, flags=statsFlags)

@pipeBase.timeMethod
@timeMethod
def run(self, skyInfo, tempExpRefList, imageScalerList, weightList,
altMaskList=None, mask=None, supplementaryData=None):
"""Assemble a coadd from input warps
Expand Down Expand Up @@ -1586,7 +1587,7 @@ def __init__(self, *args, **kwargs):
self.makeSubtask("clipDetection", schema=schema)

@utils.inheritDoc(AssembleCoaddTask)
@pipeBase.timeMethod
@timeMethod
def run(self, skyInfo, tempExpRefList, imageScalerList, weightList, *args, **kwargs):
"""Assemble the coadd for a region.

Expand Down Expand Up @@ -2274,7 +2275,7 @@ def _noTemplateMessage(self, warpType):
return message

@utils.inheritDoc(AssembleCoaddTask)
@pipeBase.timeMethod
@timeMethod
def run(self, skyInfo, tempExpRefList, imageScalerList, weightList,
supplementaryData, *args, **kwargs):
"""Assemble the coadd.
Expand Down
5 changes: 3 additions & 2 deletions python/lsst/pipe/tasks/calibrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
ApplyApCorrTask,
CatalogCalculationTask)
from lsst.meas.deblender import SourceDeblendTask
from lsst.utils.timer import timeMethod
from lsst.pipe.tasks.setPrimaryFlags import SetPrimaryFlagsTask
from .fakes import BaseFakeSourcesTask
from .photoCal import PhotoCalTask
Expand Down Expand Up @@ -549,7 +550,7 @@ def __init__(self, butler=None, astromRefObjLoader=None,
sourceCatSchema.getTable().setMetadata(self.algMetadata)
self.outputSchema = sourceCatSchema

@pipeBase.timeMethod
@timeMethod
def runDataRef(self, dataRef, exposure=None, background=None, icSourceCat=None,
doUnpersist=True):
"""!Calibrate an exposure, optionally unpersisting inputs and
Expand Down Expand Up @@ -643,7 +644,7 @@ def runQuantum(self, butlerQC, inputRefs, outputRefs):
outputs.matches = normalizedMatches
butlerQC.put(outputs, outputRefs)

@pipeBase.timeMethod
@timeMethod
def run(self, exposure, exposureIdInfo=None, background=None,
icSourceCat=None):
"""!Calibrate an exposure (science image or coadd)
Expand Down
7 changes: 4 additions & 3 deletions python/lsst/pipe/tasks/characterizeImage.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
from .repair import RepairTask
from .computeExposureSummaryStats import ComputeExposureSummaryStatsTask
from lsst.pex.exceptions import LengthError
from lsst.utils.timer import timeMethod

__all__ = ["CharacterizeImageConfig", "CharacterizeImageTask"]

Expand Down Expand Up @@ -389,7 +390,7 @@ def getInitOutputDatasets(self):
outputCatSchema.getTable().setMetadata(self.algMetadata)
return {'outputSchema': outputCatSchema}

@pipeBase.timeMethod
@timeMethod
def runDataRef(self, dataRef, exposure=None, background=None, doUnpersist=True):
"""!Characterize a science image and, if wanted, persist the results

Expand Down Expand Up @@ -441,7 +442,7 @@ def runDataRef(self, dataRef, exposure=None, background=None, doUnpersist=True):

return charRes

@pipeBase.timeMethod
@timeMethod
def run(self, exposure, exposureIdInfo=None, background=None):
"""!Characterize a science image

Expand Down Expand Up @@ -526,7 +527,7 @@ def run(self, exposure, exposureIdInfo=None, background=None):
backgroundModel=dmeRes.background
)

@pipeBase.timeMethod
@timeMethod
def detectMeasureAndEstimatePsf(self, exposure, exposureIdInfo, background):
"""!Perform one iteration of detect, measure and estimate PSF

Expand Down
3 changes: 2 additions & 1 deletion python/lsst/pipe/tasks/computeExposureSummaryStats.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import lsst.afw.math as afwMath
import lsst.afw.image as afwImage
import lsst.geom
from lsst.utils.timer import timeMethod


__all__ = ("ComputeExposureSummaryStatsTask", "ComputeExposureSummaryStatsConfig")
Expand Down Expand Up @@ -79,7 +80,7 @@ class ComputeExposureSummaryStatsTask(pipeBase.Task):
ConfigClass = ComputeExposureSummaryStatsConfig
_DefaultName = "computeExposureSummaryStats"

@pipeBase.timeMethod
@timeMethod
def run(self, exposure, sources, background):
"""Measure exposure statistics from the exposure, sources, and background.

Expand Down
5 changes: 3 additions & 2 deletions python/lsst/pipe/tasks/dcrAssembleCoadd.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import lsst.pipe.base as pipeBase
import lsst.utils as utils
from lsst.skymap import BaseSkyMap
from lsst.utils.timer import timeMethod
from .assembleCoadd import (AssembleCoaddTask,
CompareWarpAssembleCoaddConfig,
CompareWarpAssembleCoaddTask)
Expand Down Expand Up @@ -381,7 +382,7 @@ def runQuantum(self, butlerQC, inputRefs, outputRefs):
butlerQC.put(retStruct, outputRefs)
return retStruct

@pipeBase.timeMethod
@timeMethod
def runDataRef(self, dataRef, selectDataList=None, warpRefList=None):
"""Assemble a coadd from a set of warps.

Expand Down Expand Up @@ -578,7 +579,7 @@ def prepareDcrInputs(self, templateCoadd, warpRefList, weightList):
psf=psf)
return dcrModels

@pipeBase.timeMethod
@timeMethod
def run(self, skyInfo, warpRefList, imageScalerList, weightList,
supplementaryData=None):
"""Assemble the coadd.
Expand Down
3 changes: 2 additions & 1 deletion python/lsst/pipe/tasks/exampleCmdLineTask.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import lsst.afw.display as afwDisplay
import lsst.pex.config as pexConfig
import lsst.pipe.base as pipeBase
from lsst.utils.timer import timeMethod
from .exampleStatsTasks import ExampleSigmaClippedStatsTask

__all__ = ["ExampleCmdLineConfig", "ExampleCmdLineTask"]
Expand Down Expand Up @@ -112,7 +113,7 @@ def __init__(self, *args, **kwargs):
pipeBase.CmdLineTask.__init__(self, *args, **kwargs)
self.makeSubtask("stats")

@pipeBase.timeMethod
@timeMethod
def runDataRef(self, dataRef):
"""!Compute a few statistics on the image plane of an exposure

Expand Down
7 changes: 4 additions & 3 deletions python/lsst/pipe/tasks/exampleStatsTasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import lsst.afw.math as afwMath
import lsst.pex.config as pexConfig
import lsst.pipe.base as pipeBase
from lsst.utils.timer import timeMethod

__all__ = ["ExampleSigmaClippedStatsConfig", "ExampleSigmaClippedStatsTask", "ExampleSimpleStatsTask"]

Expand Down Expand Up @@ -115,7 +116,7 @@ def __init__(self, *args, **kwargs):
self._statsControl.setNumIter(self.config.numIter)
self._statsControl.setAndMask(self._badPixelMask)

@pipeBase.timeMethod
@timeMethod
def run(self, maskedImage):
"""!Compute and return statistics for a masked image

Expand Down Expand Up @@ -184,11 +185,11 @@ class ExampleSimpleStatsTask(pipeBase.Task):
# be run by a parent task at the same time).
_DefaultName = "exampleSimpleStats"

# The `lsst.pipe.timeMethod` decorator measures how long a task method takes to run,
# The `lsst.utils.timer.timeMethod` decorator measures how long a task method takes to run,
# and the resources needed to run it. The information is recorded in the task's `metadata` field.
# Most command-line tasks (not including the example below) save metadata for the task
# and all of its subtasks whenver the task is run.
@pipeBase.timeMethod
@timeMethod
def run(self, maskedImage):
"""!Compute and return statistics for a masked image

Expand Down
3 changes: 2 additions & 1 deletion python/lsst/pipe/tasks/getRepositoryData.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"""
import lsst.pex.config as pexConfig
import lsst.pipe.base as pipeBase
from lsst.utils.timer import timeMethod

__all__ = ["DataRefListRunner", "GetRepositoryDataTask"]

Expand Down Expand Up @@ -74,7 +75,7 @@ class GetRepositoryDataTask(pipeBase.CmdLineTask):
def __init__(self, *args, **kwargs):
pipeBase.CmdLineTask.__init__(self, *args, **kwargs)

@pipeBase.timeMethod
@timeMethod
def runDataRef(self, dataRefList):
"""Get data from a repository for a collection of data references

Expand Down
5 changes: 3 additions & 2 deletions python/lsst/pipe/tasks/healSparseMapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import lsst.afw.geom as afwGeom
from lsst.daf.butler import Formatter
from lsst.skymap import BaseSkyMap
from lsst.utils.timer import timeMethod
from .healSparseMappingProperties import (BasePropertyMap, BasePropertyMapConfig,
PropertyMapMap, compute_approx_psf_size_and_shape)

Expand Down Expand Up @@ -456,7 +457,7 @@ def __init__(self, **kwargs):
for name, config, PropertyMapClass in self.config.property_maps.apply():
self.property_maps[name] = PropertyMapClass(config, name)

@pipeBase.timeMethod
@timeMethod
def runQuantum(self, butlerQC, inputRefs, outputRefs):
inputs = butlerQC.get(inputRefs)

Expand Down Expand Up @@ -868,7 +869,7 @@ def __init__(self, **kwargs):
for name, config, PropertyMapClass in self.config.property_maps.apply():
self.property_maps[name] = PropertyMapClass(config, name)

@pipeBase.timeMethod
@timeMethod
def runQuantum(self, butlerQC, inputRefs, outputRefs):
inputs = butlerQC.get(inputRefs)

Expand Down
5 changes: 3 additions & 2 deletions python/lsst/pipe/tasks/imageDifference.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import lsst.afw.display as afwDisplay
from lsst.skymap import BaseSkyMap
from lsst.obs.base import ExposureIdInfo
from lsst.utils.timer import timeMethod

__all__ = ["ImageDifferenceConfig", "ImageDifferenceTask"]
FwhmPerSigma = 2*math.sqrt(2*math.log(2))
Expand Down Expand Up @@ -555,7 +556,7 @@ def runQuantum(self, butlerQC: pipeBase.ButlerQuantumContext,
del outputs.diaSources
butlerQC.put(outputs, outputRefs)

@pipeBase.timeMethod
@timeMethod
def runDataRef(self, sensorRef, templateIdList=None):
"""Subtract an image from a template coadd and measure the result.

Expand Down Expand Up @@ -636,7 +637,7 @@ def runDataRef(self, sensorRef, templateIdList=None):
sensorRef.put(results.scoreExposure, self.config.coaddName + "Diff_scoreExp")
return results

@pipeBase.timeMethod
@timeMethod
def run(self, exposure=None, selectSources=None, templateExposure=None, templateSources=None,
idFactory=None, calexpBackgroundExposure=None, subtractedExposure=None):
"""PSF matches, subtract two images and perform detection on the difference image.
Expand Down
3 changes: 2 additions & 1 deletion python/lsst/pipe/tasks/interpImage.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import lsst.ip.isr as ipIsr
import lsst.meas.algorithms as measAlg
import lsst.pipe.base as pipeBase
from lsst.utils.timer import timeMethod

__all__ = ["InterpImageConfig", "InterpImageTask"]

Expand Down Expand Up @@ -115,7 +116,7 @@ def _setFallbackValue(self, mi=None):

return fallbackValue

@pipeBase.timeMethod
@timeMethod
def run(self, image, planeName=None, fwhmPixels=None, defects=None):
"""!Interpolate in place over pixels in a maskedImage marked as bad

Expand Down
5 changes: 3 additions & 2 deletions python/lsst/pipe/tasks/makeCoaddTempExp.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import lsst.geom
from lsst.meas.algorithms import CoaddPsf, CoaddPsfConfig
from lsst.skymap import BaseSkyMap
from lsst.utils.timer import timeMethod
from .coaddBase import CoaddBaseTask, makeSkyInfo, reorderAndPadList
from .warpAndPsfMatch import WarpAndPsfMatchTask
from .coaddHelpers import groupPatchExposures, getGroupDataRef
Expand Down Expand Up @@ -284,7 +285,7 @@ def __init__(self, reuse=False, **kwargs):
else:
self.calexpType = "calexp"

@pipeBase.timeMethod
@timeMethod
def runDataRef(self, patchRef, selectDataList=[]):
"""!Produce <coaddName>Coadd_<warpType>Warp images by warping and optionally PSF-matching.

Expand Down Expand Up @@ -384,7 +385,7 @@ def runDataRef(self, patchRef, selectDataList=[]):

return dataRefList

@pipeBase.timeMethod
@timeMethod
def run(self, calExpList, ccdIdList, skyInfo, visitId=0, dataIdList=None, **kwargs):
"""Create a Warp from inputs

Expand Down