-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b11c70e
commit 5a9f15d
Showing
21 changed files
with
440 additions
and
2,789 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
name: Construction image Docker | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
- dev | ||
tags: | ||
- 'v*.*.*' | ||
|
||
jobs: | ||
docker: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- | ||
name: Set up QEMU | ||
uses: docker/setup-qemu-action@v3 | ||
- | ||
name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- | ||
name: Docker meta | ||
id: meta | ||
uses: docker/metadata-action@v5 | ||
with: | ||
images: linogaliana/application-correction | ||
|
||
- | ||
name: Login to Docker Hub | ||
uses: docker/login-action@v3 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
- | ||
name: Build and push | ||
uses: docker/build-push-action@v5 | ||
with: | ||
push: true | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
name: Python package | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
- dev | ||
|
||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
# latest python minor | ||
python-version: '3.x' | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install -r requirements.txt | ||
pip install pylint | ||
- name: Lint | ||
run: | | ||
pylint src --fail-under=6 | ||
- name: Test Python code | ||
run: python train.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
config.yaml | ||
__pycache__/ | ||
data/**/*.csv | ||
titanic/ | ||
model.joblib |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
FROM ubuntu:22.04 | ||
WORKDIR ${HOME}/titanic | ||
# Install Python | ||
RUN apt-get -y update && \ | ||
apt-get install -y python3-pip | ||
# Install project dependencies | ||
COPY requirements.txt . | ||
RUN pip install -r requirements.txt | ||
COPY train.py . | ||
COPY src ./src | ||
COPY api ./api | ||
CMD ["bash", "-c", "./api/run.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Probabilité de survie sur le Titanic [![Construction image Docker](https://github.com/ensae-reproductibilite/application-correction/actions/workflows/prod.yaml/badge.svg)](https://github.com/ensae-reproductibilite/application-correction/actions/workflows/prod.yaml) | ||
|
||
Pour pouvoir utiliser ce projet, il | ||
est recommandé de créer un fichier `config.yaml` | ||
ayant la structure suivante: | ||
|
||
```yaml | ||
jeton_api: #### | ||
data_path: https://minio.lab.sspcloud.fr/lgaliana/ensae-reproductibilite/data/raw/data.csv | ||
``` | ||
Pour installer les dépendances | ||
```bash | ||
pip install -r requirements.txt | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
"""A simple API to expose our trained RandomForest model for Tutanic survival.""" | ||
from fastapi import FastAPI | ||
from joblib import load | ||
|
||
import pandas as pd | ||
|
||
model = load('model.joblib') | ||
|
||
app = FastAPI( | ||
title="Prédiction de survie sur le Titanic", | ||
description= | ||
"<b>Application de prédiction de survie sur le Titanic</b> 🚢 <br>Une version par API pour faciliter la réutilisation du modèle 🚀" +\ | ||
"<br><br><img src=\"https://media.vogue.fr/photos/5faac06d39c5194ff9752ec9/1:1/w_2404,h_2404,c_limit/076_CHL_126884.jpg\" width=\"200\">" | ||
) | ||
|
||
|
||
@app.get("/", tags=["Welcome"]) | ||
def show_welcome_page(): | ||
""" | ||
Show welcome page with model name and version. | ||
""" | ||
|
||
return { | ||
"Message": "API de prédiction de survie sur le Titanic", | ||
"Model_name": 'Titanic ML', | ||
"Model_version": "0.1", | ||
} | ||
|
||
|
||
@app.get("/predict", tags=["Predict"]) | ||
async def predict( | ||
sex: str = "female", | ||
age: float = 29.0, | ||
fare: float = 16.5, | ||
embarked: str = "S" | ||
) -> str: | ||
""" | ||
""" | ||
|
||
df = pd.DataFrame( | ||
{ | ||
"Sex": [sex], | ||
"Age": [age], | ||
"Fare": [fare], | ||
"Embarked": [embarked], | ||
} | ||
) | ||
|
||
prediction = "Survived 🎉" if int(model.predict(df)) == 1 else "Dead ⚰️" | ||
|
||
return prediction |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#/bin/bash | ||
python3 train.py | ||
uvicorn api.main:app --reload --host "0.0.0.0" --port 5000 |
Oops, something went wrong.