Skip to content

Commit edc423f

Browse files
authored
Merge pull request #201 from MindSetLib/dev
Switch to poetry packaging & adding more tests
2 parents 8f9ee09 + 3c98145 commit edc423f

20 files changed

Lines changed: 6410 additions & 250 deletions

.github/workflows/insolver-pypi-release.yaml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,15 @@ jobs:
1717
uses: actions/setup-python@v5
1818
with:
1919
python-version: "3.10"
20+
- name: Install Poetry
21+
uses: snok/install-poetry@v1
2022
- name: Install dependencies
21-
run: |
22-
python -m pip install --upgrade pip setuptools wheel
23-
pip install build
23+
shell: bash
24+
run: poetry self add poetry-version-plugin
2425
- name: Build a binary wheel and a source tarball
25-
run: python -m build --sdist --wheel --outdir dist/ .
26+
run: poetry build
2627
- name: Publish package to PyPI
2728
uses: pypa/gh-action-pypi-publish@release/v1
2829
with:
2930
user: __token__
30-
password: ${{ secrets.PYPI_API_TOKEN }}
31+
password: ${{ secrets.PYPI_API_TOKEN }}

.github/workflows/insolver-tests.yaml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,25 +31,25 @@ jobs:
3131
- name: Install libomp for lightgbm (macOS)
3232
if: matrix.os == 'macos-latest'
3333
run: brew install libomp
34+
- name: Install Poetry
35+
uses: snok/install-poetry@v1
3436
- name: Install dependencies
3537
shell: bash
3638
run: |
37-
python -m pip install --upgrade pip setuptools wheel
38-
pip install wheel ruff pytest pytest-cov black[jupyter]
39-
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
39+
poetry install --with dev --no-interaction
4040
- name: Lint with black
4141
shell: bash
4242
run: |
43-
black . --check --line-length 120
43+
poetry run black . --check --line-length 120
4444
- name: Lint with ruff
4545
shell: bash
4646
run: |
47-
ruff check . --select=E9,F63,F7,F82 --show-source
48-
ruff check . --exit-zero --statistics
47+
poetry run ruff check . --select=E9,F63,F7,F82 --show-source
48+
poetry run ruff check . --exit-zero --statistics
4949
- name: Test with pytest
5050
shell: bash
5151
run: |
52-
python -m pytest --cov=insolver --cov-report xml
52+
poetry run pytest --cov=insolver --cov-report xml
5353
- name: Code coverage with codecov on (ubuntu-latest & Python 3.10 & master)
5454
if: |
5555
(matrix.os == 'ubuntu-latest' && matrix.python-version == '3.10' && github.ref == 'refs/heads/master')

.pre-commit-config.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
repos:
22
- repo: https://github.com/pre-commit/pre-commit-hooks
3-
rev: v4.3.0
3+
rev: v4.5.0
44
hooks:
55
- id: check-added-large-files
6+
args: ['--maxkb=800']
67
- id: check-yaml
78
- id: check-toml
89
- id: end-of-file-fixer
910
- id: trailing-whitespace
1011
- repo: https://github.com/psf/black
11-
rev: 23.7.0
12+
rev: 24.4.2
1213
hooks:
1314
- id: black-jupyter
1415
- repo: https://github.com/charliermarsh/ruff-pre-commit
15-
rev: 'v0.0.246'
16+
rev: 'v0.4.4'
1617
hooks:
1718
- id: ruff

MANIFEST.in

Lines changed: 0 additions & 1 deletion
This file was deleted.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ python -m pytest
6868

6969
tests with coverage:
7070
```shell
71-
python -m pytest --cov=insolver; coverage html; xdg-open htmlcov/index.html
71+
python -m pytest . --cov=insolver --cov-report html
7272
```
7373

7474

docs/requirements-docs.txt

Lines changed: 0 additions & 9 deletions
This file was deleted.

insolver/feature_engineering/feature_engineering.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ def preprocess(self, df, target=None, drop_target=True):
132132
# create a copy of the DataFrame if inplace=False
133133
df = df.copy()
134134

135-
if drop_target:
135+
if drop_target and not (self.smoothing or self.sampling or self.dim_red):
136136
# if target is str add to lists
137137
if isinstance(target, str):
138138
self.normalization_drop.append(target)

insolver/feature_monitoring/homogeneity_report.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import os
22
import inspect
33
import numpy as np
4-
import pandas as pd
54
import plotly as py
6-
import jinja2
75
from os.path import dirname
86
from typing import List, Sequence, Dict, Union
9-
from plotly.figure_factory import create_distplot
7+
from pandas import DataFrame
108
from plotly import express as px
9+
from plotly.figure_factory import create_distplot
10+
from jinja2 import Environment, FileSystemLoader
1111

1212
from .homogeneity_tests import ContinuousHomogeneityTests, DiscreteHomogeneityTests, fillna_cont, fillna_discr
1313

@@ -176,8 +176,8 @@ def config_dict(self, config_dict_inp: Dict) -> None:
176176

177177
def build_report(
178178
self,
179-
df1: pd.DataFrame,
180-
df2: pd.DataFrame,
179+
df1: DataFrame,
180+
df2: DataFrame,
181181
dropna: bool = False,
182182
name1: str = 'Base subset',
183183
name2: str = 'Current subset',
@@ -218,9 +218,9 @@ def build_report(
218218
"""
219219

220220
# checking error situations
221-
if not isinstance(df1, pd.DataFrame):
221+
if not isinstance(df1, DataFrame):
222222
raise TypeError("df1 must be a pandas DataFrame.")
223-
if not isinstance(df2, pd.DataFrame):
223+
if not isinstance(df2, DataFrame):
224224
raise TypeError("df2 must be a pandas DataFrame.")
225225
features = self.features
226226
if not (set(features) <= set(df1.columns)):
@@ -368,7 +368,7 @@ def render_report(report_data: list, report_path: str = 'homogeneity_report.html
368368
raise KeyError("Missing information in nan gap dict.")
369369

370370
# render report
371-
env = jinja2.Environment(loader=jinja2.FileSystemLoader(curr_folder))
371+
env = Environment(loader=FileSystemLoader(curr_folder))
372372
template = env.get_template("report_template.html")
373373
output = template.render(sets=report_data)
374374

0 commit comments

Comments
 (0)