Skip to content

test(ci): add test environment for upstream dependencies #2418

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 6 commits into from
Oct 21, 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
27 changes: 27 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,30 @@ jobs:
- name: Run Tests
run: |
hatch env run --env test.py${{ matrix.python-version }}-${{ matrix.numpy-version }}-${{ matrix.dependency-set }} run

upstream:
name: py=${{ matrix.python-version }}-upstream

runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.13']

steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
- name: Install Hatch
run: |
python -m pip install --upgrade pip
pip install hatch
- name: Set Up Hatch Env
run: |
hatch env create upstream
hatch env run -e upstream list-env
- name: Run Tests
run: |
hatch env run --env upstream run
29 changes: 29 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,35 @@ features = ['docs']
build = "cd docs && make html"
serve = "sphinx-autobuild docs docs/_build --host 0.0.0.0"

[tool.hatch.envs.upstream]
dependencies = [
'numpy', # from scientific-python-nightly-wheels
'numcodecs @ git+https://github.com/zarr-developers/numcodecs',
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be great if we could get numcodecs up on the scientific-python-nightly-wheels index...

zarr-developers/numcodecs#313

'fsspec @ git+https://github.com/fsspec/filesystem_spec',
's3fs @ git+https://github.com/fsspec/s3fs',
'universal_pathlib @ git+https://github.com/fsspec/universal_pathlib',
'crc32c @ git+https://github.com/ICRAR/crc32c',
'typing_extensions @ git+https://github.com/python/typing_extensions',
'donfig @ git+https://github.com/pytroll/donfig',
# test deps
'hypothesis',
'pytest',
'pytest-cov',
'pytest-asyncio',
'moto[s3]',
]

[tool.hatch.envs.upstream.env-vars]
PIP_INDEX_URL = "https://pypi.anaconda.org/scientific-python-nightly-wheels/simple/"
PIP_EXTRA_INDEX_URL = "https://pypi.org/simple/"
PIP_PRE = "1"

[tool.hatch.envs.upstream.scripts]
run = "pytest --verbose"
run-mypy = "mypy src"
run-hypothesis = "pytest --hypothesis-profile ci tests/test_properties.py tests/test_store/test_stateful*"
list-env = "pip list"

[tool.ruff]
line-length = 100
force-exclude = true
Expand Down
7 changes: 4 additions & 3 deletions src/zarr/codecs/zstd.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
import asyncio
from dataclasses import dataclass
from functools import cached_property
from importlib.metadata import version
from typing import TYPE_CHECKING

import numcodecs
from numcodecs.zstd import Zstd
from packaging.version import Version

from zarr.abc.codec import BytesBytesCodec
from zarr.core.buffer.cpu import as_numpy_array_wrapper
Expand Down Expand Up @@ -43,8 +44,8 @@ class ZstdCodec(BytesBytesCodec):

def __init__(self, *, level: int = 0, checksum: bool = False) -> None:
# numcodecs 0.13.0 introduces the checksum attribute for the zstd codec
_numcodecs_version = tuple(map(int, version("numcodecs").split(".")))
if _numcodecs_version < (0, 13, 0): # pragma: no cover
_numcodecs_version = Version(numcodecs.__version__)
if _numcodecs_version < Version("0.13.0"):
raise RuntimeError(
"numcodecs version >= 0.13.0 is required to use the zstd codec. "
f"Version {_numcodecs_version} is currently installed."
Expand Down