diff --git a/.github/workflows/python-api.yml b/.github/workflows/python-api.yml index 3be78f3..8c2f7ad 100644 --- a/.github/workflows/python-api.yml +++ b/.github/workflows/python-api.yml @@ -29,4 +29,4 @@ jobs: if [ -f api/requirements.txt ]; then pip install -r api/requirements.txt; fi - name: Test API with unit test run: | - python -m unittest discover -s api -t api/tests + export PYTHONPATH=api MODEL_PATH=api/tests/model.pkl && python -m unittest discover -s api/tests -t api diff --git a/api/main.py b/api/main.py index 4b67583..9130bdb 100644 --- a/api/main.py +++ b/api/main.py @@ -1,5 +1,6 @@ import json import pickle +import os from smart_open import open import pandas as pd @@ -8,7 +9,7 @@ from sample_call import test_dict th_proba = 0.54 -model_path = '/Users/audreyhohmann/Documents/Formation/OCR/P7/mlruns/274439274391636157/99fce0a77f4045eda1e8cb7e14c57ab7/artifacts/model/model.pkl' +model_path = os.getenv('MODEL_PATH', 'tests/model.pkl') with open(model_path, 'rb') as file: model = pickle.load(file) diff --git a/api/requirements.txt b/api/requirements.txt index 1d848b3..03d921a 100644 --- a/api/requirements.txt +++ b/api/requirements.txt @@ -1,2 +1,5 @@ fastapi==0.99.1 -pandas==1.5.3 \ No newline at end of file +pandas==1.5.3 +httpx==0.24.1 +smart-open==6.3.0 +lightgbm==3.3.5 \ No newline at end of file diff --git a/api/tests/model.pkl b/api/tests/model.pkl new file mode 100644 index 0000000..0295577 Binary files /dev/null and b/api/tests/model.pkl differ