Skip to content

Commit

Permalink
Change refs type of Datastore.transfer_from from Iterator to Collection
Browse files Browse the repository at this point in the history
  • Loading branch information
timj committed Jan 26, 2024
1 parent c1d903b commit 7f485cf
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 13 deletions.
6 changes: 3 additions & 3 deletions python/lsst/daf/butler/datastore/_datastore.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
import time
from abc import ABCMeta, abstractmethod
from collections import abc, defaultdict
from collections.abc import Callable, Iterable, Iterator, Mapping
from collections.abc import Callable, Collection, Iterable, Iterator, Mapping
from typing import TYPE_CHECKING, Any, ClassVar

from lsst.utils import doImportType
Expand Down Expand Up @@ -853,7 +853,7 @@ def ingest(
def transfer_from(
self,
source_datastore: Datastore,
refs: Iterable[DatasetRef],
refs: Collection[DatasetRef],
transfer: str = "auto",
artifact_existence: dict[ResourcePath, bool] | None = None,
dry_run: bool = False,
Expand All @@ -865,7 +865,7 @@ def transfer_from(
source_datastore : `Datastore`
The datastore from which to transfer artifacts. That datastore
must be compatible with this datastore receiving the artifacts.
refs : iterable of `DatasetRef`
refs : `~collections.abc.Collection` of `DatasetRef`
The datasets to transfer from the source datastore.
transfer : `str`, optional
How (and whether) the dataset should be added to the datastore.
Expand Down
7 changes: 3 additions & 4 deletions python/lsst/daf/butler/datastores/chainedDatastore.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
import logging
import time
import warnings
from collections.abc import Iterable, Mapping, Sequence
from collections.abc import Collection, Iterable, Mapping, Sequence
from typing import TYPE_CHECKING, Any

from lsst.daf.butler import DatasetRef, DatasetTypeNotSupportedError, FileDataset
Expand Down Expand Up @@ -1105,7 +1105,7 @@ def export(
def transfer_from(
self,
source_datastore: Datastore,
refs: Iterable[DatasetRef],
refs: Collection[DatasetRef],
transfer: str = "auto",
artifact_existence: dict[ResourcePath, bool] | None = None,
dry_run: bool = False,
Expand All @@ -1120,8 +1120,7 @@ def transfer_from(
# child datastores.
source_datastores = (source_datastore,)

refs = list(refs)
if len(refs) == 0:
if not refs:
# Nothing to transfer.
return set(), set()

Check warning on line 1125 in python/lsst/daf/butler/datastores/chainedDatastore.py

View check run for this annotation

Codecov / codecov/patch

python/lsst/daf/butler/datastores/chainedDatastore.py#L1125

Added line #L1125 was not covered by tests

Expand Down
8 changes: 2 additions & 6 deletions python/lsst/daf/butler/datastores/fileDatastore.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
import hashlib
import logging
from collections import defaultdict
from collections.abc import Callable, Iterable, Mapping, Sequence
from collections.abc import Callable, Collection, Iterable, Mapping, Sequence
from typing import TYPE_CHECKING, Any, ClassVar, cast

from lsst.daf.butler import (
Expand Down Expand Up @@ -2370,7 +2370,7 @@ def emptyTrash(self, ignore_errors: bool = True) -> None:
def transfer_from(
self,
source_datastore: Datastore,
refs: Iterable[DatasetRef],
refs: Collection[DatasetRef],
transfer: str = "auto",
artifact_existence: dict[ResourcePath, bool] | None = None,
dry_run: bool = False,
Expand Down Expand Up @@ -2403,10 +2403,6 @@ def transfer_from(
if artifact_existence is None:
artifact_existence = {}

# We will go through the list multiple times so must convert
# generators to lists.
refs = list(refs)

# In order to handle disassembled composites the code works
# at the records level since it can assume that internal APIs
# can be used.
Expand Down

0 comments on commit 7f485cf

Please sign in to comment.