Skip to content

Commit

Permalink
ruff addition
Browse files Browse the repository at this point in the history
  • Loading branch information
alvertogit committed Feb 25, 2024
1 parent 4c5bfb3 commit c7ceaba
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 12 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/ci_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ jobs:
python3 -m pip install --upgrade pip
python3 -m pip install --upgrade setuptools
python3 -m pip install -r requirements.txt
- name: Lint with Ruff
run: ruff --output-format=github .
continue-on-error: true
- name: Run tests
run: |
cd app
Expand Down
8 changes: 3 additions & 5 deletions app/app/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,10 @@
__copyright__ = "Copyright 2018-2024"


import io
from flask import Blueprint, jsonify, request

from skimage.io import imread
import io

from .model import *
from .model import current_app, np, preprocess_image


api = Blueprint('api', __name__)
Expand All @@ -35,7 +33,7 @@ def predict():
# classify the input image generating a list of predictions
model = current_app.config["model"]
preds = model.predict(preprocessed_image)

# add generated predictions to result
result["predictions"] = []

Expand Down
2 changes: 1 addition & 1 deletion app/app/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def init_model():
Returns:
model: Loaded Deep Learning model.
"""

model = load_model(current_app.config["MODEL_PATH"])
model.make_predict_function()
return model
Expand Down
2 changes: 0 additions & 2 deletions app/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
__copyright__ = "Copyright 2018-2024"


import os

from app import create_app

app = create_app()
Expand Down
6 changes: 2 additions & 4 deletions app/tests/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
__copyright__ = "Copyright 2018-2024"


import pytest
import json
import sys

def test_index(client):
response = client.get("/")
Expand Down Expand Up @@ -42,8 +40,8 @@ def test_api(client):
print(json_response["most_probable_label"])
# predictions
for dic in json_response["predictions"]:
print("label {0} probability: {1}".format(dic["label"],dic["probability"]))
print(f"label {dic['label']} probability: {dic['probability']}")

assert json_response["most_probable_label"] == "4"
# failed
else:
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ numpy==1.26.4
Pillow==10.2.0
pytest==8.0.1
requests==2.31.0
ruff==0.2.2
scikit-image==0.22.0
tensorflow==2.15.0

0 comments on commit c7ceaba

Please sign in to comment.