-
-
Notifications
You must be signed in to change notification settings - Fork 423
Add Pyodide support and CI jobs for Zarr #1903
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
Open
agriyakhetarpal
wants to merge
122
commits into
zarr-developers:main
Choose a base branch
from
agriyakhetarpal:emscripten
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 76 commits
Commits
Show all changes
122 commits
Select commit
Hold shift + click to select a range
9f5a110
Add CI job to test out-of-tree Pyodide builds
agriyakhetarpal 29282fc
Add `[msgpack]` dependency for `numcodecs`
agriyakhetarpal d465742
Bump to Pyodide 0.26.0, update comments
agriyakhetarpal cdf0bb2
Try to run tests without async
agriyakhetarpal dfe0321
Move shared file to rootdir, outside v2 and v3
agriyakhetarpal b100ec9
Move `fasteners` import inside ThreadSynchronizer
agriyakhetarpal b0dddca
Make the tests directory importable, fix `_shared`
agriyakhetarpal d227728
Import list of greetings from `numcodecs`
agriyakhetarpal fdb2bef
Skip some tests that use threading
agriyakhetarpal 621077a
Skip some tests that use `fcntl`
agriyakhetarpal 7ae9a97
Skip tests that require `dbm`
agriyakhetarpal 22eb6da
Move `IS_WASM` logic to internal `zarr` API
agriyakhetarpal 6836947
Skip a few tests trying to import `multiprocessing`
agriyakhetarpal fe3bf27
Skip tests that use async and threading code
agriyakhetarpal 08997ec
Improve `asyncio_tests_wrapper`, fix test imports
agriyakhetarpal 9bfc860
Skip entire `test_codecs.py` file
agriyakhetarpal 9bcb350
Skip yet another test that requires threads
agriyakhetarpal 9985abb
xfail test where array's fill values are different
agriyakhetarpal 7ea12ef
xfail test because Emscripten FS
agriyakhetarpal a6565de
Skip last test that tries to run threads
agriyakhetarpal 85f621c
Another test that tries to run threads
agriyakhetarpal 1a64255
xfail another array's differing `fill_values` test
agriyakhetarpal c8cb38b
Skip entire sync file under WASM, no threading
agriyakhetarpal eb36d40
Restore pytest config options, remove when needed
agriyakhetarpal e3bf365
Merge main
agriyakhetarpal b3a5b8a
Bump Emscripten, Pyodide xbuildenv, Node.js versions
agriyakhetarpal 42d2792
Running on `ubuntu-latest` should be fine
agriyakhetarpal 27068e2
Don't persist credentials with git clone
agriyakhetarpal aff9b18
Don't pin the version of `pyodide-build`
agriyakhetarpal bb2c136
Use same xbuildenv for building and testing
agriyakhetarpal 710195a
Temporarily build numcodecs for WASM as well
agriyakhetarpal 07e5bc9
Use Pyodide 0.28.0a2 for now
agriyakhetarpal 403fbb0
Use `fetch-depth: 0` to bring correct versions
agriyakhetarpal 24dbc77
Skip `test_multiprocessing` for WASM
agriyakhetarpal ecea615
Skip all sync tests
agriyakhetarpal d919bd7
xfail `test_array_roundtrip` for now
agriyakhetarpal 0bb7d47
Skip `test_group_members_performance[memory]` for now
agriyakhetarpal fb59eba
Set concurrency and max workers as 1
agriyakhetarpal 4c6bed6
Update `zarr.config` tests to match
agriyakhetarpal 6754131
Move WASM check to resolve circular import
agriyakhetarpal f426ed7
Mark Blosc `test_typesize` as a known failure case
agriyakhetarpal 405d247
Skip `async.concurrency` config override test case
agriyakhetarpal e93073a
Mark some indexing tests as flaky on WASM
agriyakhetarpal d862953
Oops, fix a config test
agriyakhetarpal cbd1d4d
Fix another config test
agriyakhetarpal 3e8bdef
Hook into Pyodide WebLoop
agriyakhetarpal 4ee492e
Move `zarr.constants` to `zarr._constants`
agriyakhetarpal d94970e
Bump to Pyodide 0.28.0a3
agriyakhetarpal cd3424c
Fix typo
agriyakhetarpal 5044a22
`asyncio_mode = "auto"` works now, clean it up
agriyakhetarpal e131867
Restore `test_group_members_performance`
agriyakhetarpal c7c22dc
Disable SIMD when building numcodecs
agriyakhetarpal e62c933
Oops, disable AVX2, SSE2 at the right place
agriyakhetarpal d3bcf56
Debug improper numcodecs version
agriyakhetarpal e4b7379
Debug numcodecs version again
agriyakhetarpal 35cecc1
Fetch tags manually for now
agriyakhetarpal ceb70c7
Force Zarr to install
agriyakhetarpal 1ea992f
Install `numcodecs` with `crc32c`
agriyakhetarpal f51ddd1
Install the rest of the missing dependencies
agriyakhetarpal 0ec47b9
Escape wheel filename correctly
agriyakhetarpal e1617c0
Remove extra install line
agriyakhetarpal 23e34bf
Fix misquoted end
agriyakhetarpal 22e6795
Remove lenience for performance test, skip it instead
agriyakhetarpal da8bfc7
Undo async.concurrency to 1, improve performance
agriyakhetarpal 81f5df3
Add `slow_wasm` marker, skip orthogonal indexing tests
agriyakhetarpal bad9920
Move WebLoop patch to `conftest.py`
agriyakhetarpal 2217455
Mark more indexing tests as slow in WASM
agriyakhetarpal 86f8785
Fix condition for slow WASM tests
agriyakhetarpal 3230892
Clearer skip message for slow WASM tests
agriyakhetarpal 07b5645
Merge main
agriyakhetarpal ef70cbd
Add release note for Pyodide/WASM support.
agriyakhetarpal 9212c0e
Ignore WASM code paths Codecov doesn't know about
agriyakhetarpal 86323eb
Bring back numcodecs version check
agriyakhetarpal 9c6af32
Revert "Bring back numcodecs version check"
agriyakhetarpal 090c62b
Add guidance highlighting JSPI requirement
agriyakhetarpal 3f2d41d
Merge branch 'main' into emscripten
agriyakhetarpal b89f682
Drop `shutdown_asyncgens` fixture
agriyakhetarpal 700aae4
Clarify docs for JSPI availability and usage
agriyakhetarpal 93680d2
Merge branch 'main' into emscripten
agriyakhetarpal 401311e
Fix lint error
agriyakhetarpal dd25a36
Update release note with JSPI info
agriyakhetarpal f888142
Merge main
agriyakhetarpal 9161ea9
Modernise emscripten workflow
agriyakhetarpal 3533283
Ignore some test dependencies on emscripten
agriyakhetarpal 4f31bc2
Add hatch scaffolding for easier Pyodide testing
agriyakhetarpal f9e3b92
Ignore sharded Morton indexing benchmark
agriyakhetarpal ddbaae4
Ignore `test_v2_dtype_regression` for Emscripten
agriyakhetarpal a1bbcf8
numcodecs version check can be brought back
agriyakhetarpal 6874bab
Use `os.rename` for Emscripten
agriyakhetarpal 531585f
Blosc size mismatch no longer occurs!
agriyakhetarpal 5038b0c
Skip `test_scripts_can_run`, uses subprocesses
agriyakhetarpal ed8eaf0
Allow running a portion of tests if specified
agriyakhetarpal 9b3e15e
Add monkeypatch for pytest-asyncio to use WebLoop
agriyakhetarpal 524e962
Patch `asyncio.Runner.__enter__` also
agriyakhetarpal 5344cee
Fix Emscripten os.rename silently overwriting files + corrupting grou…
agriyakhetarpal 0b2a565
Stop-gap `test_typesize`'s size mismatch (for now)
agriyakhetarpal 548f7cf
Skip hypothesis problems because IDK what to do
agriyakhetarpal 7e4f3b1
Remove some lint
agriyakhetarpal 19f79bf
Better typing for asyncio monkeypatch
agriyakhetarpal 1f4db1b
Update CHANGELOG file format, JSPI default enabled
agriyakhetarpal cff0f08
Make Pyodide hatch env run on Python 3.14
agriyakhetarpal 978870f
Merge branch 'main' into emscripten
agriyakhetarpal 786e593
Add some tests for `_safe_move`
agriyakhetarpal cd3a59b
Reduce verbosity in GHA test logs, too hard to scroll
agriyakhetarpal e20043e
Fix lint
agriyakhetarpal 2796de5
Split safe move method across platforms
agriyakhetarpal 3b31588
Remove outdated pyodide webloop warning ignore
agriyakhetarpal 716dbcb
Properly ignore benchmark tests when using posargs
agriyakhetarpal 3b64a34
Experiment if we can remove the `slow_wasm` option now
agriyakhetarpal 3b86ee5
Update JSPI support message to align with 2026
agriyakhetarpal 6fde927
Merge main
agriyakhetarpal 33c7e5b
Use `--clear` when creating Pyodide venvs
agriyakhetarpal 440995e
Merge main
agriyakhetarpal 4a6017b
Bump to stable Pyodide v314.0.0
agriyakhetarpal 1183f2a
Temporarily pin pytest<9.1.0
agriyakhetarpal ae436c7
pytest v9.1.1 is out, update deps and lockfile
agriyakhetarpal d866c00
Fix conflicts, undo pytest deps fix
agriyakhetarpal beaf970
Add emscripten platform markers back
agriyakhetarpal db06c2f
Merge branch 'main' into emscripten
agriyakhetarpal 3260af8
Exercise CI to rerun uv failure
agriyakhetarpal debe5d3
Add a space before uv dependency semicolon
agriyakhetarpal 3089427
Merge main and resolve conflicts
agriyakhetarpal File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,112 @@ | ||
| # Attributed to NumPy https://github.com/numpy/numpy/pull/25894 | ||
| # https://github.com/numpy/numpy/blob/d2d2c25fa81b47810f5cbd85ea6485eb3a3ffec3/.github/workflows/emscripten.yml | ||
|
|
||
| name: Pyodide wheel | ||
|
|
||
| on: | ||
| # TODO: refine after this is ready to merge | ||
| [push, pull_request, workflow_dispatch] | ||
|
|
||
| env: | ||
| FORCE_COLOR: 3 | ||
| PYODIDE_VERSION: 0.28.0a3 | ||
| # PYTHON_VERSION and EMSCRIPTEN_VERSION are determined by PYODIDE_VERSION. | ||
| # The appropriate versions can be found in the Pyodide repodata.json | ||
| # "info" field, or in Makefile.envs: | ||
| # https://github.com/pyodide/pyodide/blob/main/Makefile.envs#L2 | ||
| PYTHON_VERSION: 3.13 # any 3.13.x version works | ||
| EMSCRIPTEN_VERSION: 4.0.9 | ||
| NODE_VERSION: 22 | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} | ||
| cancel-in-progress: true | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| build_wasm_emscripten: | ||
| name: Build and test Zarr for Pyodide | ||
| runs-on: ubuntu-latest | ||
| # To enable this workflow on a fork, comment out: | ||
| # FIXME: uncomment after this is ready to merge | ||
| # if: github.repository == 'zarr-developers/zarr-python' | ||
| steps: | ||
| - name: Checkout Zarr repository | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 | ||
| fetch-tags: true | ||
|
|
||
| - name: Set up Python ${{ env.PYTHON_VERSION }} | ||
| id: setup-python | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: ${{ env.PYTHON_VERSION }} | ||
|
|
||
| - name: Set up Emscripten toolchain | ||
| uses: mymindstorm/setup-emsdk@v14 | ||
| with: | ||
| version: ${{ env.EMSCRIPTEN_VERSION }} | ||
| actions-cache-folder: emsdk-cache | ||
|
|
||
| - name: Set up Node.js | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: ${{ env.NODE_VERSION }} | ||
|
|
||
| - name: Install pyodide-build | ||
| run: python -m pip install pyodide-build | ||
|
|
||
| - name: Build Zarr for Pyodide | ||
| run: | | ||
| pyodide xbuildenv install ${{ env.PYODIDE_VERSION }} | ||
| pyodide build | ||
|
|
||
| ### (Temporarily) build numcodecs as well, as we have an older version in the Pyodide distribution (v0.13.1) | ||
|
|
||
| - name: Clone numcodecs repository | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| # See https://github.com/zarr-developers/numcodecs/pull/529 | ||
| repository: agriyakhetarpal/numcodecs | ||
| ref: setup-emscripten-ci | ||
| path: numcodecs-wasm | ||
| submodules: recursive | ||
| fetch-depth: 0 | ||
| fetch-tags: true | ||
|
|
||
| # For some reason fetch-depth: 0 and fetch-tags: true aren't working... | ||
| - name: Manually fetch tags for numcodecs | ||
| working-directory: numcodecs-wasm | ||
| run: git fetch --tags | ||
|
|
||
| - name: Build numcodecs for WASM | ||
| run: pyodide build | ||
| working-directory: numcodecs-wasm | ||
| env: | ||
| DISABLE_NUMCODECS_AVX2: 1 | ||
| DISABLE_NUMCODECS_SSE2: 1 | ||
|
|
||
| ### Back to Zarr repository to run tests | ||
|
|
||
| - name: Run Zarr tests for Pyodide | ||
| run: | | ||
| # Set up Pyodide virtual environment and activate it | ||
| pyodide venv .venv-pyodide | ||
| source .venv-pyodide/bin/activate | ||
|
|
||
| # Install numcodecs | ||
| pip install $(ls numcodecs-wasm/dist/*.whl)"[crc32c]" | ||
|
|
||
| # Install Zarr without dependencies until we can figure out the | ||
| # numcodecs wheel versioning issue | ||
| pip install dist/*.whl --no-deps | ||
| pip install "packaging>=22.0" "numpy>=1.25" "typing_extensions>=4.9" "donfig>=0.8" | ||
|
|
||
| # Install test dependencies | ||
| pip install "coverage" "pytest" "pytest-asyncio" "pytest-cov" "pytest-accept" "rich" "mypy" "hypothesis" | ||
|
|
||
| python -m pytest tests -v --cov=zarr --cov-config=pyproject.toml | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| Added official support for the Pyodide/WebAssembly platform for using Zarr within browser-based environments. The | ||
| `threading.max_workers` parameter takes a default value of 1, and the `zarr.sync` interface is not supported. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| # This file only exists to not incur circular import issues | ||
| # TODO: find a better location for this or keep it here | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| import platform | ||
| import sys | ||
|
|
||
| IS_WASM: bool = sys.platform == "emscripten" or platform.machine() in ["wasm32", "wasm64"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.