Skip to content

Commit 257bf3f

Browse files
committed
2 parents 39f2b35 + 4e633ad commit 257bf3f

File tree

12 files changed

+54
-13
lines changed

12 files changed

+54
-13
lines changed

.github/workflows/needs_release_notes.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ on:
55

66
jobs:
77
triage:
8+
if: ${{ github.event.pull_request.user.login != 'dependabot[bot]' }} && ${{ github.event.pull_request.user.login != 'pre-commit-ci[bot]' }}
89
runs-on: ubuntu-latest
910
steps:
1011
- uses: actions/labeler@main

docs/release.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ Unreleased
1717
* Fix bug that caused double counting of groups in ``groups()`` and ``group_keys()``
1818
methods with V3 stores.
1919
By :user:`Ryan Abernathey <rabernat>` :issue:`1228`.
20+
* Handle fsspec.FSMap using FSStore store
21+
By :user:`Rafal Wojdyla <ravwojdyla>` :issue:`1304`.
2022

2123
* Add support for setting user-defined attributes at array / group creation time.
2224
By :user: `Davis Bennett <d-v-b>` :issue:`538`.

docs/spec/v1.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,9 @@ are converted to strings and concatenated with the period character
144144
('.') separating each index. For example, given an array with shape
145145
(10000, 10000) and chunk shape (1000, 1000) there will be 100 chunks
146146
laid out in a 10 by 10 grid. The chunk with indices (0, 0) provides
147-
data for rows 0-1000 and columns 0-1000 and is stored under the key
148-
'0.0'; the chunk with indices (2, 4) provides data for rows 2000-3000
149-
and columns 4000-5000 and is stored under the key '2.4'; etc.
147+
data for rows 0-999 and columns 0-999 and is stored under the key
148+
'0.0'; the chunk with indices (2, 4) provides data for rows 2000-2999
149+
and columns 4000-4999 and is stored under the key '2.4'; etc.
150150

151151
There is no need for all chunks to be present within an array
152152
store. If a chunk is not present then it is considered to be in an

docs/spec/v2.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -216,9 +216,9 @@ To form a string key for a chunk, the indices are converted to strings and
216216
concatenated with the period character (".") separating each index. For
217217
example, given an array with shape (10000, 10000) and chunk shape (1000, 1000)
218218
there will be 100 chunks laid out in a 10 by 10 grid. The chunk with indices
219-
(0, 0) provides data for rows 0-1000 and columns 0-1000 and is stored under the
220-
key "0.0"; the chunk with indices (2, 4) provides data for rows 2000-3000 and
221-
columns 4000-5000 and is stored under the key "2.4"; etc.
219+
(0, 0) provides data for rows 0-999 and columns 0-999 and is stored under the
220+
key "0.0"; the chunk with indices (2, 4) provides data for rows 2000-2999 and
221+
columns 4000-4999 and is stored under the key "2.4"; etc.
222222

223223
There is no need for all chunks to be present within an array store. If a chunk
224224
is not present then it is considered to be in an uninitialized state. An

docs/tutorial.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -525,9 +525,9 @@ When the indexing arrays have different shapes, they are broadcast together.
525525
That is, the following two calls are equivalent::
526526

527527
>>> z[1, [1, 3]]
528-
array([5, 7])
528+
array([6, 8])
529529
>>> z[[1, 1], [1, 3]]
530-
array([5, 7])
530+
array([6, 8])
531531

532532
Indexing with a mask array
533533
~~~~~~~~~~~~~~~~~~~~~~~~~~

requirements_dev_minimal.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ asciitree==0.3.3
33
fasteners==0.18
44
numcodecs==0.11.0
55
msgpack-python==0.5.6
6-
setuptools-scm==7.0.5
6+
setuptools-scm==7.1.0
77
# test requirements
88
pytest==7.2.0

requirements_dev_numpy.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# Break this out into a separate file to allow testing against
22
# different versions of numpy. This file should pin to the latest
33
# numpy version.
4-
numpy==1.23.5
4+
numpy==1.24.0

requirements_dev_optional.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# optional library requirements
22
# bsddb3==6.2.6; sys_platform != 'win32'
3-
lmdb==1.3.0; sys_platform != 'win32'
3+
lmdb==1.4.0; sys_platform != 'win32'
44
# optional library requirements for Jupyter
55
ipytree==0.2.2
6-
ipywidgets==8.0.2
6+
ipywidgets==8.0.3
77
# optional library requirements for services
88
# don't let pyup change pinning for azure-storage-blob, need to pin to older
99
# version to get compatibility with azure storage emulator on appveyor (FIXME)
@@ -14,7 +14,6 @@ types-setuptools
1414
pymongo==4.3.3
1515
# optional test requirements
1616
coverage
17-
flake8==5.0.4
1817
pytest-cov==4.0.0
1918
pytest-doctestplus==0.12.1
2019
pytest-timeout==2.1.0

zarr/_storage/v3.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,16 @@ def _normalize_store_arg_v3(store: Any, storage_options=None, mode="r") -> BaseS
567567
return store
568568
if isinstance(store, os.PathLike):
569569
store = os.fspath(store)
570+
if FSStore._fsspec_installed():
571+
import fsspec
572+
if isinstance(store, fsspec.FSMap):
573+
return FSStoreV3(store.root,
574+
fs=store.fs,
575+
mode=mode,
576+
check=store.check,
577+
create=store.create,
578+
missing_exceptions=store.missing_exceptions,
579+
**(storage_options or {}))
570580
if isinstance(store, str):
571581
if "://" in store or "::" in store:
572582
store = FSStoreV3(store, mode=mode, **(storage_options or {}))

zarr/storage.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,16 @@ def _normalize_store_arg_v2(store: Any, storage_options=None, mode="r") -> BaseS
142142
return store
143143
if isinstance(store, os.PathLike):
144144
store = os.fspath(store)
145+
if FSStore._fsspec_installed():
146+
import fsspec
147+
if isinstance(store, fsspec.FSMap):
148+
return FSStore(store.root,
149+
fs=store.fs,
150+
mode=mode,
151+
check=store.check,
152+
create=store.create,
153+
missing_exceptions=store.missing_exceptions,
154+
**(storage_options or {}))
145155
if isinstance(store, str):
146156
if "://" in store or "::" in store:
147157
return FSStore(store, mode=mode, **(storage_options or {}))
@@ -1341,6 +1351,8 @@ def __init__(self, url, normalize_keys=False, key_separator=None,
13411351
create=False,
13421352
missing_exceptions=None,
13431353
**storage_options):
1354+
if not self._fsspec_installed(): # pragma: no cover
1355+
raise ImportError("`fsspec` is required to use zarr's FSStore")
13441356
import fsspec
13451357

13461358
mapper_options = {"check": check, "create": create}
@@ -1512,6 +1524,13 @@ def clear(self):
15121524
raise ReadOnlyError()
15131525
self.map.clear()
15141526

1527+
@classmethod
1528+
def _fsspec_installed(cls):
1529+
"""Returns true if fsspec is installed"""
1530+
import importlib.util
1531+
1532+
return importlib.util.find_spec("fsspec") is not None
1533+
15151534

15161535
class TempStore(DirectoryStore):
15171536
"""Directory store using a temporary directory for storage.

0 commit comments

Comments
 (0)