File tree Expand file tree Collapse file tree 5 files changed +40
-43
lines changed
Expand file tree Collapse file tree 5 files changed +40
-43
lines changed Original file line number Diff line number Diff line change 1- name : Smoke Tests for Notebooks
1+ name : Validation & Smoke Tests for Notebooks
22
33on :
44 pull_request :
@@ -105,9 +105,12 @@ jobs:
105105
106106 - name : Install Testing Tools
107107 run : |
108- pip install papermill ipykernel
108+ pip install papermill ipykernel nbstripout
109109 ipython kernel install --name "python3" --user
110110
111+ - name : Run Formatting Tests
112+ run : make format-notebooks-check
113+
111114 - name : Execute Notebooks
112115 run : |
113116 set -ux
Original file line number Diff line number Diff line change 1- name : Pre-commit checks
1+ name : Python Formatting Validation
22
33on :
4+ workflow_dispatch :
45 pull_request :
56 types : [opened, synchronize, reopened]
67 paths :
78 - " **/*.py"
8- - " **/*.ipynb"
99 - " .pre-commit-config.yaml"
10+ - " Makefile"
1011 - " pyproject.toml"
12+ - " .github/workflow/validate-python.yml"
1113 pull_request_target :
1214 types : [closed]
1315 paths :
1416 - " **/*.py"
15- - " **/*.ipynb"
1617 - " .pre-commit-config.yaml"
18+ - " Makefile"
1719 - " pyproject.toml"
18-
19- concurrency :
20- group : pre-commit-${{ github.ref }}z
21- cancel-in-progress : true
20+ - " .github/workflow/validate-python.yml"
2221
2322jobs :
24- pre-commit :
25- if : github.event_name != 'pull_request_target' || github.event.pull_request.merged == true
23+ formatting-test :
2624 runs-on : ubuntu-latest
2725 permissions :
2826 contents : read
3836 with :
3937 python-version : " 3.12"
4038
41- - name : Cache pre-commit envs
42- uses : actions/cache@v4
43- with :
44- path : ~/.cache/pre-commit
45- key : pre-commit-${{ runner.os }}-${{ hashFiles('.pre-commit-config.yaml') }}
46-
47- - name : Install pre-commit
48- run : pip install pre-commit
39+ - name : Install python formatting test dependencies
40+ run : pip install ruff
4941
50- - name : Run pre-commit
51- uses :
pre-commit/[email protected] 52- with :
53- extra_args : --all-files --show-diff-on-failure
42+ - name : Run Formatting Tests
43+ run : make format-python-check
Original file line number Diff line number Diff line change 44 - repo : https://github.com/astral-sh/ruff-pre-commit
55 rev : v0.13.0
66 hooks :
7- - id : ruff
8- name : ruff-check
9- args : [--fix, --show-fixes]
10- types_or : [python]
117 - id : ruff-format
128 name : ruff-format
139 types_or : [python]
14-
15- # Import ordering (aligned with Black)
16- - repo : https://github.com/pycqa/isort
17- rev : 6.0.1
18- hooks :
19- - id : isort
20- types_or : [python]
21-
22- # Canonical Python formatter
23- - repo : https://github.com/psf/black
24- rev : 24.8.0
25- hooks :
26- - id : black
27- types_or : [python]
28-
2910 # Strip notebook outputs anywhere in repo
3011 - repo : https://github.com/kynan/nbstripout
3112 rev : 0.8.1
@@ -39,4 +20,4 @@ exclude: |
3920 ^\.venv/|^venv/|
4021 ^\.pytest_cache/|^\.mypy_cache/|
4122 ^\.ipynb_checkpoints/
42- )
23+ )
Original file line number Diff line number Diff line change 1+ .PHONY : format-python format-notebook format-python-check format-notebooks-check
2+
3+ USE_CASES := $(wildcard notebooks/use-cases/* .ipynb)
4+ TUTORIALS := $(wildcard notebooks/tutorials/* .ipynb)
5+ ALL_NOTEBOOKS := $(USE_CASES ) $(TUTORIALS )
6+
7+ format-python :
8+ @echo " Running ruff format..."
9+ ruff format
10+
11+ format-notebooks :
12+ @echo " Running nbstripout..."
13+ nbstripout $(ALL_NOTEBOOKS )
14+
15+ format-notebooks-check : lint nbcleanup
16+ nbstripout --verify $(ALL_NOTEBOOKS )
17+ @echo " nbstripout check passed :)"
18+
19+ format-python-check : lint nbcleanup
20+ ruff format --check
21+ @echo " ruff format check passed :)"
Original file line number Diff line number Diff line change 1+ ruff
2+ nbstripout
You can’t perform that action at this time.
0 commit comments