Skip to content

Commit c0fd1ef

Browse files
authored
Merge pull request #266 from scipp/data-retriever
Use a new unzip processor for each file
2 parents 48dc3e4 + 293138e commit c0fd1ef

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

src/ess/reduce/data/_registry.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,6 @@ def __init__(
176176
base_url=base_url,
177177
retry_if_failed=retry_if_failed,
178178
)
179-
self._unzip_processor = _import_pooch().Unzip()
180179
super().__init__(files)
181180

182181
@cache # noqa: B019
@@ -192,6 +191,12 @@ def get_path(self, name: str) -> Path:
192191
return Path(_expect_single_unzipped(paths, name))
193192
return Path(self._registry.fetch(name))
194193

194+
@property
195+
def _unzip_processor(self) -> Any:
196+
# Create a new processor on demand because reusing the same processor would
197+
# reuse the same output path for every file.
198+
return _import_pooch().Unzip()
199+
195200

196201
class LocalRegistry(Registry):
197202
def __init__(
@@ -212,8 +217,7 @@ def __init__(
212217
base_url=base_url,
213218
retry_if_failed=retry_if_failed,
214219
)
215-
pooch = _import_pooch()
216-
self._unzip_processor = pooch.processors.Unzip(extract_dir=pooch_registry.path)
220+
self._extract_dir = pooch_registry.path
217221
self._source_path = source_path.resolve().joinpath(*prefix.split("/"), version)
218222
super().__init__(files)
219223

@@ -247,6 +251,12 @@ def _local_path(self, name: str) -> Path:
247251
# value is a system path, i.e., it can be a Windows-style path.
248252
return self._source_path.joinpath(*name.split("/"))
249253

254+
@property
255+
def _unzip_processor(self) -> Any:
256+
# Create a new processor on demand because reusing the same processor would
257+
# reuse the same output path for every file.
258+
return _import_pooch().Unzip(self._extract_dir)
259+
250260

251261
def _import_pooch() -> Any:
252262
try:

0 commit comments

Comments
 (0)