File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ For project contributors:
2+
3+ Feel free to use this pre-commit hooks in your local setups.
4+
5+ It does the same as the workflows that run on github:
6+ - format the files with black
7+ - linting the files with flake8
8+ - run the tests
9+
10+ Just copy the file into your ` .git/hooks/ ` directory or set it up via a ` .pre-commit-config.yaml ` file.
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ # Git pre-commit hook to run code quality checks
4+ # This hook runs black, flake8, and pytest before allowing commits
5+
6+ set -e
7+
8+ # 1. Run black with line length 79
9+ echo " Running black formatting check..."
10+ if ! black -l 79 . ; then
11+ echo " ❌ Black formatting failed. Please fix formatting issues."
12+ exit 1
13+ fi
14+ echo " ✅ Black formatting passed"
15+
16+ # 2. Run flake8 on jumper_extension directory
17+ echo " Running flake8 linting..."
18+ if ! flake8 --extend-ignore=E203 src; then
19+ echo " ❌ Flake8 linting failed. Please fix linting issues."
20+ exit 1
21+ fi
22+ echo " ✅ Flake8 linting passed"
23+
24+
25+ # 3. Run pytest with coverage
26+ echo " Running tests..."
27+ if ! python -m unittest tests.test_userpersistence; then
28+ echo " ❌ Tests failed. Please fix failing tests Maybe you need to install the recent version of ther kernel via pip install . && python -m scorepjupyter.install."
29+ exit 1
30+ fi
31+
32+ if ! python -m unittest tests.test_kernel; then
33+ echo " ❌ Tests failed. Please fix failing tests."
34+ exit 1
35+ fi
36+
37+ echo " ✅ All tests passed"
38+
39+ echo " 🎉 All pre-commit checks passed! Proceeding with commit."
Original file line number Diff line number Diff line change @@ -903,7 +903,8 @@ async def do_execute(
903903 if shutil .which ("vampir" ) is None :
904904 self .log_error (KernelErrorCode .VAMPIR_NOT_FOUND )
905905 else :
906- self .cell_output ("Vampir will be launched after next instrumented execution." )
906+ self .cell_output ("Vampir will be launched after next "
907+ "instrumented execution." )
907908 return self .standard_reply ()
908909 elif code .startswith ("%%disable_vampir_launch" ):
909910 self .launch_vampir_requested = False
Original file line number Diff line number Diff line change @@ -44,8 +44,9 @@ class KernelErrorCode(Enum):
4444 "(looked in: {scorep_folder})"
4545 ),
4646 KernelErrorCode .VAMPIR_NOT_FOUND : (
47- 'Vampir binary not found in PATH. Add it to PATH to enable automatic launch'
48- ' (e.g. in ~/.bashrc: export PATH="/path/to/vampir/bin:$PATH"'
47+ 'Vampir binary not found in PATH. Add it to PATH to enable '
48+ 'automatic launch'
49+ ' (e.g. in ~/.bashrc: export PATH="/path/to/vampir/bin:$PATH"'
4950 ),
5051
5152 KernelErrorCode .VAMPIR_LAUNCH_FAILED : (
You can’t perform that action at this time.
0 commit comments