Skip to content

Commit b0ca6c6

Browse files
new logic for tests - bad and good example; hook checking nb outputs; (#61)
* create hook checking if notebook executed and without errors * add executable;move to correct dir * add main * add imports an dependencies; remove doubled code; specify exceptions * update tests; error msg * define func possible to move to utils; add todo flag * add docstrings * run check-badges only on good examples * new structure for pre-commit hooks * fix notebooks * change logic of checked files * refactor hooks using copilot * rename notebooks * add new tests for hooks * add test to run notebooks; exclude bad example * update notebooks * pylint hints; remove some unnecessary comments,; cleanup * change exceptions * change exception to ValueError * remove duplicated code * add nu_ju to executables * add check=True flag * exclude bad example from run on CI workflow * run pre-commit hook black-26.1.0 * do not fail the whole test, when error is expected * rerun example-notebooks * clear output for bad example * add test for notebooks-output * use should_fail in assertion * move relpath function to hook that uses it; fix misuse of absolute and relative paths * reuse ValueError for re-raising (pylint hint) * remove fix header option * remove header fixing at all as it is not well-designed and not essential * pass tmp path to badges check for notebooks created during tests
1 parent e99aa4d commit b0ca6c6

15 files changed

Lines changed: 799 additions & 254 deletions

.github/workflows/checks.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
pip install pre-commit
3535
pre-commit clean
3636
pre-commit autoupdate
37-
pre-commit run --all-files
37+
pre-commit run --files $(git ls-files | grep -v tests/examples/bad.ipynb)
3838
3939
selftest:
4040
needs: [pylint, precommit]

.pre-commit-config.yaml

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ default_stages: [pre-commit]
22

33
repos:
44
- repo: https://github.com/psf/black-pre-commit-mirror
5-
rev: 25.11.0
5+
rev: 26.1.0
66
hooks:
77
- id: black
88

@@ -13,10 +13,10 @@ repos:
1313
- id: end-of-file-fixer
1414
- id: debug-statements
1515

16-
- repo: https://github.com/christopher-hacker/enforce-notebook-run-order
17-
rev: 2.1.1
18-
hooks:
19-
- id: enforce-notebook-run-order
16+
# - repo: https://github.com/christopher-hacker/enforce-notebook-run-order
17+
# rev: 2.1.1
18+
# hooks:
19+
# - id: enforce-notebook-run-order
2020

2121
- repo: local
2222
hooks:
@@ -27,6 +27,7 @@ repos:
2727
- nbformat
2828
language: python
2929
types: [jupyter]
30+
exclude: tests/examples/bad.ipynb
3031

3132
- id: check-badges
3233
name: check badges
@@ -35,6 +36,24 @@ repos:
3536
- nbformat
3637
- pytest
3738
- gitpython
38-
args: [--fix-header, --repo-name=devops_tests]
39+
args: [--repo-name=devops_tests]
40+
language: python
41+
types: [jupyter]
42+
exclude: tests/examples/bad.ipynb
43+
44+
- id: notebooks-output
45+
name: notebooks output
46+
entry: notebooks_output
47+
additional_dependencies:
48+
- nbformat
3949
language: python
4050
types: [jupyter]
51+
exclude: tests/examples/bad.ipynb
52+
53+
- id: notebooks-using-jupyter-utils
54+
name: notebooks using open-atmos-jupyter-utils
55+
entry: notebooks_using_jupyter_utils
56+
additional_dependencies:
57+
- nbformat
58+
language: python
59+
types: [ jupyter ]

.pre-commit-hooks.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,19 @@
1313
language: python
1414
stages: [pre-commit]
1515
types: [jupyter]
16+
17+
- id: notebooks-output
18+
name: notebooks output
19+
description: check if notebooks are executed and without errors and warnings
20+
entry: notebooks_output
21+
language: python
22+
stages: [pre-commit]
23+
types: [jupyter]
24+
25+
- id: notebooks-using-jupyter-utils
26+
name: notebooks using open-atmos-jupyter-utils
27+
description: check if notebook use show_anim() and show_plot() methods from open-atmos-jupyter-utils
28+
entry: notebooks_using_jupyter_utils
29+
language: python
30+
stages: [pre-commit]
31+
types: [jupyter]

0 commit comments

Comments
 (0)