Skip to content

Commit

Permalink
Replace pipe.base.timeMethod with utils.timer (DM-32226)
Browse files Browse the repository at this point in the history
  • Loading branch information
andy-slac committed Oct 20, 2021
1 parent bfd0ea7 commit 730b8a8
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 15 deletions.
9 changes: 5 additions & 4 deletions python/lsst/ap/association/association.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import lsst.geom as geom
import lsst.pex.config as pexConfig
import lsst.pipe.base as pipeBase
from lsst.utils.timer import timeMethod

# Enforce an error for unsafe column/array value setting in pandas.
pd.options.mode.chained_assignment = 'raise'
Expand Down Expand Up @@ -59,7 +60,7 @@ class AssociationTask(pipeBase.Task):
ConfigClass = AssociationConfig
_DefaultName = "association"

@pipeBase.timeMethod
@timeMethod
def run(self,
diaSources,
diaObjects):
Expand Down Expand Up @@ -137,7 +138,7 @@ def check_dia_source_radec(self, dia_sources):
dia_sources = dia_sources[~nan_mask]
return dia_sources

@pipeBase.timeMethod
@timeMethod
def associate_sources(self, dia_objects, dia_sources):
"""Associate the input DIASources with the catalog of DIAObjects.
Expand Down Expand Up @@ -170,7 +171,7 @@ def associate_sources(self, dia_objects, dia_sources):

return match_result

@pipeBase.timeMethod
@timeMethod
def score(self, dia_objects, dia_sources, max_dist):
"""Compute a quality score for each dia_source/dia_object pair
between this catalog of DIAObjects and the input DIASource catalog.
Expand Down Expand Up @@ -273,7 +274,7 @@ def _radec_to_xyz(self, catalog):

return vectors

@pipeBase.timeMethod
@timeMethod
def match(self, dia_objects, dia_sources, score_struct):
"""Match DIAsources to DiaObjects given a score.
Expand Down
3 changes: 2 additions & 1 deletion python/lsst/ap/association/diaForcedSource.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
from lsst.meas.base import ForcedMeasurementTask
import lsst.pex.config as pexConfig
import lsst.pipe.base as pipeBase
from lsst.utils.timer import timeMethod


class DiaForcedSourcedConfig(pexConfig.Config):
Expand Down Expand Up @@ -87,7 +88,7 @@ def __init__(self, **kwargs):
self.makeSubtask("forcedMeasurement",
refSchema=afwTable.SourceTable.makeMinimalSchema())

@pipeBase.timeMethod
@timeMethod
def run(self,
dia_objects,
updatedDiaObjectIds,
Expand Down
3 changes: 2 additions & 1 deletion python/lsst/ap/association/diaPipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import lsst.pex.config as pexConfig
import lsst.pipe.base as pipeBase
import lsst.pipe.base.connectionTypes as connTypes
from lsst.utils.timer import timeMethod

from lsst.ap.association import (
AssociationTask,
Expand Down Expand Up @@ -299,7 +300,7 @@ def runQuantum(self, butlerQC, inputRefs, outputRefs):

butlerQC.put(outputs, outputRefs)

@pipeBase.timeMethod
@timeMethod
def run(self,
diaSourceTable,
solarSystemObjectTable,
Expand Down
11 changes: 6 additions & 5 deletions python/lsst/ap/association/loadDiaCatalogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import lsst.pex.config as pexConfig
import lsst.pipe.base as pipeBase
import lsst.sphgeom as sphgeom
from lsst.utils.timer import timeMethod

__all__ = ("LoadDiaCatalogsTask", "LoadDiaCatalogsConfig")

Expand All @@ -54,7 +55,7 @@ class LoadDiaCatalogsTask(pipeBase.Task):
def __init__(self, **kwargs):
pipeBase.Task.__init__(self, **kwargs)

@pipeBase.timeMethod
@timeMethod
def run(self, exposure, apdb):
"""Preload all DiaObjects and DiaSources from the Apdb given the
current exposure.
Expand Down Expand Up @@ -108,7 +109,7 @@ def run(self, exposure, apdb):
diaSources=diaSources,
diaForcedSources=diaForcedSources)

@pipeBase.timeMethod
@timeMethod
def loadDiaObjects(self, region, apdb):
"""Load DiaObjects from the Apdb based on their HTM location.
Expand Down Expand Up @@ -142,7 +143,7 @@ def loadDiaObjects(self, region, apdb):

return diaObjects.replace(to_replace=[None], value=np.nan)

@pipeBase.timeMethod
@timeMethod
def loadDiaSources(self, diaObjects, region, dateTime, apdb):
"""Load DiaSources from the Apdb based on their diaObjectId or
location.
Expand Down Expand Up @@ -192,7 +193,7 @@ def loadDiaSources(self, diaObjects, region, dateTime, apdb):

return diaSources.replace(to_replace=[None], value=np.nan)

@pipeBase.timeMethod
@timeMethod
def loadDiaForcedSources(self, diaObjects, region, dateTime, apdb):
"""Load DiaObjects from the Apdb based on their HTM location.
Expand Down Expand Up @@ -241,7 +242,7 @@ def loadDiaForcedSources(self, diaObjects, region, dateTime, apdb):

return diaForcedSources.replace(to_replace=[None], value=np.nan)

@pipeBase.timeMethod
@timeMethod
def _getRegion(self, exposure):
"""Calculate an enveloping region for an exposure.
Expand Down
3 changes: 2 additions & 1 deletion python/lsst/ap/association/packageAlerts.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import lsst.pex.config as pexConfig
from lsst.pex.exceptions import InvalidParameterError
import lsst.pipe.base as pipeBase
from lsst.utils.timer import timeMethod


"""Methods for packaging Apdb and Pipelines data into Avro alerts.
Expand Down Expand Up @@ -76,7 +77,7 @@ def __init__(self, **kwargs):
self.alertSchema = alertPack.Schema.from_file(self.config.schemaFile)
os.makedirs(self.config.alertWriteLocation, exist_ok=True)

@pipeBase.timeMethod
@timeMethod
def run(self,
diaSourceCat,
diaObjectCat,
Expand Down
3 changes: 2 additions & 1 deletion python/lsst/ap/association/skyBotEphemerisQuery.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
from lsst.daf.base import DateTime
import lsst.pex.config as pexConfig
import lsst.pipe.base as pipeBase
from lsst.utils.timer import timeMethod

from lsst.pipe.base import PipelineTask, PipelineTaskConfig, PipelineTaskConnections
import lsst.pipe.base.connectionTypes as connTypes
Expand Down Expand Up @@ -99,7 +100,7 @@ def runQuantum(self, butlerQC, inputRefs, outputRefs):

butlerQC.put(outputs, outputRefs)

@pipeBase.timeMethod
@timeMethod
def run(self, visitInfos, visit):
"""Parse the information on the current visit and retrieve the
observable solar system objects from SkyBot.
Expand Down
3 changes: 2 additions & 1 deletion python/lsst/ap/association/ssoAssociation.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import lsst.geom as geom
import lsst.pex.config as pexConfig
import lsst.pipe.base as pipeBase
from lsst.utils.timer import timeMethod


class SolarSystemAssociationConfig(pexConfig.Config):
Expand Down Expand Up @@ -61,7 +62,7 @@ class SolarSystemAssociationTask(pipeBase.Task):
ConfigClass = SolarSystemAssociationConfig
_DefaultName = "ssoAssociation"

@pipeBase.timeMethod
@timeMethod
def run(self, diaSourceCatalog, solarSystemObjects, exposure):
"""Create a searchable tree of unassociated DiaSources and match
to the nearest ssoObject.
Expand Down
3 changes: 2 additions & 1 deletion python/lsst/ap/association/transformDiaSourceCatalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
from lsst.pipe.tasks.postprocess import TransformCatalogBaseTask, TransformCatalogBaseConfig
from lsst.pipe.tasks.parquetTable import ParquetTable
from lsst.pipe.tasks.functors import Column
from lsst.utils.timer import timeMethod


class TransformDiaSourceCatalogConnections(pipeBase.PipelineTaskConnections,
Expand Down Expand Up @@ -169,7 +170,7 @@ def runQuantum(self, butlerQC, inputRefs, outputRefs):

butlerQC.put(outputs, outputRefs)

@pipeBase.timeMethod
@timeMethod
def run(self,
diaSourceCat,
diffIm,
Expand Down

0 comments on commit 730b8a8

Please sign in to comment.