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 #91

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
8 changes: 4 additions & 4 deletions doc/lsst.verify/tasks/lsst.verify.tasks.MemoryMetricTask.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@
MemoryMetricTask
################

``MemoryMetricTask`` creates a resident set size `~lsst.verify.Measurement` based on data collected by @\ `~lsst.pipe.base.timeMethod`.
``MemoryMetricTask`` creates a resident set size `~lsst.verify.Measurement` based on data collected by @\ `~lsst.utils.timer.timeMethod`.
It reads the raw timing data from the top-level `~lsst.pipe.base.CmdLineTask`'s metadata, which is identified by the task configuration.

In general, it's only useful to measure this metric for the top-level task being run.
@\ `~lsst.pipe.base.timeMethod` measures the peak memory usage from process start, so the results for any subtask will be contaminated by previous subtasks run on the same data ID.
@\ `~lsst.utils.timer.timeMethod` measures the peak memory usage from process start, so the results for any subtask will be contaminated by previous subtasks run on the same data ID.

Because @\ `~lsst.pipe.base.timeMethod` gives platform-dependent results, this task may give incorrect results (e.g., units) when run in a distributed system with heterogeneous nodes.
Because @\ `~lsst.utils.timer.timeMethod` gives platform-dependent results, this task may give incorrect results (e.g., units) when run in a distributed system with heterogeneous nodes.

.. _lsst.verify.tasks.MemoryMetricTask-summary:

Processing summary
==================

``MemoryMetricTask`` searches the metadata for @\ `~lsst.pipe.base.timeMethod`-generated keys corresponding to the method of interest.
``MemoryMetricTask`` searches the metadata for @\ `~lsst.utils.timer.timeMethod`-generated keys corresponding to the method of interest.
If it finds matching keys, it stores the maximum memory usage as a `~lsst.verify.Measurement`.

.. _lsst.verify.tasks.MemoryMetricTask-api:
Expand Down
4 changes: 2 additions & 2 deletions doc/lsst.verify/tasks/lsst.verify.tasks.TimingMetricTask.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
TimingMetricTask
################

``TimingMetricTask`` creates a wall-clock timing `~lsst.verify.Measurement` based on data collected by @\ `~lsst.pipe.base.timeMethod`.
``TimingMetricTask`` creates a wall-clock timing `~lsst.verify.Measurement` based on data collected by @\ `~lsst.utils.timer.timeMethod`.
It reads the raw timing data from the top-level `~lsst.pipe.base.CmdLineTask`'s metadata, which is identified by the task configuration.

.. _lsst.verify.tasks.TimingMetricTask-summary:

Processing summary
==================

``TimingMetricTask`` searches the metadata for @\ `~lsst.pipe.base.timeMethod`-generated keys corresponding to the method of interest.
``TimingMetricTask`` searches the metadata for @\ `~lsst.utils.timer.timeMethod`-generated keys corresponding to the method of interest.
If it finds matching keys, it stores the elapsed time as a `~lsst.verify.Measurement`.

.. _lsst.verify.tasks.TimingMetricTask-api:
Expand Down
16 changes: 8 additions & 8 deletions python/lsst/verify/tasks/commonMetrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@


class TimeMethodMetricConfig(MetadataMetricConfig):
"""Common config fields for metrics based on `~lsst.pipe.base.timeMethod`.
"""Common config fields for metrics based on `~lsst.utils.timer.timeMethod`.

These fields let metrics distinguish between different methods that have
been decorated with `~lsst.pipe.base.timeMethod`.
been decorated with `~lsst.utils.timer.timeMethod`.
"""
target = pexConfig.Field(
dtype=str,
Expand Down Expand Up @@ -87,7 +87,7 @@ def validate(self):
@registerMultiple("timing")
class TimingMetricTask(MetadataMetricTask):
"""A Task that computes a wall-clock time using metadata produced by the
`lsst.pipe.base.timeMethod` decorator.
`lsst.utils.timer.timeMethod` decorator.

Parameters
----------
Expand Down Expand Up @@ -129,7 +129,7 @@ def getInputMetadataKeys(cls, config):

def makeMeasurement(self, timings):
"""Compute a wall-clock measurement from metadata provided by
`lsst.pipe.base.timeMethod`.
`lsst.utils.timer.timeMethod`.

Parameters
----------
Expand Down Expand Up @@ -163,7 +163,7 @@ def makeMeasurement(self, timings):
else:
meas = Measurement(self.config.metricName,
totalTime * u.second)
meas.notes["estimator"] = "pipe.base.timeMethod"
meas.notes["estimator"] = "utils.timer.timeMethod"
if timings["StartTimestamp"]:
meas.extras["start"] = Datum(timings["StartTimestamp"])
if timings["EndTimestamp"]:
Expand All @@ -182,7 +182,7 @@ def makeMeasurement(self, timings):
@registerMultiple("memory")
class MemoryMetricTask(MetadataMetricTask):
"""A Task that computes the maximum resident set size using metadata
produced by the `lsst.pipe.base.timeMethod` decorator.
produced by the `lsst.utils.timer.timeMethod` decorator.

Parameters
----------
Expand Down Expand Up @@ -218,7 +218,7 @@ def getInputMetadataKeys(cls, config):

def makeMeasurement(self, memory):
"""Compute a maximum resident set size measurement from metadata
provided by `lsst.pipe.base.timeMethod`.
provided by `lsst.utils.timer.timeMethod`.

Parameters
----------
Expand Down Expand Up @@ -247,7 +247,7 @@ def makeMeasurement(self, memory):
else:
meas = Measurement(self.config.metricName,
self._addUnits(maxMemory))
meas.notes['estimator'] = 'pipe.base.timeMethod'
meas.notes['estimator'] = 'utils.timer.timeMethod'
return meas
else:
self.log.info("Nothing to do: no memory information for %s found.",
Expand Down
3 changes: 2 additions & 1 deletion tests/test_commonMetrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@

import lsst.utils.tests
from lsst.pex.config import Config
from lsst.pipe.base import Task, timeMethod
from lsst.pipe.base import Task
from lsst.utils.timer import timeMethod

from lsst.verify import Measurement, Name
from lsst.verify.gen2tasks.testUtils import MetricTaskTestCase
Expand Down