Skip to content

Commit

Permalink
Add ruff-format and support for python 3.12
Browse files Browse the repository at this point in the history
  • Loading branch information
pavelzw committed Oct 25, 2023
1 parent 8060c73 commit f4475a5
Show file tree
Hide file tree
Showing 17 changed files with 13,128 additions and 105 deletions.
14 changes: 8 additions & 6 deletions .github/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,22 @@ changelog:
exclude:
labels:
- ignore for release
- ci
categories:
- title: New features
- title: New features
labels:
- enhancement
- title: Bug fixes
- title: 🐛 Bug fixes
labels:
- bug
- title: Documentation
- title: 📝 Documentation
labels:
- documentation
- title: Dependencies
- title: ⬆️ Dependencies
labels:
- dependencies
- title: Other changes
- title: 🚀 CI
labels:
- ci
- title: 🤷🏻 Other changes
labels:
- '*'
7 changes: 3 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ jobs:
- { PYTHON_VERSION: '3.9', SKLEARN_VERSION: '', LGBM_VERSION: '' }
- { PYTHON_VERSION: '3.10', SKLEARN_VERSION: '', LGBM_VERSION: '' }
- { PYTHON_VERSION: '3.11', SKLEARN_VERSION: '', LGBM_VERSION: '' }
- { PYTHON_VERSION: '3.12', SKLEARN_VERSION: '', LGBM_VERSION: '' }
steps:
- uses: actions/checkout@v4
- name: Set up conda env
Expand All @@ -56,13 +57,11 @@ jobs:
${{ matrix.SKLEARN_VERSION }}${{ matrix.LGBM_VERSION }}
linux-unittests-pixi:
name: "Unit tests Pixi - Python ${{ matrix.PYTHON_VERSION }}"
name: Unit tests Pixi
timeout-minutes: 15
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
PYTHON_VERSION: ['3.11']
steps:
- uses: actions/checkout@v4
- uses: prefix-dev/[email protected]
Expand All @@ -73,7 +72,7 @@ jobs:
uses: pavelzw/pytest-action@v2
with:
custom-pytest: pixi run test
report-title: "Unit tests Linux Pixi - Python ${{ matrix.PYTHON_VERSION }}"
report-title: Unit tests Linux Pixi

pre-commit: # todo switch to pre-commit.ci
name: "Pre-commit checks"
Expand Down
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -121,5 +121,3 @@ mlruns

# pixi
.pixi
# this is a library so we don't include pixi.lock
pixi.lock
10 changes: 2 additions & 8 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,10 @@ repos:
- id: trailing-whitespace
- id: check-toml
- repo: https://github.com/quantco/pre-commit-mirrors-ruff
rev: 0.0.291
rev: 0.1.2
hooks:
- id: ruff-conda
- repo: https://github.com/quantco/pre-commit-mirrors-black
rev: 23.9.1
hooks:
- id: black-conda
args:
- --safe
- --target-version=py38
- id: ruff-format-conda
- repo: https://github.com/quantco/pre-commit-mirrors-mypy
rev: 1.5.1
hooks:
Expand Down
8 changes: 2 additions & 6 deletions benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,12 @@ def train_sklearn_rf_1g() -> RandomForestRegressor:
def train_sklearn_gb_2m() -> GradientBoostingRegressor:
return load_model(
"sklearn_gb_2m",
lambda: GradientBoostingRegressor(
n_estimators=2000, random_state=42, verbose=True
),
lambda: GradientBoostingRegressor(n_estimators=2000, random_state=42, verbose=True),
)


def train_lgbm_gbdt_2m() -> lgb.LGBMRegressor:
return load_model(
"lgbm_gbdt_2m", lambda: lgb.LGBMRegressor(n_estimators=1000, random_state=42)
)
return load_model("lgbm_gbdt_2m", lambda: lgb.LGBMRegressor(n_estimators=1000, random_state=42))


def train_lgbm_gbdt_5m() -> lgb.LGBMRegressor:
Expand Down
4 changes: 1 addition & 3 deletions examples/pickle_lgbm.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,5 @@ def dump_model_string(booster: Booster, path: Union[str, pathlib.Path]):
dump_model_string(model.booster_, "examples/out/model_uncompressed.model")
dump_model_string(model_compressed.booster_, "examples/out/model_compressed.model")

evaluate_prediction_difference(
model, model_compressed, generate_dataset(n_samples=10000)[0]
)
evaluate_prediction_difference(model, model_compressed, generate_dataset(n_samples=10000)[0])
evaluate_compression_performance(model, dump)
4 changes: 1 addition & 3 deletions examples/pickle_sklearn.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,5 @@ def train_model() -> RandomForestRegressor:
dump_sklearn_compressed(model, path, "no")
model_compressed = load_compressed(path, "no")

evaluate_prediction_difference(
model, model_compressed, generate_dataset(n_samples=10000)[0]
)
evaluate_prediction_difference(model, model_compressed, generate_dataset(n_samples=10000)[0])
evaluate_compression_performance(model, dump)
4 changes: 1 addition & 3 deletions examples/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,7 @@ def generate_dataset_train_test(
return train_test_split(X, y, test_size=0.2, random_state=42)


def evaluate_compression_performance(
model: Any, dump: Callable, print_performance: bool = True
):
def evaluate_compression_performance(model: Any, dump: Callable, print_performance: bool = True):
compressions = ["no", "lzma", "bz2", "gzip"]
performance = []
for compression, dump_function in product(compressions, [None, dump]):
Expand Down
Loading

0 comments on commit f4475a5

Please sign in to comment.