Skip to content
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

[WIP]: Add Pyodide support and CI jobs for Zarr #1903

Draft
wants to merge 24 commits into
base: v3
Choose a base branch
from

Conversation

agriyakhetarpal
Copy link

Description

Tip

This PR is a rework of #1902, which targeted the main branch. This one targets the v3 branch, as suggested by @jhamman.

This description is a stub and will be updated in due course.

TODO:

  • Add unit tests and/or doctests in docstrings
  • Add docstrings and API docs for any new/modified user-facing classes and functions
  • New/modified features documented in docs/tutorial.rst
  • Changes documented in docs/release.rst
  • GitHub Actions have all passed
  • Test coverage is 100% (Codecov passes)

Additional context

Here are a few xrefs to some other PRs that have been implemented for packages in the Scientific Python ecosystem:

The greater, long-term goal towards this change is to implement Sphinx-based interactive documentation via JupyterLite and WASM-powered, in-browser kernels, as referenced in Quansight-Labs/czi-scientific-python-mgmt#19, see also: Quansight-Labs/czi-scientific-python-mgmt#18. A pilot that can be readily tried out is available for the "API reference" pages under the PyWavelets documentation. This will be preceded by configuring a place to publish these WebAssembly/Emscripten wheels nightly or on a scheduled cadence for Zarr (which could be a third-party, PyPI-like index such as Anaconda.org) and then integrating Sphinx extensions such as jupyterlite-sphinx for hosted documentation.

@agriyakhetarpal
Copy link
Author

Zarr v3 has crc32c and zstandard as dependencies, which were not present for v2. These packages contain compiled code and are not available in Pyodide yet (based on the logs from the workflow run). I shall try to add recipes for them Pyodide, but I am afraid I shall not have an answer for how long that can take.

@agriyakhetarpal
Copy link
Author

Update: we added both crc32c and zstandard (please see the issues/PRs linked above). Pyodide 0.26.0 should be out very soon containing both packages plus with a bump to the Python version (to 3.12.1) and an ABI-breaking change (via Emscripten 3.1.58). I shall revisit this PR in a few days.

Next, when Zarr v3 (stable) comes out on PyPI in the next month or so, I shall bump the version/recipe for the in-tree Pyodide build as well. It would be great to have the out-of-tree build, i.e., this PR, ready for review/merging by then, and I will be committed to putting my best efforts in doing so – thanks!

@agriyakhetarpal
Copy link
Author

The Pyodide 0.26.0 release is out, and we have been lucky to have got both crc32c and zstandard in time (but in any case, they would have got into a patch release anyway). Let me update this PR in a short moment.

@agriyakhetarpal agriyakhetarpal force-pushed the emscripten branch 2 times, most recently from 4ca4aef to 9278c65 Compare May 28, 2024 16:39
@@ -18,6 +19,7 @@
from zarr.store import StorePath


@pytest.mark.skipif(IS_WASM, reason="Can't test async code in WASM")
Copy link
Member

Choose a reason for hiding this comment

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

This is going to be a problem for moving this PR forward. The entire design of V3 depends on being able to execute async. If threading and async are a show stopper, I think we should evaluate whether this can work another way.

Copy link
Author

@agriyakhetarpal agriyakhetarpal May 28, 2024

Choose a reason for hiding this comment

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

I agree, I think about half of the test suite is being skipped because of these tests under v3. Both threading and async code are probably not a priority at this time for Pyodide (perhaps @hoodmane will have more insights).

Copy link
Author

Choose a reason for hiding this comment

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

From the latest run on my fork:

14 failed, 1606 passed, 1572 skipped, 9 xfailed, 93 warnings in 104.70s (0:01:44)

Copy link
Member

Choose a reason for hiding this comment

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

I assume 99% of the passing tests are coming from the v2 test suite. I wouldn't put much weight on that. We need tests/v3 to be passing for this to work.

Copy link
Author

@agriyakhetarpal agriyakhetarpal May 28, 2024

Choose a reason for hiding this comment

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

Yes. If there is a way to run asynchronous tests in a manner that is not asynchronous, then there might be a way forward, but if Zarr's underlying functionality is going to rely on this, I am not sure if there is a solution. The first way would be to get pytest-asyncio both packaged and running under Pyodide.

Edit: the related issue is pyodide/pyodide#2221.

Choose a reason for hiding this comment

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

It is at this point possible to run async tests in Pyodide using stack switching. Just have to implement it.

Choose a reason for hiding this comment

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

Thanks for pushing this forward @agriyakhetarpal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants