Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 30 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
branches: [main, develop]
push:
branches:
- 'feature/**'
- '*'

jobs:
test-api:
Expand All @@ -15,17 +15,28 @@ jobs:
steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: "3.10"
# Installer Miniconda
- name: Installer Miniconda
run: |
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh
bash miniconda.sh -b -p $HOME/miniconda
echo "$HOME/miniconda/bin" >> $GITHUB_PATH

# Créer l'environnement Conda et installer lightfm
- name: Configurer Conda et installer lightfm
run: |
conda create -y -n lightfm_env python=3.9
conda install -y -n lightfm_env -c conda-forge lightfm numpy scipy tqdm pymysql pandas scikit-learn

- name: Installer les dépendances
# Installer les dépendances Python via pip dans l'environnement Conda
- name: Installer les dépendances Python
run: |
pip install fastapi uvicorn pymysql pandas numpy \
lightfm pytest httpx python-dotenv
conda run -n lightfm_env pip install fastapi uvicorn pymysql pandas numpy httpx==0.25.0 python-dotenv pytest haversine

# Lancer les tests dans l'environnement Conda
- name: Lancer les tests
run: pytest tests/ -v
run: |
conda run -n lightfm_env pytest tests_api/ -v
env:
MYSQL_HOST: ${{ secrets.MYSQL_HOST }}
MYSQL_USER: ${{ secrets.MYSQL_USER }}
Expand All @@ -35,8 +46,7 @@ jobs:
build-images:
name: Build Docker Images
runs-on: ubuntu-latest
needs: test-api

#needs: test-api
strategy:
matrix:
include:
Expand All @@ -52,11 +62,20 @@ jobs:

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Debug matrix
run: |
echo "SERVICE=${{ matrix.service }}"
echo "DOCKERFILE=${{ matrix.dockerfile }}"
- name: Debug repository
run: |
pwd
ls -la
find . -type f | sort

- name: Build ${{ matrix.service }}
uses: docker/build-push-action@v5
with:
context: .
dockerfile: ${{ matrix.dockerfile }}
file: ${{ matrix.dockerfile }}
push: false
tags: ${{ matrix.service }}:test
10 changes: 8 additions & 2 deletions api.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,14 @@ def connect_mysql():
with open("lightfm_model_hist.pkl", "rb") as f:
model = pickle.load(f)

with open("models/dataset.pkl", "rb") as f:
dataset = pickle.load(f)
dataset = None
try:

with open("dataset.pkl", "rb") as f:
dataset = pickle.load(f)
except :
with open("models/dataset.pkl", "rb") as f:
dataset = pickle.load(f)

print("Modèle LightFM et dataset chargés avec succès")

Expand Down
Loading