Skip to content

Commit

Permalink
Appli 18
Browse files Browse the repository at this point in the history
  • Loading branch information
linogaliana committed Mar 15, 2024
1 parent 32010ea commit d2ff21f
Show file tree
Hide file tree
Showing 17 changed files with 1,301 additions and 581 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
- main
- dev


jobs:
docker:
runs-on: ubuntu-latest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
- main
- dev


jobs:
build:

Expand Down
1 change: 1 addition & 0 deletions src/appli18/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
config.yaml
__pycache__/
data/**/*.csv
titanic/
model.joblib
4 changes: 0 additions & 4 deletions src/appli18/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
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
Expand Down
16 changes: 5 additions & 11 deletions src/appli18/README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,16 @@
# Probabilité de survie sur le Titanic [![Construction image Docker](https://github.com/ensae-reproductibilite/application-correction/actions/workflows/prod.yml/badge.svg)](https://github.com/ensae-reproductibilite/application-correction/actions/workflows/prod.yml)
# 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: ####
train_path: ####
test_path: ####
test_fraction: ####
data_path: https://minio.lab.sspcloud.fr/lgaliana/ensae-reproductibilite/data/raw/data.csv
```
## Réutilisation
Pour installer les dépendances
Pour pouvoir tester ce projet, le code suivant
suffit:
```python
```bash
pip install -r requirements.txt
python main.py
```
```
16 changes: 2 additions & 14 deletions src/appli18/api/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

app = FastAPI(
title="Prédiction de survie sur le Titanic",
description=
descriptaion=
"Application de prédiction de survie sur le Titanic 🚢 <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\">"
)
Expand All @@ -29,32 +29,20 @@ def show_welcome_page():

@app.get("/predict", tags=["Predict"])
async def predict(
pclass: int = 3,
sex: str = "female",
age: float = 29.0,
sib_sp: int = 1,
parch: int = 1,
fare: float = 16.5,
embarked: str = "S",
title: str = "Miss.",
has_cabin: int = 1,
ticket_len: int = 7
embarked: str = "S"
) -> str:
"""
"""

df = pd.DataFrame(
{
"Pclass": [pclass],
"Sex": [sex],
"Age": [age],
"SibSp": [sib_sp],
"parch": [parch],
"Fare": [fare],
"Embarked": [embarked],
"Title": [title],
"hasCabin": [has_cabin],
"Ticket_Len": [ticket_len]
}
)

Expand Down
1 change: 0 additions & 1 deletion src/appli18/api/run.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#/bin/bash

python3 train.py
uvicorn api.main:app --reload --host "0.0.0.0" --port 5000
8 changes: 7 additions & 1 deletion src/appli18/deployment/ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ metadata:
name: titanic-ingress
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /
# Enable CORS by adding these annotations
nginx.ingress.kubernetes.io/enable-cors: "true"
nginx.ingress.kubernetes.io/cors-allow-methods: "PUT, GET, POST, DELETE, PATCH, OPTIONS"
nginx.ingress.kubernetes.io/cors-allow-credentials: "true"
nginx.ingress.kubernetes.io/cors-allow-headers: "DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization"
nginx.ingress.kubernetes.io/cors-allow-origin: "*"
spec:
ingressClassName: nginx
tls:
Expand All @@ -19,4 +25,4 @@ spec:
service:
name: titanic-service
port:
number: 80
number: 80
2 changes: 1 addition & 1 deletion src/appli18/deployment/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ spec:
ports:
- protocol: TCP
port: 80
targetPort: 5000
targetPort: 5000
3 changes: 0 additions & 3 deletions src/appli18/install.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
#!/bin/bash

# Install Python
apt-get -y update
apt-get install -y python3-pip python3-venv

# Create empty virtual environment
python3 -m venv titanic
source titanic/bin/activate

# Install project dependencies
pip install -r requirements.txt
Loading

0 comments on commit d2ff21f

Please sign in to comment.