Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .github/workflows/check-notebooks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Check notebooks
on:
pull_request:
paths:
- 'src/tutorials/**/*.ipynb'
- 'src/how-to/**/*.ipynb'
- 'mkdocs.yaml'
- 'scripts/check_notebook_versions.py'
- '.github/workflows/check-notebooks.yml'
jobs:
check-versions:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Verify notebook DataJoint connection banners are current
run: python scripts/check_notebook_versions.py
10 changes: 5 additions & 5 deletions scripts/check_notebook_versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,22 +80,22 @@ def main() -> int:
notebooks.extend(p for p in d.rglob("*.ipynb") if ".ipynb_checkpoints" not in str(p))
notebooks.sort()

stale: list[tuple[Path, tuple[int, int, int]]] = []
stale: dict[Path, set[tuple[int, int, int]]] = {}
checked = 0
for nb in notebooks:
had_banner = False
for ver in iter_banner_versions(nb):
had_banner = True
if ver[0] != target_major or ver[1] != target_minor:
stale.append((nb.relative_to(repo), ver))
break
stale.setdefault(nb.relative_to(repo), set()).add(ver)
if had_banner:
checked += 1

if stale:
print(f"Stale DataJoint connection banner(s) (target: {target_major}.{target_minor}.x):")
for path, ver in stale:
print(f" {path}: found {ver[0]}.{ver[1]}.{ver[2]}")
for path, vers in sorted(stale.items()):
for ver in sorted(vers):
print(f" {path}: found {ver[0]}.{ver[1]}.{ver[2]}")
print(f"\nRe-execute notebooks with MODE=EXECUTE or MODE=EXECUTE_PG.")
return 1

Expand Down
22 changes: 14 additions & 8 deletions scripts/execute_notebooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,15 +174,21 @@ def main():
print(f" DJ_USER: {env.get('DJ_USER')}")

# Pre-cache scikit-image datasets so the one-time "Downloading file ..."
# message doesn't leak into committed notebook outputs.
# message doesn't leak into committed notebook outputs. Warnings go to
# stderr so a transient gitlab.com hiccup is visible in CI logs without
# silently re-introducing the download chatter on the next refresh.
print("\nPre-caching scikit-image datasets...")
import skimage.data as _sk_data
for _loader in (_sk_data.hubble_deep_field, _sk_data.human_mitosis):
try:
_loader()
print(f" cached: {_loader.__name__}")
except Exception as _e:
print(f" pre-cache warn: {_loader.__name__}: {_e}")
try:
import skimage.data as _sk_data
except ImportError as _e:
print(f" skipping pre-cache (scikit-image not installed): {_e}", file=sys.stderr)
else:
for _loader in (_sk_data.hubble_deep_field, _sk_data.human_mitosis):
try:
_loader()
print(f" cached: {_loader.__name__}")
except Exception as _e:
print(f" pre-cache warn: {_loader.__name__}: {_e}", file=sys.stderr)

# Find notebooks
notebooks = find_notebooks(args.base_path)
Expand Down
Loading