Skip to content

Commit

Permalink
gh-365: upload HTML rendering of notebooks as artifact
Browse files Browse the repository at this point in the history
  • Loading branch information
Saransh-cpp committed Nov 5, 2024
1 parent 209eb24 commit c222771
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 7 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,11 @@ jobs:
run: nox -s examples
env:
FORCE_COLOR: 1
- name: Generate HTML
run: nox -s examples -- html
env:
FORCE_COLOR: 1
- uses: actions/upload-artifact@v4
with:
name: Examples
path: examples/**/*.html
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ dist
.env
.coverage*
coverage*
examples/**/*.html
6 changes: 6 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,9 @@ repos:
- id: mypy
additional_dependencies:
- numpy
- repo: https://github.com/kynan/nbstripout
rev: 0.7.1
hooks:
- id: nbstripout
args:
- --keep-output
29 changes: 22 additions & 7 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,29 @@ def doctests(session: nox.Session) -> None:

@nox.session
def examples(session: nox.Session) -> None:
"""Run the example notebooks."""
"""Run the example notebooks. Pass "html" to build html."""
session.install("-e", ".[examples]")
session.run(
"jupyter",
"execute",
*Path().glob("examples/**/*.ipynb"),
*session.posargs,
)

if session.posargs:
if "html" in session.posargs:
print("Generating HTML for the example notebooks")
session.run(
"jupyter",
"nbconvert",
"--to",
"html",
"--embed-images",
"examples/**/*.ipynb",
)
else:
print("Unsupported argument to examples")
else:
session.run(
"jupyter",
"execute",
*Path().glob("examples/**/*.ipynb"),
*session.posargs,
)


@nox.session
Expand Down

0 comments on commit c222771

Please sign in to comment.