From 4a3bbf1cbb89e90ea9ca4d6d75dae23ed4b957c9 Mon Sep 17 00:00:00 2001 From: Joe Hamman Date: Thu, 24 Oct 2024 16:27:41 -0700 Subject: [PATCH] test(ci): test on windows and osx (#2431) * 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> --- .github/workflows/gpu_test.yml | 2 +- .github/workflows/hypothesis.yaml | 2 +- .github/workflows/test.yml | 25 ++++++++++++++++++++++--- .pre-commit-config.yaml | 2 -- pyproject.toml | 11 ++++------- src/zarr/storage/local.py | 12 +++++++----- tests/test_sync.py | 4 ++-- 7 files changed, 37 insertions(+), 21 deletions(-) diff --git a/.github/workflows/gpu_test.yml b/.github/workflows/gpu_test.yml index f9e36e9c2e..0403a9c06e 100644 --- a/.github/workflows/gpu_test.yml +++ b/.github/workflows/gpu_test.yml @@ -25,7 +25,7 @@ jobs: strategy: matrix: python-version: ['3.11'] - numpy-version: ['2.0'] + numpy-version: ['2.1'] dependency-set: ["minimal"] steps: diff --git a/.github/workflows/hypothesis.yaml b/.github/workflows/hypothesis.yaml index 85d48bddb1..1029063ef4 100644 --- a/.github/workflows/hypothesis.yaml +++ b/.github/workflows/hypothesis.yaml @@ -26,7 +26,7 @@ jobs: strategy: matrix: python-version: ['3.11'] - numpy-version: ['1.26'] + numpy-version: ['2.1'] dependency-set: ["optional"] steps: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d32f6f793c..2866ed4b85 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 55488c2372..40cddb50cd 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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: diff --git a/pyproject.toml b/pyproject.toml index ef2ccd9469..7be1999480 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -61,7 +61,6 @@ test = [ "pytest", "pytest-cov", "msgpack", - "lmdb", "s3fs", "pytest-asyncio", "moto[s3]", @@ -92,13 +91,11 @@ docs = [ 'numpydoc', 'numcodecs[msgpack]', 'msgpack', - 'lmdb', ] extra = [ 'msgpack', ] optional = [ - 'lmdb', 'universal-pathlib>=0.0.22', ] @@ -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] @@ -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] diff --git a/src/zarr/storage/local.py b/src/zarr/storage/local.py index 5c03009a97..ba13c2c661 100644 --- a/src/zarr/storage/local.py +++ b/src/zarr/storage/local.py @@ -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 @@ -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 diff --git a/tests/test_sync.py b/tests/test_sync.py index 20dbf33d95..a6216a4852 100644 --- a/tests/test_sync.py +++ b/tests/test_sync.py @@ -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: