Skip to content

Commit

Permalink
Merge pull request #203 from MindSetLib/dev
Browse files Browse the repository at this point in the history
Update workflows and tests
  • Loading branch information
alexmindset authored May 21, 2024
2 parents edc423f + f4a33c7 commit ae80eb9
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 17 deletions.
12 changes: 8 additions & 4 deletions .github/workflows/insolver-pypi-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ permissions:
jobs:
deploy:
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/insolver/
permissions:
id-token: write

steps:
- uses: actions/checkout@v4
Expand All @@ -21,11 +26,10 @@ jobs:
uses: snok/install-poetry@v1
- name: Install dependencies
shell: bash
run: poetry self add poetry-version-plugin
run: |
pip install -U pip setuptools wheel
poetry self add poetry-version-plugin
- name: Build a binary wheel and a source tarball
run: poetry build
- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
3 changes: 3 additions & 0 deletions .github/workflows/insolver-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ jobs:
- name: Install dependencies
shell: bash
run: |
pip install -U pip setuptools wheel
poetry install --with dev --no-interaction
- name: Lint with black
shell: bash
Expand All @@ -59,3 +60,5 @@ jobs:
name: codecov-insolver
fail_ci_if_error: false
files: ./coverage.xml
token: ${{ secrets.CODECOV_TOKEN }}
verbose: true
2 changes: 1 addition & 1 deletion .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ version: 2
build:
os: ubuntu-22.04
tools:
python: "3.9"
python: "3.10"

# Build documentation in the docs/ directory with Sphinx
sphinx:
Expand Down
9 changes: 9 additions & 0 deletions docs/requirements-docs.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
myst-parser
Sphinx
sphinx-rtd-theme
sphinxcontrib-applehelp
sphinxcontrib-devhelp
sphinxcontrib-htmlhelp
sphinxcontrib-jsmath
sphinxcontrib-qthelp
sphinxcontrib-serializinghtml
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ include = [
[tool.poetry.urls]
"Bug Tracker" = "https://github.com/MindSetLib/Insolver/issues"
"Documentation" = "https://insolver.readthedocs.io/en/stable/"
"Source Code" = "https://github.com/MindSetLib/Insolver"


[tool.poetry.dependencies]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ def gen_examples_cont(samp_size):

# Delete test data
os.remove('tests/data/freMPL-R.csv')
os.rmdir('tests/data')
return examples


Expand Down
1 change: 1 addition & 0 deletions tests/feature_monitoring/test_DiscreteHomogeneityTests.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ def gen_examples_discr(samp_size):

# Delete test data
os.remove('tests/data/freMPL-R.csv')
os.rmdir('tests/data')
return examples


Expand Down
20 changes: 9 additions & 11 deletions tests/test_serving_flask.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
import importlib
from io import StringIO

import h2o.exceptions
import pytest
import pandas as pd
import insolver
from insolver import InsolverDataFrame
Expand Down Expand Up @@ -94,31 +92,31 @@ def __call__(self, df):
y_train = InsTransforms.loc[InsTransforms.index.tolist()[:-1], target]
x_test = InsTransforms.loc[[InsTransforms.index.tolist()[-1]], features]

iglm = InsolverGLMWrapper(backend='h2o', family='gamma', link='log')
iglm = InsolverGLMWrapper(backend='sklearn', family='gamma', link='log')
iglm.fit(x_train, y_train)
iglm.save_model(name='test_glm_model')

predict = iglm.predict(x_test)
request_json_h2o = {'df': json.loads(test_df.iloc[0].to_json())}
request_json_sklearn = {'df': json.loads(test_df.iloc[0].to_json())}

with open("./dev/test_request_frempl.json", 'r') as file_:
request_json = json.load(file_)
# with open("./dev/test_request_frempl.json", 'r') as file_:
# request_json = json.load(file_)


@pytest.mark.xfail(raises=h2o.exceptions.H2OServerError)
def test_h2o_model():
os.environ['model_path'] = './test_glm_model.h2o'
def test_sklearn_model():
os.environ['model_path'] = './test_glm_model.pickle'
os.environ['transforms_path'] = './transforms.pickle'

from insolver.serving.flask_app import app

os.remove("test_glm_model.h2o")
os.remove("test_glm_model.pickle")
os.remove("transforms.pickle")
app.testing = True

with app.test_client() as client:
response = client.post(
'/predict',
data=json.dumps(request_json_h2o),
data=json.dumps(request_json_sklearn),
content_type='application/json',
)
data = json.loads(response.get_data(as_text=True))
Expand Down

0 comments on commit ae80eb9

Please sign in to comment.