From 44f5f6c72abb2a641a3d2efa40bb684f75d3cf44 Mon Sep 17 00:00:00 2001 From: Nate Lust Date: Tue, 4 Jul 2023 09:33:56 -0400 Subject: [PATCH] More typing changes --- python/lsst/pipe/base/connections.py | 10 +++++----- python/lsst/pipe/base/graph/_implDetails.py | 6 ++++-- python/lsst/pipe/base/graphBuilder.py | 5 +++-- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/python/lsst/pipe/base/connections.py b/python/lsst/pipe/base/connections.py index 556cfa01..3d54150f 100644 --- a/python/lsst/pipe/base/connections.py +++ b/python/lsst/pipe/base/connections.py @@ -39,7 +39,7 @@ import itertools import string from collections import UserDict -from collections.abc import Collection, Generator, Iterable, Mapping, Set +from collections.abc import Collection, Generator, Iterable, Mapping, Sequence, Set from dataclasses import dataclass from types import MappingProxyType, SimpleNamespace from typing import TYPE_CHECKING, Any @@ -934,12 +934,12 @@ class AdjustQuantumHelper: connection-oriented mappings used inside `PipelineTaskConnections`. """ - inputs: NamedKeyMapping[DatasetType, tuple[DatasetRef]] + inputs: NamedKeyMapping[DatasetType, Sequence[DatasetRef]] """Mapping of regular input and prerequisite input datasets, grouped by `~lsst.daf.butler.DatasetType`. """ - outputs: NamedKeyMapping[DatasetType, tuple[DatasetRef]] + outputs: NamedKeyMapping[DatasetType, Sequence[DatasetRef]] """Mapping of output datasets, grouped by `~lsst.daf.butler.DatasetType`. """ @@ -997,7 +997,7 @@ def adjust_in_place( # Translate adjustments to DatasetType-keyed, Quantum-oriented form, # installing new mappings in self if necessary. if adjusted_inputs_by_connection: - adjusted_inputs = NamedKeyDict[DatasetType, tuple[DatasetRef]](self.inputs) + adjusted_inputs = NamedKeyDict[DatasetType, tuple[DatasetRef, ...]](self.inputs) for name, (connection, updated_refs) in adjusted_inputs_by_connection.items(): dataset_type_name = connection.name if not set(updated_refs).issubset(self.inputs[dataset_type_name]): @@ -1012,7 +1012,7 @@ def adjust_in_place( else: self.inputs_adjusted = False if adjusted_outputs_by_connection: - adjusted_outputs = NamedKeyDict[DatasetType, tuple[DatasetRef]](self.outputs) + adjusted_outputs = NamedKeyDict[DatasetType, tuple[DatasetRef, ...]](self.outputs) for name, (connection, updated_refs) in adjusted_outputs_by_connection.items(): dataset_type_name = connection.name if not set(updated_refs).issubset(self.outputs[dataset_type_name]): diff --git a/python/lsst/pipe/base/graph/_implDetails.py b/python/lsst/pipe/base/graph/_implDetails.py index 3f27faec..6472ab06 100644 --- a/python/lsst/pipe/base/graph/_implDetails.py +++ b/python/lsst/pipe/base/graph/_implDetails.py @@ -313,13 +313,15 @@ def _pruner( # from the graph. try: helper.adjust_in_place(node.taskDef.connections, node.taskDef.label, node.quantum.dataId) + # ignore the types because quantum really can take a sequence + # of inputs newQuantum = Quantum( taskName=node.quantum.taskName, taskClass=node.quantum.taskClass, dataId=node.quantum.dataId, initInputs=node.quantum.initInputs, - inputs=helper.inputs, - outputs=helper.outputs, + inputs=helper.inputs, # type: ignore + outputs=helper.outputs, # type: ignore ) # If the inputs or outputs were adjusted to something different # than what was supplied by the graph builder, dissassociate diff --git a/python/lsst/pipe/base/graphBuilder.py b/python/lsst/pipe/base/graphBuilder.py index c9ee2978..fb5620f0 100644 --- a/python/lsst/pipe/base/graphBuilder.py +++ b/python/lsst/pipe/base/graphBuilder.py @@ -455,13 +455,14 @@ def makeQuantum(self, datastore_records: Mapping[str, DatastoreRecordData] | Non matching_records = records.subset(input_ids) if matching_records is not None: quantum_records[datastore_name] = matching_records + # ignore the types because quantum really can take a sequence of inputs return Quantum( taskName=self.task.taskDef.taskName, taskClass=self.task.taskDef.taskClass, dataId=self.dataId, initInputs=initInputs, - inputs=helper.inputs, - outputs=helper.outputs, + inputs=helper.inputs, # type: ignore + outputs=helper.outputs, # type: ignore datastore_records=quantum_records, )