diff --git a/.github/workflows/ci_tests.yml b/.github/workflows/ci_tests.yml index db3620d..a0bcf27 100644 --- a/.github/workflows/ci_tests.yml +++ b/.github/workflows/ci_tests.yml @@ -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 diff --git a/app/app/api.py b/app/app/api.py index c802db1..2f542a4 100644 --- a/app/app/api.py +++ b/app/app/api.py @@ -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__) @@ -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"] = [] diff --git a/app/app/model.py b/app/app/model.py index f6943b6..b5476ca 100644 --- a/app/app/model.py +++ b/app/app/model.py @@ -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 diff --git a/app/server.py b/app/server.py index b170ac4..8ce09ee 100644 --- a/app/server.py +++ b/app/server.py @@ -6,8 +6,6 @@ __copyright__ = "Copyright 2018-2024" -import os - from app import create_app app = create_app() diff --git a/app/tests/test_app.py b/app/tests/test_app.py index de9926a..869df07 100644 --- a/app/tests/test_app.py +++ b/app/tests/test_app.py @@ -6,9 +6,7 @@ __copyright__ = "Copyright 2018-2024" -import pytest import json -import sys def test_index(client): response = client.get("/") @@ -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: diff --git a/requirements.txt b/requirements.txt index 3bee82a..f1b88dc 100644 --- a/requirements.txt +++ b/requirements.txt @@ -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