Skip to content

Commit a3688f9

Browse files
authored
fix zarr fsstore regression (#136)
* fix zarr fsstore regression * fix pre-commit * make mypy happy
1 parent 1da2476 commit a3688f9

File tree

3 files changed

+14
-16
lines changed

3 files changed

+14
-16
lines changed

.pre-commit-config.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/pycqa/isort
3-
rev: 5.6.4
3+
rev: 5.12.0
44
hooks:
55
- id: isort
66
args: ["--profile", "black", "--filter-files"]
@@ -9,12 +9,12 @@ repos:
99
hooks:
1010
- id: black
1111
language_version: python3
12-
- repo: https://gitlab.com/pycqa/flake8
12+
- repo: https://github.com/pycqa/flake8
1313
rev: 3.7.9
1414
hooks:
1515
- id: flake8
1616
language_version: python3
1717
- repo: https://github.com/pre-commit/mirrors-mypy
18-
rev: v0.790
18+
rev: v1.0.1
1919
hooks:
2020
- id: mypy

rechunker/pipeline.py

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import itertools
22
import math
3-
from typing import Any, Iterable, Iterator, Tuple, TypeVar
3+
from typing import Any, Iterable, Iterator, Tuple
44

55
import dask
66
import numpy as np
@@ -74,11 +74,8 @@ def specs_to_pipelines(specs: Iterable[CopySpec]) -> ParallelPipelines:
7474
return tuple((spec_to_pipeline(spec) for spec in specs))
7575

7676

77-
T = TypeVar("T")
78-
79-
8077
class CopySpecToPipelinesMixin(CopySpecExecutor):
81-
def prepare_plan(self, specs: Iterable[CopySpec]) -> T:
78+
def prepare_plan(self, specs: Iterable[CopySpec]):
8279
pipelines = specs_to_pipelines(specs)
8380
return self.pipelines_to_plan(pipelines)
8481

tests/test_rechunk.py

+9-8
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import numpy as np
1010
import pytest
1111
import zarr
12+
from zarr.storage import FSStore
1213

1314
from rechunker import api
1415

@@ -208,9 +209,9 @@ def test_rechunk_dataset(
208209
xarray = pytest.importorskip("xarray")
209210

210211
if target_store.startswith("mapper"):
211-
fsspec = pytest.importorskip("fsspec")
212-
target_store = fsspec.get_mapper(str(tmp_path) + target_store)
213-
temp_store = fsspec.get_mapper(str(tmp_path) + temp_store)
212+
pytest.importorskip("fsspec")
213+
target_store = FSStore(str(tmp_path) + target_store)
214+
temp_store = FSStore(str(tmp_path) + temp_store)
214215
else:
215216
target_store = str(tmp_path / target_store)
216217
temp_store = str(tmp_path / temp_store)
@@ -445,16 +446,16 @@ def test_rechunk_dask_array(
445446
@pytest.mark.parametrize("temp_store", ["temp.zarr", "mapper.temp.zarr"])
446447
def test_rechunk_group(tmp_path, executor, source_store, target_store, temp_store):
447448
if source_store.startswith("mapper"):
448-
fsspec = pytest.importorskip("fsspec")
449-
store_source = fsspec.get_mapper(str(tmp_path) + source_store)
450-
target_store = fsspec.get_mapper(str(tmp_path) + target_store)
451-
temp_store = fsspec.get_mapper(str(tmp_path) + temp_store)
449+
pytest.importorskip("fsspec")
450+
store_source = FSStore(str(tmp_path) + source_store)
451+
target_store = FSStore(str(tmp_path) + target_store)
452+
temp_store = FSStore(str(tmp_path) + temp_store)
452453
else:
453454
store_source = str(tmp_path / source_store)
454455
target_store = str(tmp_path / target_store)
455456
temp_store = str(tmp_path / temp_store)
456457

457-
group = zarr.group(store_source)
458+
group = zarr.group(store_source, overwrite=True)
458459
group.attrs["foo"] = "bar"
459460
# 800 byte chunks
460461
a = group.ones("a", shape=(5, 10, 20), chunks=(1, 10, 20), dtype="f4")

0 commit comments

Comments
 (0)