Skip to content

Commit

Permalink
Fix examples
Browse files Browse the repository at this point in the history
  • Loading branch information
paddyroddy committed Jan 15, 2025
1 parent 5c77056 commit 71eb842
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 3 deletions.
37 changes: 37 additions & 0 deletions examples/run.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
"""_summary_."""

import pathlib
import subprocess
import sys


def main() -> None:
"""_summary_."""
if len(sys.argv) > 1 and "html" in sys.argv[1:]:
print("Generating HTML for the example notebooks")
subprocess.run( # noqa: S603
[ # noqa: S607
"jupyter",
"nbconvert",
"--to",
"html",
"--embed-images",
"examples/**/*.ipynb",
],
check=False,
)
else:
notebooks = [str(p) for p in pathlib.Path().glob("examples/**/*.ipynb")]
subprocess.run( # noqa: S603
[ # noqa: S607
"jupyter",
"execute",
"--inplace",
*notebooks,
],
check=False,
)


if __name__ == "__main__":
main()
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ lint.per-file-ignores = {"__init__.py" = [
"D100", # undocumented-public-module
"INP001", # implicit-namespace-package,
], "examples*" = [
"INP001", # implicit-namespace-package
"PLR2004", # magic-value-comparison
"T201", # print
], "glass*" = [
Expand Down Expand Up @@ -224,9 +225,8 @@ legacy_tox_ini = """
[testenv:examples]
extras = examples
commands =
!html: jupyter execute --inplace examples/**/*.ipynb {posargs}
html: jupyter nbconvert --to html --embed-images examples/**/*.ipynb
commands = python examples/run.py {posargs}
description = Run the example notebooks. Pass "html" to build html.
[testenv:docs]
extras = docs
Expand Down

0 comments on commit 71eb842

Please sign in to comment.