Skip to content

Commit

Permalink
Merge pull request #201 from MindSetLib/dev
Browse files Browse the repository at this point in the history
Switch to poetry packaging & adding more tests
  • Loading branch information
alexmindset authored May 15, 2024
2 parents 8f9ee09 + 3c98145 commit edc423f
Show file tree
Hide file tree
Showing 20 changed files with 6,410 additions and 250 deletions.
11 changes: 6 additions & 5 deletions .github/workflows/insolver-pypi-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Install Poetry
uses: snok/install-poetry@v1
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools wheel
pip install build
shell: bash
run: poetry self add poetry-version-plugin
- name: Build a binary wheel and a source tarball
run: python -m build --sdist --wheel --outdir dist/ .
run: poetry build
- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
password: ${{ secrets.PYPI_API_TOKEN }}
14 changes: 7 additions & 7 deletions .github/workflows/insolver-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,25 +31,25 @@ jobs:
- name: Install libomp for lightgbm (macOS)
if: matrix.os == 'macos-latest'
run: brew install libomp
- name: Install Poetry
uses: snok/install-poetry@v1
- name: Install dependencies
shell: bash
run: |
python -m pip install --upgrade pip setuptools wheel
pip install wheel ruff pytest pytest-cov black[jupyter]
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
poetry install --with dev --no-interaction
- name: Lint with black
shell: bash
run: |
black . --check --line-length 120
poetry run black . --check --line-length 120
- name: Lint with ruff
shell: bash
run: |
ruff check . --select=E9,F63,F7,F82 --show-source
ruff check . --exit-zero --statistics
poetry run ruff check . --select=E9,F63,F7,F82 --show-source
poetry run ruff check . --exit-zero --statistics
- name: Test with pytest
shell: bash
run: |
python -m pytest --cov=insolver --cov-report xml
poetry run pytest --cov=insolver --cov-report xml
- name: Code coverage with codecov on (ubuntu-latest & Python 3.10 & master)
if: |
(matrix.os == 'ubuntu-latest' && matrix.python-version == '3.10' && github.ref == 'refs/heads/master')
Expand Down
7 changes: 4 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
rev: v4.5.0
hooks:
- id: check-added-large-files
args: ['--maxkb=800']
- id: check-yaml
- id: check-toml
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/psf/black
rev: 23.7.0
rev: 24.4.2
hooks:
- id: black-jupyter
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: 'v0.0.246'
rev: 'v0.4.4'
hooks:
- id: ruff
1 change: 0 additions & 1 deletion MANIFEST.in

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ python -m pytest

tests with coverage:
```shell
python -m pytest --cov=insolver; coverage html; xdg-open htmlcov/index.html
python -m pytest . --cov=insolver --cov-report html
```


Expand Down
9 changes: 0 additions & 9 deletions docs/requirements-docs.txt

This file was deleted.

2 changes: 1 addition & 1 deletion insolver/feature_engineering/feature_engineering.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def preprocess(self, df, target=None, drop_target=True):
# create a copy of the DataFrame if inplace=False
df = df.copy()

if drop_target:
if drop_target and not (self.smoothing or self.sampling or self.dim_red):
# if target is str add to lists
if isinstance(target, str):
self.normalization_drop.append(target)
Expand Down
16 changes: 8 additions & 8 deletions insolver/feature_monitoring/homogeneity_report.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import os
import inspect
import numpy as np
import pandas as pd
import plotly as py
import jinja2
from os.path import dirname
from typing import List, Sequence, Dict, Union
from plotly.figure_factory import create_distplot
from pandas import DataFrame
from plotly import express as px
from plotly.figure_factory import create_distplot
from jinja2 import Environment, FileSystemLoader

from .homogeneity_tests import ContinuousHomogeneityTests, DiscreteHomogeneityTests, fillna_cont, fillna_discr

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

def build_report(
self,
df1: pd.DataFrame,
df2: pd.DataFrame,
df1: DataFrame,
df2: DataFrame,
dropna: bool = False,
name1: str = 'Base subset',
name2: str = 'Current subset',
Expand Down Expand Up @@ -218,9 +218,9 @@ def build_report(
"""

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

# render report
env = jinja2.Environment(loader=jinja2.FileSystemLoader(curr_folder))
env = Environment(loader=FileSystemLoader(curr_folder))
template = env.get_template("report_template.html")
output = template.render(sets=report_data)

Expand Down
Loading

0 comments on commit edc423f

Please sign in to comment.