Skip to content
Open
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
5 changes: 2 additions & 3 deletions .github/workflows/notebook-qa.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,9 @@ jobs:
NBS=$(printf '%s\n' $INPUT_NOTEBOOKS)
elif [ -n "$BASE_SHA" ]; then
NBS=$(git diff --name-only --diff-filter=ACMR "$BASE_SHA" HEAD -- '*.ipynb' \
| grep -v '\.ipynb_checkpoints/' \
| sed 's|^|./|' || true)
| grep -v '\.ipynb_checkpoints/' || true)
else
NBS=$(find . -name '*.ipynb' -not -path '*/.ipynb_checkpoints/*')
NBS=$(find . -name '*.ipynb' -not -path '*/.ipynb_checkpoints/*' -printf '%P\n')
fi
if [ -z "$NBS" ]; then
echo "files=" >> "$GITHUB_OUTPUT"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ disabled_checks:

# Notebooks to skip entirely (all checks), supports glob patterns
skip_notebooks:
- "./draft.ipynb" # To skip notebooks at the top level include "./" to ensure that the path is resolved
- "draft.ipynb"
- "notebooks/draft.ipynb"
- "notebooks/experimental/**"

Expand Down
11 changes: 9 additions & 2 deletions process-notebooks/checkers/qa_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@
PYNBLINT_DEFAULT_EXCLUDE = ["missing-h1-MD-heading", "imports-beyond-first-cell"]


def _normalize_path(path: str) -> str:
"""Remove leading ./ from a path for consistent fnmatch matching."""
return path.removeprefix("./")


def load_config(config_path: str = ".github/notebook-qa.yml") -> dict[str, Any]:
"""
Load QA configuration from YAML file.
Expand Down Expand Up @@ -95,7 +100,8 @@ def is_notebook_skipped(config: dict[str, Any], notebook: str) -> bool:
True if notebook should be skipped, False otherwise
"""
skip_patterns = config.get("skip_notebooks", [])
return any(fnmatch(notebook, pattern) for pattern in skip_patterns)
notebook = _normalize_path(notebook)
return any(fnmatch(notebook, _normalize_path(pattern)) for pattern in skip_patterns)


def is_check_skipped_for_notebook(config: dict[str, Any], check_id: str, notebook: str) -> bool:
Expand All @@ -111,8 +117,9 @@ def is_check_skipped_for_notebook(config: dict[str, Any], check_id: str, noteboo
True if check should be skipped for this notebook, False otherwise
"""
per_notebook = config.get("notebooks", {})
notebook = _normalize_path(notebook)
for pattern, settings in per_notebook.items():
if fnmatch(notebook, pattern):
if fnmatch(notebook, _normalize_path(pattern)):
skip_checks = settings.get("skip", [])
if check_id in skip_checks:
return True
Expand Down
5 changes: 2 additions & 3 deletions process-notebooks/checkers/write_gha_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@

def parse_notebook_list(raw: str) -> list[str]:
"""Parse notebook list from newline-separated (or space-separated) string."""
if "\n" in raw:
return [nb.strip() for nb in raw.splitlines() if nb.strip()]
return raw.split()
nbs = [nb.strip() for nb in raw.splitlines() if nb.strip()] if "\n" in raw else raw.split()
return [nb.removeprefix("./") for nb in nbs]


def write_multiline_output(fh, key: str, lines: list[str]) -> None:
Expand Down