Skip to content

Commit 014fb4d

Browse files
authored
Merge pull request #19 from datarootsio/refac
Refac
2 parents d4ad272 + 1aee73e commit 014fb4d

File tree

7 files changed

+25
-27
lines changed

7 files changed

+25
-27
lines changed

.github/workflows/test-and-train.yml

+3-5
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
runs-on: ubuntu-latest
1414
strategy:
1515
matrix:
16-
python-version: [3.7, 3.8]
16+
python-version: [3.7, 3.8, 3.9]
1717
steps:
1818
- uses: actions/checkout@v2
1919
- name: Set up Python ${{ matrix.python-version }}
@@ -22,8 +22,7 @@ jobs:
2222
python-version: ${{ matrix.python-version }}
2323
- name: Install dependencies
2424
run: |
25-
python -m pip install --upgrade pip
26-
python -m pip install -e ".[test]"
25+
make install
2726
- name: Lint with flake8 & black
2827
run: |
2928
make lint
@@ -50,8 +49,7 @@ jobs:
5049
python-version: 3.7
5150
- name: Install dependencies
5251
run: |
53-
python -m pip install --upgrade pip
54-
python -m pip install -e .
52+
make install
5553
- name: Train the model
5654
run: |
5755
make train

HOWTO.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ While the project is heavily opinionated, opinions are welcomed to be discussed:
1414
```
1515

1616
2. Install dependencies using [pip](https://pip.pypa.io/en/stable/installing/). The following command
17-
will install the dependencies from `setup.py`. Note that installing dependencies with `-e`
17+
will install the dependencies from `setup.py`. In the backend it will run `pip install -e ".[test, serve]"`. Note that installing dependencies with `-e`
1818
editable mode is needed to properly run unit tests. `[test, serve]` is optional. `test` refers to
1919
unit test dependencies and `serve` refers to deployment dependencies.
2020

2121
```bash
22-
pip install -e ".[test, serve]"
22+
make install
2323
```
2424

2525
## Running the project
@@ -49,7 +49,7 @@ Note the dependency: `generate-dataset` > `train` > `serve`.
4949
5050
## Docker
5151
52-
Currently you can find the following docker files:
52+
Currently, you can find the following docker files:
5353
1. `jupyter.Dockerfile` builds an image for running notebooks.
5454
2. `test.Dockerfile` builds an image to run all tests in (`make test-docker`).
5555
3. `serve.Dockerfile` build an image to serve the trained model via a REST api.

Makefile

+3-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ DATASET := data/transformed/creditcard.csv
1313
###############################################################
1414
# COMMANDS #
1515
###############################################################
16+
install: ## install dependencies
17+
pip install -e ".[test, serve]"
1618

1719
clean: ## clean artifacts
1820
@echo ">>> cleaning files"
@@ -32,7 +34,7 @@ serve: ## serve trained model with a REST API using dploy-kickstart
3234
@echo ">>> serving the trained model"
3335
kickstart serve -e ml_skeleton_py/model/predict.py -l .
3436

35-
run-pipeline: clean generate-dataset train serve ## clean artifacts -> generate dataset -> train -> serve
37+
run-pipeline: install clean generate-dataset train serve ## install dependencies -> clean artifacts -> generate dataset -> train -> serve
3638

3739
lint: ## flake8 linting and black code style
3840
@echo ">>> black files"

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
[![maintained by dataroots](https://img.shields.io/badge/maintained%20by-dataroots-%2300b189)](https://dataroots.io)
3-
[![PythonVersion](https://img.shields.io/badge/python-3.7%20%7C%203.8-blue)](https://img.shields.io/badge/python-3.7%20%7C%203.8-blue)
3+
[![PythonVersion](https://img.shields.io/pypi/pyversions/gino_admin)](https://img.shields.io/pypi/pyversions/gino_admin)
44
[![tests](https://github.com/datarootsio/ml-skeleton-py/workflows/tests/badge.svg?branch=master)](https://github.com/datarootsio/ml-skeleton-py/actions)
55
[![Codecov](https://codecov.io/github/datarootsio/ml-skeleton-py/badge.svg?branch=master&service=github)](https://github.com/datarootsio/ml-skeleton-py/actions)
66
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)

ml_skeleton_py/etl/generate_dataset.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def remove_outliers(df: pd.DataFrame, **kwargs: int) -> pd.DataFrame:
6868

6969
df_outlier_removed = df_outlier_removed[
7070
df_outlier_removed.is_outlier != -1
71-
] # -1 represents outliers
71+
] # -1 represents outliers
7272

7373
# Report number of removed rows
7474
n_filtered_rows = df_outlier_removed.shape[0]

ml_skeleton_py/model/train.py

+6-7
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,7 @@ def train(dataset_loc: str, model_dir: str, model_name: str = "lr") -> None:
6363

6464
auc_roc = round(training_score.mean(), 2)
6565
logger.info(f"Classifier: {pipeline.__class__.__name__}")
66-
logger.info(
67-
"Has a training score "
68-
+ f"of {auc_roc} roc_auc"
69-
)
66+
logger.info("Has a training score " + f"of {auc_roc} roc_auc")
7067
check_performance(auc_roc)
7168
# Serialize and dump trained pipeline to disk
7269
pred_result = {
@@ -83,9 +80,11 @@ def train(dataset_loc: str, model_dir: str, model_name: str = "lr") -> None:
8380

8481
def check_performance(auc_roc: float) -> None:
8582
if auc_roc < s.EXPECTED_MIN_AUC:
86-
raise Exception("The auc roc is less than the expected, "
87-
"please check your data manipulation or "
88-
"training parameters!")
83+
raise Exception(
84+
"The auc roc is less than the expected, "
85+
"please check your data manipulation or "
86+
"training parameters!"
87+
)
8988
else:
9089
# Performance is more than the expected
9190
pass

setup.py

+8-9
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,13 @@
22

33

44
test_deps = [
5-
"pytest>=5.3.5",
6-
"pytest-flask>=1.0.0",
7-
"pip>=20.0.0",
8-
"tox>=3.14.0",
9-
"flake8>=3.7.9",
10-
"flake8-annotations>=1.1.3",
11-
"pytest-cov>=2.8.1",
12-
"black>=19.10b0"
5+
"pytest>=6.2.3",
6+
"pytest-flask>=1.2.0",
7+
"pip>=21.0.1",
8+
"flake8>=3.9.2",
9+
"flake8-annotations>=2.6.2",
10+
"pytest-cov>=2.12.1",
11+
"black>=21.7b0"
1312
]
1413

1514
serve_deps = [
@@ -26,7 +25,7 @@
2625
author_email="[email protected]",
2726
description="Description of my ml-skeleton package",
2827
packages=find_packages(),
29-
install_requires=["pandas>=1.1.0", "scikit-learn>=0.23.2"],
28+
install_requires=["pandas>=1.3.2", "scikit-learn>=0.24.2"],
3029
tests_require=test_deps,
3130
extras_require=extras,
3231
)

0 commit comments

Comments
 (0)