From 89015ecc0d760f410b2fdedb69b13fdb9745749c Mon Sep 17 00:00:00 2001 From: Nate Lust Date: Fri, 30 Jun 2023 18:14:56 -0400 Subject: [PATCH] Address review comments and mypy fixes --- doc/changes/DM-39582.api.md | 1 - doc/changes/DM-39582.removal.md | 1 + python/lsst/pipe/base/graph/_loadHelpers.py | 3 +-- python/lsst/pipe/base/graph/quantumNode.py | 6 ++++-- python/lsst/pipe/base/pipeline.py | 8 ++++---- python/lsst/pipe/base/tests/simpleQGraph.py | 2 +- 6 files changed, 11 insertions(+), 10 deletions(-) delete mode 100644 doc/changes/DM-39582.api.md create mode 100644 doc/changes/DM-39582.removal.md diff --git a/doc/changes/DM-39582.api.md b/doc/changes/DM-39582.api.md deleted file mode 100644 index e871ba4e..00000000 --- a/doc/changes/DM-39582.api.md +++ /dev/null @@ -1 +0,0 @@ -Deprecated reconstituteDimensions argument from QuantumNode.from_simple diff --git a/doc/changes/DM-39582.removal.md b/doc/changes/DM-39582.removal.md new file mode 100644 index 00000000..b489f3bb --- /dev/null +++ b/doc/changes/DM-39582.removal.md @@ -0,0 +1 @@ +Deprecated reconstituteDimensions argument from `QuantumNode.from_simple` diff --git a/python/lsst/pipe/base/graph/_loadHelpers.py b/python/lsst/pipe/base/graph/_loadHelpers.py index 4f0d3e2c..0190842f 100644 --- a/python/lsst/pipe/base/graph/_loadHelpers.py +++ b/python/lsst/pipe/base/graph/_loadHelpers.py @@ -34,7 +34,6 @@ from lsst.daf.butler import DimensionUniverse, PersistenceContextVars from lsst.resources import ResourceHandleProtocol, ResourcePath - if TYPE_CHECKING: from ._versionDeserializers import DeserializerBase from .graph import QuantumGraph @@ -224,7 +223,7 @@ def load( # object instantiation. runner = PersistenceContextVars() graph = runner.run(self.deserializer.constructGraph, nodeSet, _readBytes, universe) - return graph # type: ignore + return graph def _readBytes(self, start: int, stop: int) -> bytes: """Load the specified byte range from the ResourcePath object diff --git a/python/lsst/pipe/base/graph/quantumNode.py b/python/lsst/pipe/base/graph/quantumNode.py index 2979e3f1..b5df5d01 100644 --- a/python/lsst/pipe/base/graph/quantumNode.py +++ b/python/lsst/pipe/base/graph/quantumNode.py @@ -23,9 +23,9 @@ __all__ = ("QuantumNode", "NodeId", "BuildId") import uuid +import warnings from dataclasses import dataclass from typing import Any, NewType -import warnings from lsst.daf.butler import ( DatasetRef, @@ -35,6 +35,7 @@ Quantum, SerializedQuantum, ) +from lsst.utils.introspection import find_outside_stacklevel from pydantic import BaseModel from ..pipeline import TaskDef @@ -141,7 +142,8 @@ def from_simple( if recontitutedDimensions is not None: warnings.warn( "The recontitutedDimensions argument is now ignored and may be removed after v 27", - category=DeprecationWarning, + category=FutureWarning, + stacklevel=find_outside_stacklevel("lsst.pipe.base"), ) return QuantumNode( quantum=Quantum.from_simple(simple.quantum, universe), diff --git a/python/lsst/pipe/base/pipeline.py b/python/lsst/pipe/base/pipeline.py index 781defcc..48f3ad05 100644 --- a/python/lsst/pipe/base/pipeline.py +++ b/python/lsst/pipe/base/pipeline.py @@ -192,7 +192,7 @@ def logOutputDatasetName(self) -> str | None: """Name of a dataset type for log output from this task, `None` if logs are not to be saved (`str`) """ - if cast(PipelineTaskConfig, self.config).saveLogOutput: + if self.config.saveLogOutput: return acc.LOG_OUTPUT_TEMPLATE.format(label=self.label) else: return None @@ -623,7 +623,7 @@ def get_data_id(self, universe: DimensionUniverse) -> DataCoordinate: """ instrument_class_name = self._pipelineIR.instrument if instrument_class_name is not None: - instrument_class = doImportType(instrument_class_name) + instrument_class = cast(PipeBaseInstrument, doImportType(instrument_class_name)) if instrument_class is not None: return DataCoordinate.standardize(instrument=instrument_class.getName(), universe=universe) return DataCoordinate.makeEmpty(universe) @@ -654,8 +654,8 @@ def addTask(self, task: type[PipelineTask] | str, label: str) -> None: # be defined without label which is not acceptable, use task # _DefaultName in that case if isinstance(task, str): - task_class = doImportType(task) - label = task_class._DefaultName + task_class = cast(PipelineTask, doImportType(task)) + label = task_class._DefaultName self._pipelineIR.tasks[label] = pipelineIR.TaskIR(label, taskName) def removeTask(self, label: str) -> None: diff --git a/python/lsst/pipe/base/tests/simpleQGraph.py b/python/lsst/pipe/base/tests/simpleQGraph.py index 8b50bf42..6a5289d4 100644 --- a/python/lsst/pipe/base/tests/simpleQGraph.py +++ b/python/lsst/pipe/base/tests/simpleQGraph.py @@ -307,7 +307,7 @@ def populateButler( instrument = pipeline.getInstrument() if instrument is not None: instrument_class = doImportType(instrument) - instrumentName = instrument_class.getName() + instrumentName = cast(Instrument, instrument_class).getName() instrumentClass = get_full_type_name(instrument_class) else: instrumentName = "INSTR"