niivue / ipyniivue

A WebGL-powered Jupyter Widget for Niivue based on anywidget
BSD 2-Clause "Simplified" License
25 stars 8 forks source link

Testing for examples #22

Closed christian-oreilly closed 6 months ago

christian-oreilly commented 1 year ago

I have been working on documenting a bit better the Google Colab examples and adding at least one new. In doing so, it came to mind that these need to be part of the CI tests so that updates breaking these are flagged by the CI and blocked from merging. These notebooks can be automatically converted in Python script easily with:

jupyter nbconvert --to script [YOUR_NOTEBOOK].ipynb

I guess that these could be then integrated in pytest with something like (untested):

from pathlib import Path
import runpy

def test_notebooks():
    notebooks = Path([PATH_TO_NOTEBOOKS]).glob("*.ipynb")
    for notebook in notebooks:
        command = f'jupyter nbconvert --to script {notebook}`
        subprocess.call([command],shell=True)
        runpy.run_path(path_name=notebook.with_suffix(".py"))
christian-oreilly commented 1 year ago

@hanayik @AnthonyAndroulakis I am not sure who has the full rights on that repo, but if it is one of you, could bump my rights a bit? Right now I don't seem to have the right to assign a label to issues. I would have put this one as an enhancement.

hanayik commented 1 year ago

@christian-oreilly , I just sent you an invite to be a maintainer. Let me know if you have not received this (check your junk folder too).

christian-oreilly commented 1 year ago

Invite received! Thanks @hanayik