Skip to content

Commit

Permalink
test(ci): test on windows and osx (zarr-developers#2431)
Browse files Browse the repository at this point in the history
* test(ci): test on windows and osx

* add os to name

* bail on making np upper bound super flexible

* remove lmdb

* remove types-redis

* fixup

* tweak timeout

* to_posix in LocalStore

* no mo windows

* Update src/zarr/storage/local.py

* Update .github/workflows/test.yml

* style: pre-commit fixes

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
jhamman and pre-commit-ci[bot] authored Oct 24, 2024
1 parent f4af51c commit 4a3bbf1
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/gpu_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
strategy:
matrix:
python-version: ['3.11']
numpy-version: ['2.0']
numpy-version: ['2.1']
dependency-set: ["minimal"]

steps:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/hypothesis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
strategy:
matrix:
python-version: ['3.11']
numpy-version: ['1.26']
numpy-version: ['2.1']
dependency-set: ["optional"]

steps:
Expand Down
25 changes: 22 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,33 @@ concurrency:

jobs:
test:
name: py=${{ matrix.python-version }}, np=${{ matrix.numpy-version }}, deps=${{ matrix.dependency-set }}
name: os=${{ matrix.os }}, py=${{ matrix.python-version }}, np=${{ matrix.numpy-version }}, deps=${{ matrix.dependency-set }}

runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.11', '3.12', '3.13']
numpy-version: ['1.25', '1.26', '2.0']
numpy-version: ['1.25', '2.1']
dependency-set: ["minimal", "optional"]
os: ["ubuntu-latest"]
include:
- python-version: '3.11'
numpy-version: '1.25'
dependency-set: 'optional'
os: 'macos-latest'
- python-version: '3.13'
numpy-version: '2.1'
dependency-set: 'optional'
os: 'macos-latest'
# https://github.com/zarr-developers/zarr-python/issues/2438
# - python-version: '3.11'
# numpy-version: '1.25'
# dependency-set: 'optional'
# os: 'windows-latest'
# - python-version: '3.13'
# numpy-version: '2.1'
# dependency-set: 'optional'
# os: 'windows-latest'
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v4
Expand Down
2 changes: 0 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ repos:
- universal-pathlib
# Tests
- pytest
# Zarr v2
- types-redis
- repo: https://github.com/scientific-python/cookie
rev: 2024.08.19
hooks:
Expand Down
11 changes: 4 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ test = [
"pytest",
"pytest-cov",
"msgpack",
"lmdb",
"s3fs",
"pytest-asyncio",
"moto[s3]",
Expand Down Expand Up @@ -92,13 +91,11 @@ docs = [
'numpydoc',
'numcodecs[msgpack]',
'msgpack',
'lmdb',
]
extra = [
'msgpack',
]
optional = [
'lmdb',
'universal-pathlib>=0.0.22',
]

Expand Down Expand Up @@ -135,17 +132,17 @@ features = ["test", "extra"]

[[tool.hatch.envs.test.matrix]]
python = ["3.11", "3.12", "3.13"]
numpy = ["1.25", "1.26", "2.0"]
numpy = ["1.25", "2.1"]
version = ["minimal"]

[[tool.hatch.envs.test.matrix]]
python = ["3.11", "3.12", "3.13"]
numpy = ["1.25", "1.26", "2.0"]
numpy = ["1.25", "2.1"]
features = ["optional"]

[[tool.hatch.envs.test.matrix]]
python = ["3.11", "3.12", "3.13"]
numpy = ["1.25", "1.26", "2.0"]
numpy = ["1.25", "2.1"]
features = ["gpu"]

[tool.hatch.envs.test.scripts]
Expand All @@ -166,7 +163,7 @@ features = ["test", "extra", "gpu"]

[[tool.hatch.envs.gputest.matrix]]
python = ["3.11", "3.12", "3.13"]
numpy = ["1.25", "1.26", "2.0"]
numpy = ["1.25", "2.1"]
version = ["minimal"]

[tool.hatch.envs.gputest.scripts]
Expand Down
12 changes: 7 additions & 5 deletions src/zarr/storage/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,17 +219,19 @@ async def exists(self, key: str) -> bool:

async def list(self) -> AsyncGenerator[str, None]:
# docstring inherited
to_strip = str(self.root) + "/"
to_strip = self.root.as_posix() + "/"
for p in list(self.root.rglob("*")):
if p.is_file():
yield str(p).replace(to_strip, "")
yield p.as_posix().replace(to_strip, "")

async def list_prefix(self, prefix: str) -> AsyncGenerator[str, None]:
# docstring inherited
to_strip = os.path.join(str(self.root / prefix))
to_strip = (
(self.root / prefix).as_posix() + "/"
) # TODO: fixme in https://github.com/zarr-developers/zarr-python/issues/2438
for p in (self.root / prefix).rglob("*"):
if p.is_file():
yield str(p.relative_to(to_strip))
yield p.as_posix().replace(to_strip, "")

async def list_dir(self, prefix: str) -> AsyncGenerator[str, None]:
# docstring inherited
Expand All @@ -239,6 +241,6 @@ async def list_dir(self, prefix: str) -> AsyncGenerator[str, None]:
try:
key_iter = base.iterdir()
for key in key_iter:
yield str(key).replace(to_strip, "")
yield key.as_posix().replace(to_strip, "")
except (FileNotFoundError, NotADirectoryError):
pass
4 changes: 2 additions & 2 deletions tests/test_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,13 @@ def test_sync_raises(sync_loop: asyncio.AbstractEventLoop | None) -> None:


def test_sync_timeout() -> None:
duration = 0.002
duration = 0.02

async def foo() -> None:
await asyncio.sleep(duration)

with pytest.raises(asyncio.TimeoutError):
sync(foo(), timeout=duration / 2)
sync(foo(), timeout=duration / 10)


def test_sync_raises_if_no_coroutine(sync_loop: asyncio.AbstractEventLoop | None) -> None:
Expand Down

0 comments on commit 4a3bbf1

Please sign in to comment.