-
Notifications
You must be signed in to change notification settings - Fork 1
Improve plots and fix exploratory notebook issues #596
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
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
f2148f2
Improve charts to look similar to original explore notebooks
JohT 87f679c
Fix exploratory Jupyter notebooks
JohT 3b7ed50
Add Python lib nbformat for plotly in Juypter notebooks
JohT 4d0badc
Remove setuptools dependency since opentsne is removed
JohT 047a93d
Add pipeline to quickly validate Jupyter notebooks
JohT afa6b70
Prepare release v4.0.1
JohT 77b6958
Fix broken links in README.md
JohT 9347997
Improved domains overview in documentation
JohT File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| name: Check Jupyter Notebooks | ||
|
|
||
| on: | ||
| pull_request: | ||
| branches: | ||
| - main | ||
| # Run when notebooks, Python dependencies, or this workflow change | ||
| paths: | ||
| - 'domains/**/explore/*.ipynb' | ||
| - 'pyproject.toml' | ||
| - 'uv.lock' | ||
| - 'scripts/activateUvEnvironment.sh' | ||
| - '.github/workflows/internal-check-notebooks.yml' | ||
|
|
||
| jobs: | ||
| check-notebook-syntax-and-imports: | ||
| runs-on: ubuntu-22.04 | ||
|
|
||
| steps: | ||
| - name: Checkout GIT Repository | ||
| uses: actions/checkout@v6 | ||
|
|
||
| - name: (uv Setup) Install uv | ||
| uses: astral-sh/setup-uv@v6 | ||
| with: | ||
| python-version: '3.12' | ||
|
|
||
| - name: (uv Setup) Sync dependencies from lockfile | ||
| run: uv sync --frozen | ||
|
|
||
| - name: Check notebook syntax and imports | ||
| # For each notebook: parse each Python code cell as Python AST to catch SyntaxErrors, | ||
| # then collect every unique import statement across all notebooks and run them | ||
| # in a single Python process to catch ModuleNotFoundError / ImportError. | ||
| # Cell magics (%%html, %%bash, …) and line magics (%matplotlib, …) are skipped — | ||
| # they are not Python and would cause false-positive SyntaxErrors. | ||
| # No kernel execution — no Neo4j needed, finishes in seconds. | ||
| run: | | ||
| uv run python3 - <<'PYEOF' | ||
| import ast, json, sys | ||
| from pathlib import Path | ||
|
|
||
| notebooks = sorted(Path("domains").glob("**/explore/*.ipynb")) | ||
| import_lines = set() | ||
| syntax_failures = [] | ||
|
|
||
| for notebook in notebooks: | ||
| print(f"Parsing {notebook}", flush=True) | ||
| nb = json.loads(notebook.read_text()) | ||
| for cell in nb["cells"]: | ||
| if cell["cell_type"] != "code": | ||
| continue | ||
| source = "".join(cell["source"]).strip() | ||
| if not source: | ||
| continue | ||
| # Skip cell magics (%%html, %%bash, etc.) — not Python code | ||
| if source.startswith("%%"): | ||
| continue | ||
| # Remove line magics (%matplotlib, %time, etc.) — not valid Python syntax | ||
| python_source = "\n".join(line for line in source.split("\n") if not line.lstrip().startswith("%")) | ||
| if not python_source.strip(): | ||
| continue | ||
| try: | ||
| tree = ast.parse(python_source) | ||
| except SyntaxError as e: | ||
| syntax_failures.append(f"{notebook}: SyntaxError line {e.lineno}: {e.msg}") | ||
| continue | ||
| for node in ast.walk(tree): | ||
| if isinstance(node, ast.Import): | ||
| for alias in node.names: | ||
| import_lines.add(f"import {alias.name}") | ||
| elif isinstance(node, ast.ImportFrom) and node.module: | ||
| names = ", ".join(a.name for a in node.names) | ||
| import_lines.add(f"from {node.module} import {names}") | ||
|
|
||
| if syntax_failures: | ||
| print("Syntax errors found:", file=sys.stderr) | ||
| for f in syntax_failures: | ||
| print(f" {f}", file=sys.stderr) | ||
| sys.exit(1) | ||
|
JohT marked this conversation as resolved.
|
||
|
|
||
| import_script = "\n".join(sorted(import_lines)) | ||
| print(f"\nRunning {len(import_lines)} unique import statements from {len(notebooks)} notebooks...", flush=True) | ||
| try: | ||
| exec(import_script) # noqa: S102 | ||
| except Exception as e: | ||
| print("Import check failed:", file=sys.stderr) | ||
| print(str(e), file=sys.stderr) | ||
| sys.exit(1) | ||
|
JohT marked this conversation as resolved.
|
||
|
|
||
| print(f"All {len(notebooks)} notebooks OK: syntax valid, {len(import_lines)} unique imports resolved.") | ||
| PYEOF | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.