Zbehel commited on
Commit ·
aa8b168
1
Parent(s): ab80adf
Ajouter le serveur de suivi MLflow et l'application Streamlit
Browse files- Dockerfile +6 -2
- mlflow_app.py +5 -0
- train.py +3 -1
Dockerfile
CHANGED
|
@@ -13,7 +13,7 @@ ENV HOME=/home/user \
|
|
| 13 |
WORKDIR $HOME/app
|
| 14 |
|
| 15 |
# Install basic dependencies
|
| 16 |
-
RUN pip install boto3 pandas gunicorn mlflow streamlit scikit-learn matplotlib seaborn plotly
|
| 17 |
|
| 18 |
COPY --chown=user . $HOME/app
|
| 19 |
|
|
@@ -22,4 +22,8 @@ RUN pip install -r /dependencies/requirements.txt
|
|
| 22 |
|
| 23 |
COPY . $HOME/app
|
| 24 |
|
| 25 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
WORKDIR $HOME/app
|
| 14 |
|
| 15 |
# Install basic dependencies
|
| 16 |
+
RUN pip install boto3 pandas gunicorn mlflow streamlit scikit-learn matplotlib seaborn plotly openpyxl
|
| 17 |
|
| 18 |
COPY --chown=user . $HOME/app
|
| 19 |
|
|
|
|
| 22 |
|
| 23 |
COPY . $HOME/app
|
| 24 |
|
| 25 |
+
# Exposer les ports pour Streamlit et MLflow
|
| 26 |
+
EXPOSE 8000 5000
|
| 27 |
+
|
| 28 |
+
# Lancer Streamlit et le serveur de suivi MLflow
|
| 29 |
+
CMD ["sh", "-c", "streamlit run app.py --server.port 8000 --server.address 0.0.0.0 & python mlflow_app.py"]
|
mlflow_app.py
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import mlflow
|
| 2 |
+
import os
|
| 3 |
+
|
| 4 |
+
if __name__ == "__main__":
|
| 5 |
+
os.system("mlflow server --host 0.0.0.0 --port 5000")
|
train.py
CHANGED
|
@@ -12,6 +12,8 @@ from sklearn.compose import ColumnTransformer
|
|
| 12 |
from sklearn.linear_model import LinearRegression
|
| 13 |
from sklearn.metrics import mean_squared_error
|
| 14 |
|
|
|
|
|
|
|
| 15 |
|
| 16 |
if __name__ == "__main__":
|
| 17 |
|
|
@@ -79,7 +81,7 @@ if __name__ == "__main__":
|
|
| 79 |
run_id = run.info.run_id
|
| 80 |
with open("run_id.txt", "w") as f:
|
| 81 |
f.write(run_id)
|
| 82 |
-
|
| 83 |
print("...Done!")
|
| 84 |
print("Saving model...")
|
| 85 |
mlflow.sklearn.log_model(model, "model", signature=infer_signature(X_train, predictions))
|
|
|
|
| 12 |
from sklearn.linear_model import LinearRegression
|
| 13 |
from sklearn.metrics import mean_squared_error
|
| 14 |
|
| 15 |
+
# Définir l'URI de suivi MLflow
|
| 16 |
+
mlflow.set_tracking_uri("http://0.0.0.0:5000")
|
| 17 |
|
| 18 |
if __name__ == "__main__":
|
| 19 |
|
|
|
|
| 81 |
run_id = run.info.run_id
|
| 82 |
with open("run_id.txt", "w") as f:
|
| 83 |
f.write(run_id)
|
| 84 |
+
|
| 85 |
print("...Done!")
|
| 86 |
print("Saving model...")
|
| 87 |
mlflow.sklearn.log_model(model, "model", signature=infer_signature(X_train, predictions))
|