Skip to content

chore(deps): make fsspec and upath optional dependencies #2534

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions docs/release.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,32 @@ Release notes
See `GH1777 <https://github.com/zarr-developers/zarr-python/issues/1777>`_ for more details on the upcoming
3.0 release.

.. release_3.0.0-beta:

3.0.0-beta series
-----------------

.. warning::
Zarr-Python 3.0.0-beta is a pre-release of the upcoming 3.0 release. This release is not feature complete or
expected to be ready for production applications.

.. note::
The complete release notes for 3.0 have not been added to this document yet. See the
`3.0.0-beta <https://github.com/zarr-developers/zarr-python/releases/tag/v3.0.0-beta>`_ release on GitHub
for a record of changes included in this release.

Dependency Changes
~~~~~~~~~~~~~~~~~~

* fsspec was moved from a required dependency to an optional one. Users should install
fsspec and any relevant implementations (e.g. s3fs) before using the ``RemoteStore``.
By :user:`Joe Hamman <jhamman>` :issue:`2391`.


.. release_3.0.0-alpha:

3.0.0-alpha
-----------
3.0.0-alpha series
------------------

.. warning::
Zarr-Python 3.0.0-alpha is a pre-release of the upcoming 3.0 release. This release is not feature complete or
Expand Down
11 changes: 5 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ requires-python = ">=3.11"
dependencies = [
'numpy>=1.25',
'numcodecs[crc32c]>=0.14',
'fsspec>=2022.10.0',
'typing_extensions>=4.6',
'typing_extensions>=4.9',
'donfig>=0.8',
]

Expand All @@ -54,16 +53,16 @@ license = {text = "MIT License"}
keywords = ["Python", "compressed", "ndimensional-arrays", "zarr"]

[project.optional-dependencies]
fsspec = [
"fsspec>=2023.10.0",
]
test = [
"coverage",
"pytest",
"pytest-cov",
"msgpack",
"s3fs",
"pytest-asyncio",
"moto[s3]",
"flask-cors",
"flask",
"requests",
"mypy",
"hypothesis",
Expand Down Expand Up @@ -224,7 +223,7 @@ dependencies = [
'fsspec==2022.10.0',
's3fs==2022.10.0',
'universal_pathlib==0.0.22',
'typing_extensions==4.6.*', # 4.5 needed for @deprecated, 4.6 for Buffer
'typing_extensions==4.9.*',
'donfig==0.8.*',
# test deps
'hypothesis',
Expand Down
10 changes: 7 additions & 3 deletions tests/test_store/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

import pytest
from _pytest.compat import LEGACY_PATH
from upath import UPath

from zarr.core.common import AccessModeLiteral
from zarr.storage._utils import normalize_path
Expand Down Expand Up @@ -72,6 +71,7 @@ async def test_make_store_path_invalid() -> None:


async def test_make_store_path_fsspec(monkeypatch) -> None:
pytest.importorskip("fsspec")
store_path = await make_store_path("http://foo.com/bar")
assert isinstance(store_path.store, RemoteStore)

Expand Down Expand Up @@ -106,13 +106,17 @@ async def test_unsupported() -> None:
"foo/bar///",
Path("foo/bar"),
b"foo/bar",
UPath("foo/bar"),
],
)
def test_normalize_path_valid(path: str | bytes | Path | UPath) -> None:
def test_normalize_path_valid(path: str | bytes | Path) -> None:
assert normalize_path(path) == "foo/bar"


def test_normalize_path_upath() -> None:
upath = pytest.importorskip("upath")
assert normalize_path(upath.UPath("foo/bar")) == "foo/bar"


def test_normalize_path_none():
assert normalize_path(None) == ""

Expand Down
6 changes: 3 additions & 3 deletions tests/test_store/test_remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@
import os
from typing import TYPE_CHECKING

import fsspec
import pytest
from botocore.session import Session
from upath import UPath

import zarr.api.asynchronous
from zarr.core.buffer import Buffer, cpu, default_buffer_prototype
Expand All @@ -21,6 +19,7 @@
import botocore.client


fsspec = pytest.importorskip("fsspec")
s3fs = pytest.importorskip("s3fs")
requests = pytest.importorskip("requests")
moto_server = pytest.importorskip("moto.moto_server.threaded_moto_server")
Expand Down Expand Up @@ -182,7 +181,8 @@ async def test_remote_store_from_uri(self, store: RemoteStore):
assert dict(group.attrs) == {"key": "value-3"}

def test_from_upath(self) -> None:
path = UPath(
upath = pytest.importorskip("upath")
path = upath.UPath(
f"s3://{test_bucket_name}/foo/bar/",
endpoint_url=endpoint_url,
anon=False,
Expand Down
Loading