Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files- Dockerfile +19 -100
Dockerfile
CHANGED
|
@@ -1,107 +1,26 @@
|
|
| 1 |
-
|
| 2 |
-
import pandas as pd
|
| 3 |
-
import boto3
|
| 4 |
-
import folium
|
| 5 |
-
from streamlit_folium import st_folium
|
| 6 |
-
from io import StringIO
|
| 7 |
-
from babel.dates import format_datetime
|
| 8 |
-
import os
|
| 9 |
|
| 10 |
-
|
| 11 |
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
if secret not in os.environ:
|
| 16 |
-
st.error(f"⚠️ La variable d'environnement `{secret}` est manquante. "
|
| 17 |
-
"Veuillez la configurer dans les Secrets de Streamlit Cloud.")
|
| 18 |
-
st.stop()
|
| 19 |
|
| 20 |
-
|
| 21 |
-
try:
|
| 22 |
-
s3 = boto3.client(
|
| 23 |
-
"s3",
|
| 24 |
-
aws_access_key_id=os.environ["AWS_ACCESS_KEY_ID"],
|
| 25 |
-
aws_secret_access_key=os.environ["AWS_SECRET_ACCESS_KEY"],
|
| 26 |
-
region_name=os.environ.get("AWS_DEFAULT_REGION", "eu-west-3")
|
| 27 |
-
)
|
| 28 |
-
BUCKET = "certiflead"
|
| 29 |
-
except Exception as e:
|
| 30 |
-
st.error(f"❌ Erreur lors de la connexion à S3 : {e}")
|
| 31 |
-
st.stop()
|
| 32 |
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
try:
|
| 37 |
-
obj = s3.get_object(Bucket=BUCKET, Key=key)
|
| 38 |
-
data = obj["Body"].read().decode("utf-8")
|
| 39 |
-
df = pd.read_csv(StringIO(data), sep=",")
|
| 40 |
-
|
| 41 |
-
# Interpréter le timestamp comme datetime naïf (on suppose qu'il est déjà en heure locale France)
|
| 42 |
-
df["timestamp"] = pd.to_datetime(df["timestamp"], format="ISO8601")
|
| 43 |
-
|
| 44 |
-
# Créer une version formatée pour l'affichage dans les popups
|
| 45 |
-
df["timestamp_display"] = df["timestamp"].dt.strftime("%d/%m %H:%M")
|
| 46 |
-
|
| 47 |
-
return df
|
| 48 |
-
except s3.exceptions.NoSuchKey:
|
| 49 |
-
st.error(f"❌ Le fichier `{key}` est introuvable dans le bucket S3 `{BUCKET}`.")
|
| 50 |
-
st.stop()
|
| 51 |
-
except Exception as e:
|
| 52 |
-
st.error(f"❌ Erreur lors du chargement de `{key}` depuis S3 : {str(e)}")
|
| 53 |
-
st.stop()
|
| 54 |
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
df_fore = read_csv_from_s3("forecast_6h.csv")
|
| 58 |
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
"Rain": "https://cdn-icons-png.flaticon.com/128/3313/3313888.png",
|
| 64 |
-
"Fog": "https://cdn-icons-png.flaticon.com/128/1779/1779807.png",
|
| 65 |
-
}
|
| 66 |
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
location=[r.lat, r.lon],
|
| 72 |
-
popup=f"🏙️ {r.ville}<br><b>Historique :</b> {r.prediction}<br>{r.timestamp_display}",
|
| 73 |
-
icon=folium.CustomIcon(icons.get(r.prediction, icons["Clear"]), icon_size=(34, 34))
|
| 74 |
-
).add_to(m_hist)
|
| 75 |
-
|
| 76 |
-
# --- Carte Prévision 6h ---
|
| 77 |
-
m_fore = folium.Map(location=[46.6, 2.2], zoom_start=6, tiles="CartoDB Positron")
|
| 78 |
-
for _, r in df_fore.iterrows():
|
| 79 |
-
# Cercle de fond pour mise en évidence
|
| 80 |
-
folium.CircleMarker(
|
| 81 |
-
location=[r.lat, r.lon],
|
| 82 |
-
radius=10,
|
| 83 |
-
color="orange",
|
| 84 |
-
fill=True,
|
| 85 |
-
fill_opacity=0.25
|
| 86 |
-
).add_to(m_fore)
|
| 87 |
-
# Marqueur avec icône
|
| 88 |
-
folium.Marker(
|
| 89 |
-
location=[r.lat, r.lon],
|
| 90 |
-
popup=f"🏙️ {r.ville}<br><b>Prévision 6h :</b> {r.prediction}<br>{r.timestamp_display}",
|
| 91 |
-
icon=folium.CustomIcon(icons.get(r.prediction, icons["Clear"]), icon_size=(40, 40))
|
| 92 |
-
).add_to(m_fore)
|
| 93 |
-
|
| 94 |
-
# --- Titre avec la dernière date (en heure locale) ---
|
| 95 |
-
latest_ts = max(df_hist['timestamp'].max(), df_fore['timestamp'].max())
|
| 96 |
-
st.subheader(f"🗺️ Données combinées — {format_datetime(latest_ts, 'd MMMM y à HH:mm', locale='fr_FR')}")
|
| 97 |
-
|
| 98 |
-
# --- Affichage côte à côte ---
|
| 99 |
-
col1, col2 = st.columns(2)
|
| 100 |
-
|
| 101 |
-
with col1:
|
| 102 |
-
st.markdown("### 📜 Historique")
|
| 103 |
-
st_folium(m_hist, width=420, height=550)
|
| 104 |
-
|
| 105 |
-
with col2:
|
| 106 |
-
st.markdown("### 🔮 Prévision (6h)")
|
| 107 |
-
st_folium(m_fore, width=420, height=550)
|
|
|
|
| 1 |
+
FROM continuumio/miniconda3
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
|
| 3 |
+
WORKDIR /home/app
|
| 4 |
|
| 5 |
+
RUN apt-get update
|
| 6 |
+
RUN apt-get install nano unzip
|
| 7 |
+
RUN apt install curl -y
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
|
| 9 |
+
RUN curl -fsSL https://get.deta.dev/cli.sh | sh
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
+
RUN curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
|
| 12 |
+
RUN unzip awscliv2.zip
|
| 13 |
+
RUN ./aws/install
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
|
| 15 |
+
COPY requirements.txt /dependencies/requirements.txt
|
| 16 |
+
RUN pip install -r /dependencies/requirements.txt
|
|
|
|
| 17 |
|
| 18 |
+
ENV AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID
|
| 19 |
+
ENV AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY
|
| 20 |
+
ENV BACKEND_STORE_URI=$BACKEND_STORE_URI
|
| 21 |
+
ENV ARTIFACT_STORE_URI=$ARTIFACT_STORE_URI
|
|
|
|
|
|
|
|
|
|
| 22 |
|
| 23 |
+
CMD mlflow server -p $PORT \
|
| 24 |
+
--host 0.0.0.0 \
|
| 25 |
+
--backend-store-uri $BACKEND_STORE_URI \
|
| 26 |
+
--default-artifact-root $ARTIFACT_STORE_URI
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|