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

Testing if the notebook runs fine with pyodide-kernel #145

Open
kp992 opened this issue Dec 1, 2024 · 1 comment
Open

Testing if the notebook runs fine with pyodide-kernel #145

kp992 opened this issue Dec 1, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@kp992
Copy link

kp992 commented Dec 1, 2024

I am trying to see if I can automate the testing of .ipynb notebooks after they are served using jupyter-lite. The problem is given a python notebook, the script should output whether the execution completed successfully or not. When I installed using

pip install jupyterlite-pyodide-kernel

I can't see the kernel in the kernel list:

% jupyter kernelspec list
Available kernels:
  python3                     /Users/kpl/mambaforge/envs/qe/share/jupyter/kernels/python3
  xpython-raw                 /Users/kpl/mambaforge/envs/qe/share/jupyter/kernels/xpython-raw

How do I test the notebooks or how do I fix the installation to see this in kernel list.

@kp992 kp992 added the bug Something isn't working label Dec 1, 2024
@agriyakhetarpal
Copy link
Member

A workaround, for now, could be in this form (if you use the Pyodide kernel):

# convert the notebook to a Python file
python -m pip install jupytext
python -m jupytext --to py your_notebook.ipynb # or py:percent if you like

# install Pyodide and activate
python -m pip install pyodide-build
pyodide xbuildenv install 0.27.0 # or your preferred Pyodide version
pyodide venv .venv-pyodide
source .venv-pyodide/bin/activate

# run the notebook as a Python file
python my_notebook.py

As a more robust solution, maybe it can be possible to run the notebook as one usually does – it would require making the Pyodide/Xeus kernels visible in the kernel list and making it possible for notebook testing tools like papermill or nbmake to connect to them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants