Skip to content

Commit ee48cbc

Browse files
committed
added ruff lint and black format hooks
1 parent 0b47bbf commit ee48cbc

File tree

3 files changed

+85
-15
lines changed

3 files changed

+85
-15
lines changed

.githooks/pre-push.sh

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/bin/bash
2+
# .githooks/pre-push
3+
4+
# Navigate to the repository root (relative to the hook location)
5+
cd "$(dirname "$0")/.."
6+
7+
# Activate the virtual environment (if needed)
8+
VENV_PATH=$(find . -type d -name "ml_grid_env")
9+
if [ -n "$VENV_PATH" ]; then
10+
source "$VENV_PATH/bin/activate"
11+
else
12+
echo "Virtual environment not found. Exiting."
13+
exit 1
14+
fi
15+
16+
# Run Ruff linter
17+
echo "Running Ruff linter..."
18+
ruff check .
19+
if [ $? -ne 0 ]; then
20+
echo "Ruff linting failed. Please fix the issues before pushing."
21+
exit 1
22+
fi
23+
24+
# Run Black formatter check
25+
echo "Running Black formatter check..."
26+
black --check .
27+
if [ $? -ne 0 ]; then
28+
echo "Black formatting check failed. Please run 'black .' to format your code before pushing."
29+
exit 1
30+
fi
31+
32+
# Run the same test command as in the GitHub Actions workflow
33+
echo "Running tests before pushing..."
34+
pytest notebooks/test_notebook.py
35+
36+
# Check the exit status of the test command
37+
if [ $? -ne 0 ]; then
38+
echo "Tests failed. Push aborted."
39+
exit 1
40+
fi
41+
42+
echo "All checks passed. Proceeding with push."
43+
exit 0

config_hyperopt.yml

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,16 @@ data:
3131

3232
# Models to be used during the hyperopt search
3333
models:
34-
LogisticRegression_class: true
35-
knn_classifiers_class: true
36-
quadratic_discriminant_analysis_class: true
37-
SVC_class: true
38-
XGB_class_class: true
39-
mlp_classifier_class: true
40-
RandomForestClassifier_class: true
41-
GradientBoostingClassifier_class: true
42-
CatBoost_class: true
43-
GaussianNB_class: true
34+
LogisticRegressionClass: true
35+
KNeighborsClassifierClass: true
36+
QuadraticDiscriminantAnalysisClass: true
37+
SVCClass: true
38+
XGBClassifierClass: true
39+
MLPClassifierClass: true
40+
RandomForestClassifierClass: true
41+
GradientBoostingClassifierClass: true
42+
CatBoostClassifierClass: true
43+
GaussianNBClassifierClass: true
4444
H2O_class: false # H2O AutoML
4545
H2O_GBM_class: true
4646
H2O_DRF_class: true
@@ -51,10 +51,10 @@ models:
5151
H2O_XGBoost_class: true
5252
H2O_StackedEnsemble_class: false
5353
H2O_GAM_class: true
54-
LightGBMClassifierWrapper: true
55-
adaboost_class: true
56-
NeuralNetworkClassifier_class: true
57-
TabTransformer_class: false
54+
LightGBMClassifierWrapper: true # noqa
55+
AdaBoostClassifierClass: true
56+
NeuralNetworkClassifier_class: true # noqa
57+
TabTransformerClass: false
5858
# Set the following to true if a GPU is available and configured
5959
kerasClassifier_class: false
6060
knn__gpu_wrapper_class: false

pyproject.toml

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ dependencies = [
5353
[project.optional-dependencies]
5454
# Dependencies for running tests, including notebook tests
5555
test = [
56+
"black",
57+
"ruff",
5658
"pytest",
5759
"nbmake",
5860
"scikit-optimize",
@@ -96,4 +98,29 @@ docs = [
9698

9799

98100
[tool.setuptools.packages.find]
99-
include = ["ml_grid"]
101+
include = ["ml_grid"]
102+
103+
[tool.black]
104+
line-length = 88
105+
target-version = ['py310']
106+
107+
[tool.ruff]
108+
# Set the maximum line length to match Black.
109+
line-length = 88
110+
111+
# Enable the Pyflakes (F) and pycodestyle (E, W) rules by default.
112+
# I for isort for import sorting.
113+
select = ["E", "F", "W", "I"]
114+
115+
# Exclude a variety of commonly ignored directories.
116+
exclude = [
117+
".git",
118+
".ruff_cache",
119+
".venv",
120+
"__pypackages__",
121+
"build",
122+
"dist",
123+
"ml_grid_env",
124+
"ml_grid_ts_env",
125+
"venv",
126+
]

0 commit comments

Comments
 (0)