Skip to content

Commit 830a51e

Browse files
committed
fixing pylint issues, updating github workflows
1 parent d8b82b1 commit 830a51e

26 files changed

+299
-350
lines changed

.github/workflows/deploy_on_release.yaml

-37
This file was deleted.

.github/workflows/pylint.yaml

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Pylint
2+
3+
on: [push]
4+
5+
jobs:
6+
build:
7+
runs-on: ubuntu-latest
8+
strategy:
9+
matrix:
10+
python-version: ["3.10"]
11+
steps:
12+
- uses: actions/checkout@v4
13+
- name: Set up Python ${{ matrix.python-version }}
14+
uses: actions/setup-python@v3
15+
with:
16+
python-version: ${{ matrix.python-version }}
17+
- name: Install dependencies
18+
run: |
19+
python -m pip install --upgrade pip
20+
pip install pylint
21+
- name: Analysing the code with pylint
22+
run: |
23+
pylint $(git ls-files '*.py') --rcfile=.pylintrc

.github/workflows/test_on_push.yaml

+7-7
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,22 @@ jobs:
77
runs-on: ubuntu-latest
88
strategy:
99
matrix:
10-
python-version: [3.10]
10+
python-version: ["3.10"]
1111

1212
steps:
13-
- uses: actions/checkout@v2
13+
- uses: actions/checkout@v3
1414
- name: Set up Python ${{ matrix.python-version }}
15-
uses: actions/setup-python@v2
15+
uses: actions/setup-python@v4
1616
with:
1717
python-version: ${{ matrix.python-version }}
1818
- name: Install dependencies
1919
run: |
2020
python -m pip install --upgrade pip
21-
pip install pytest black
2221
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
23-
- name: Test with pytest
24-
run: |
25-
pytest
2622
- name: Python Black
2723
run: |
24+
pip install black==24.10.0
2825
black . --check
26+
- name: Test with pytest
27+
run: |
28+
pytest --cov-report html:./results/cov_html --cov=src tests/

.github/workflows/train_evaluate.yaml

-35
This file was deleted.

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,4 @@ coverage.xml
6262
docs/_build/
6363

6464
# PyBuilder
65-
target/
65+
target/

.pylintrc

+8-9
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ analyse-fallback-blocks=no
77

88
# Clear in-memory caches upon conclusion of linting. Useful if running pylint
99
# in a server-like mode.
10-
clear-cache-post-run=no
10+
# clear-cache-post-run=no
1111

1212
# Load and enable all available extensions. Use --list-extensions to see a list
1313
# all available extensions.
@@ -89,7 +89,7 @@ persistent=yes
8989

9090
# Resolve imports to .pyi stubs if available. May reduce no-member messages and
9191
# increase not-an-iterable messages.
92-
prefer-stubs=no
92+
# prefer-stubs=no
9393

9494
# Minimum Python version to use for version dependent checks. Will default to
9595
# the version used to run pylint.
@@ -102,7 +102,7 @@ recursive=no
102102
# source root is an absolute path or a path relative to the current working
103103
# directory used to determine a package namespace for modules located under the
104104
# source root.
105-
source-roots=
105+
# source-roots=
106106

107107
# When enabled, pylint would attempt to guess common misconfiguration and emit
108108
# user-friendly hints instead of false-positive error messages.
@@ -363,7 +363,7 @@ single-line-if-stmt=no
363363
allow-any-import-level=
364364

365365
# Allow explicit reexports by alias from a package __init__.
366-
allow-reexport-from-package=no
366+
# allow-reexport-from-package=no
367367

368368
# Allow wildcard imports from modules that define __all__.
369369
allow-wildcard-with-all=no
@@ -433,9 +433,8 @@ disable=raw-checker-failed,
433433
suppressed-message,
434434
useless-suppression,
435435
deprecated-pragma,
436-
use-implicit-booleaness-not-comparison-to-string,
437-
use-implicit-booleaness-not-comparison-to-zero,
438-
use-symbolic-message-instead
436+
use-symbolic-message-instead,
437+
duplicate-code
439438

440439
# Enable the message, report, category or checker with the given id(s). You can
441440
# either give multiple identifier separated by comma (,) or put this option
@@ -448,7 +447,7 @@ enable=
448447

449448
# List of qualified names (i.e., library.method) which require a timeout
450449
# parameter e.g. 'requests.api.get,requests.api.post'
451-
timeout-methods=requests.api.delete,requests.api.get,requests.api.head,requests.api.options,requests.api.patch,requests.api.post,requests.api.put,requests.api.request
450+
# timeout-methods=requests.api.delete,requests.api.get,requests.api.head,requests.api.options,requests.api.patch,requests.api.post,requests.api.put,requests.api.request
452451

453452

454453
[MISCELLANEOUS]
@@ -476,7 +475,7 @@ never-returning-functions=sys.exit,argparse.parse_error
476475
# Let 'consider-using-join' be raised when the separator to join on would be
477476
# non-empty (resulting in expected fixes of the type: ``"- " + " -
478477
# ".join(items)``)
479-
suggest-join-with-non-empty-separator=yes
478+
# suggest-join-with-non-empty-separator=yes
480479

481480

482481
[REPORTS]

__init__.py

Whitespace-only changes.

docker-compose.yaml

+4-4
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ services:
1818
# exposing the port that will be used by MLFlow and Jupyter Notebook
1919
ports:
2020
- "8888:8888"
21-
21+
2222
# setting external volumes
2323
volumes:
2424
- ./credentials.yaml:/e2e-project/credentials.yaml
2525
- ./models:/e2e-project/models/
2626
- ./data:/e2e-project/data/
27-
27+
2828
dev-mlflow:
2929
image: e2e-dev:latest
3030
build:
@@ -39,9 +39,9 @@ services:
3939
# exposing the port that will be used by MLFlow and Jupyter Notebook
4040
ports:
4141
- "5000:5000"
42-
42+
4343
# setting external volumes
4444
volumes:
4545
- ./credentials.yaml:/e2e-project/credentials.yaml
4646
- ./models:/e2e-project/models/
47-
- ./data:/e2e-project/data/
47+
- ./data:/e2e-project/data/

requirements.txt

+8-7
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
boto3==1.35.6
1+
boto3==1.24.28
22
fastapi==0.115.5
33
joblib==1.3.2
44
loguru==0.7.2
5-
mlflow==2.17.2
6-
numpy==2.1.3
7-
pandas==1.5.2
5+
mlflow==2.15.1
6+
numpy==1.21.5
7+
pandas==1.4.4
88
pydantic==2.9.2
9-
pytest==8.3.3
10-
PyYAML==6.0.2
9+
pytest==7.2.2
10+
pytest-cov==6.0.0
11+
PyYAML==6.0
1112
scikit_learn==1.3.2
12-
xgboost==2.1.2
13+
xgboost==2.1.2

src/api.py

+28-7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
"""
2+
API's main file.
3+
"""
4+
from typing import Dict
5+
16
import pandas as pd
27
import mlflow
38
from fastapi import FastAPI
@@ -14,15 +19,21 @@
1419
if aws_credentials.EC2 != "YOUR_EC2_INSTANCE_URL":
1520
mlflow.set_tracking_uri(f"http://{aws_credentials.EC2}:5000")
1621
else:
17-
mlflow.set_tracking_uri(f"http://127.0.0.1:5000")
22+
mlflow.set_tracking_uri("http://127.0.0.1:5000")
1823

1924

2025
@app.get("/version")
21-
def check_versions():
26+
def check_versions() -> Dict:
27+
"""
28+
This endpoint will return the current model and code versions.
29+
30+
Returns:
31+
Dict: the model and code versions.
32+
"""
2233
with open(
2334
f"{general_settings.RESEARCH_ENVIRONMENT_PATH}/VERSION", "r", encoding="utf-8"
24-
) as f:
25-
code_version = f.readline().strip()
35+
) as file:
36+
code_version = file.readline().strip()
2637

2738
return {
2839
"code_version": code_version,
@@ -31,7 +42,17 @@ def check_versions():
3142

3243

3344
@app.get("/predict")
34-
async def prediction(person: Person):
45+
async def prediction(person: Person) -> Dict:
46+
"""
47+
This endpoint is used to make a prediction (with the trained model)
48+
with the given data.
49+
50+
Args:
51+
person (Person): a person's data.
52+
53+
Returns:
54+
Dict: the predictions.
55+
"""
3556
loaded_model = ModelServe(
3657
model_name=model_settings.MODEL_NAME,
3758
model_flavor=model_settings.MODEL_FLAVOR,
@@ -40,6 +61,6 @@ async def prediction(person: Person):
4061
loaded_model.load()
4162

4263
data = pd.DataFrame.from_dict([person.model_dump()])
43-
X = data_processing_inference(data)
64+
features = data_processing_inference(data)
4465

45-
return {"predictions": loaded_model.predict(X).tolist()}
66+
return {"predictions": loaded_model.predict(features).tolist()}

src/config/aws.py

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
"""
2+
Creates a Pydantic's base model for the AWS' credentials.
3+
"""
14
from pathlib import Path
25

36
from pydantic import BaseModel

src/config/kaggle.py

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
"""
2+
Creates a Pydantic's base model for the Kaggle's credentials.
3+
"""
14
from pathlib import Path
25
from pydantic import BaseModel
36

src/config/model.py

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
"""
2+
Creates a Pydantic's base model for the model's configuration.
3+
"""
14
from typing import List
25

36
from pathlib import Path

src/config/settings.py

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
"""
2+
Creates a Pydantic's base model for the general configuration settings.
3+
"""
14
import os
25
from pathlib import Path
36

0 commit comments

Comments
 (0)