Skip to content

Commit

Permalink
chore(deps): make fsspec and upath optional dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
jhamman committed Dec 5, 2024
1 parent bda158a commit 3552404
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
9 changes: 4 additions & 5 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
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

0 comments on commit 3552404

Please sign in to comment.