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
Add out-of-tree Pyodide builds in CI for scikit-image
#7350
base: main
Are you sure you want to change the base?
Add out-of-tree Pyodide builds in CI for scikit-image
#7350
Conversation
Initial inspiration was taken from numpy/numpy#24603.
Locally, this version seems to successfully create a wheel when running "pyodide build" opposed to using "python -m build ...".
Based on numpy/numpy#25894. This comment updates versions for Pyodide, Emscripten, and improves some names for job steps. Multiple reusable actions have also been updated in accordance with the latest versions available. Co-Authored-By: Lars Grüter <20140352+lagru@users.noreply.github.com>
This commit loads and re-saves all of the `.npy` files to `.npz` NumPy compressed file format and saves them to the 'data' field in the Npz objects. The test cases where they have been used have been updated to use this attribute, and the SHA-256 checksums in the registry for each of the files have been updated in accordance with this change.
For context: a lot of the Some of the changes will make the tests with additional data being downloaded fail with |
Some progress: adding a JS script to run the |
ac6d92d
to
12f0bd4
Compare
970d0a3
to
da1c1ed
Compare
More progress: I have finally got a green check (🎉) for the Emscripten job by skipping and fixing tests as necessary: https://github.com/scikit-image/scikit-image/actions/runs/8348607683/job/22850925405?pr=7350. I will now proceed to clean up this PR and fix the rest of the tests. It might require fixing the |
Try setting Agg backend for Matplotlib testing Don't mark Matplotlib tests, correct set backend
da1c1ed
to
00fefee
Compare
00fefee
to
24598b7
Compare
Looks like all tests are now passing! This is ready for review now, @lagru and @rgommers. I am happy to rewrite history here if needed, or have this be squash-merged – either way works for me. As soon as this is merged, I can follow up with a PR that publishes these wheels weekly (based on the current cadence) to the Anaconda.org repository or any other PyPI-like indices1. Doing that should be much more trivial in comparison to this PR :) I can also add a corresponding job in the Note: the commit 0dc7431 that performed the Footnotes
|
scikit-image
scikit-image
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some comments to facilitate an easier review, below:
from matplotlib import use | ||
|
||
use('Agg') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even with the MPLBACKEND
environment variable set inside the workflow, it didn't work and the tests for Matplotlib were failing – I would suggest keeping this change here (and in other places).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I won't have as much context as @lagru here, but for what it's worth: in SciPy we set the backend to Agg for testing, and it's my understanding that that in general is a robust strategy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't really follow why use('Agg')
fixes things and MPLBACKEND="Agg"
doesn't. E.g. for be525a4, pytest's error log already indicates that Agg
is used.
This is before you try to use Agg programmatically
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand it enough either (perhaps Node.js is not properly letting environment variables pass to the Python interpreter). But sure, let me try to revert this change in a separate commit, again, at the end of addressing the review and we can see if things break in an isolated state. Either way, keeping just one of these options would be better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have done a bit of reading about this as someone who does not have much JavaScript experience, and I think what is happening here is that Pyodide runs Python code within the browser environment (or in a different environment if a browser is not present), isolated from the Node.js process that spawns the Pyodide interpreter – therefore, it doesn't directly inherit environment variables from Node.js.
It could be tricky to debug further but I'm happy to do so, so I'll remove the MPLBACKEND
environment variable from the workflow file for now, given that the programmatic approach with matplotlib.use
will be beneficial for not only these Pyodide-specific tests, but for the general test suite on regular supported platforms too. Edit: removed in 174f3e7.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks quite good to me. The CI job config looks good, as do the logs. Applying the needed patch for .npy
files is a good approach.
The changes to test files all seem reasonable; the import threading
one is the only one that may require a change, but you already commented on that so the maintainers can decide on that one.
from matplotlib import use | ||
|
||
use('Agg') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I won't have as much context as @lagru here, but for what it's worth: in SciPy we set the backend to Agg for testing, and it's my understanding that that in general is a robust strategy.
See pyodide/pyodide#4654 for discussion. This commit resolves a build error due to a release of `build` (v1.2.0) which had broken the `pyodide build` command for all repositories.
Pyodide had a recent patch release to fix failures on the |
Sorry for not keeping up with this @agriyakhetarpal. 🙏 I plan to review this by the weekend. |
Thanks, @lagru! No worries at all. I was merging |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @agriyakhetarpal! I'm impressed by the workarounds you figured out by yourself without knowing our library intimately. :D
from matplotlib import use | ||
|
||
use('Agg') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't really follow why use('Agg')
fixes things and MPLBACKEND="Agg"
doesn't. E.g. for be525a4, pytest's error log already indicates that Agg
is used.
This is before you try to use Agg programmatically
Description
This pull request is meant to supersede #7265 based on @lagru's suggestion, and it adds a CI job to build and test
scikit-image
in a Pyodide virtual environment through WASM wheels. Following this, it would be possible to include JupyterLite notebooks in the documentation in order to runscikit-image
's code snippets which come with docstring-based examples.It is to be highlighted that this was completed last month for NumPy: (numpy/numpy#25894) and for PyWavelets – an optional dependency for
scikit-image
: (PyWavelets/pywt#701), all thanks to @rgommers for the help.I was working on this last month, and I have rebased my branch to account for the latest changes upstream.
cc @stefanv from discussions on the previous PR.
Checklist
./doc/examples
for new featuresRelease note
We use changelist to
compile each pull request into an item of the release notes. Please refer to
the instructions
and past release notes
for guidance and examples.