Sidoineko commited on
Commit
e8c6615
·
1 Parent(s): 7c5d357

Ajout des fichiers de debug et optimisation pour Hugging Face

Browse files
Files changed (3) hide show
  1. .dockerignore +7 -8
  2. Dockerfile +7 -4
  3. app.py +30 -9
.dockerignore CHANGED
@@ -1,11 +1,10 @@
1
- __pycache__/
2
  *.pyc
3
  *.pyo
4
  *.pyd
5
- .Python
6
- env/
7
- venv/
8
- .git/
9
- .idea/
10
- .DS_Store
11
- .cache/
 
1
+ __pycache__
2
  *.pyc
3
  *.pyo
4
  *.pyd
5
+ .git
6
+ .gitignore
7
+ .vscode
8
+ .idea
9
+ *.log
10
+ .env
 
Dockerfile CHANGED
@@ -11,6 +11,12 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
11
  COPY requirements.txt .
12
  RUN pip install --no-cache-dir -r requirements.txt
13
 
 
 
 
 
 
 
14
  # Copie du code source
15
  COPY . .
16
 
@@ -19,8 +25,5 @@ ENV STREAMLIT_SERVER_PORT=8501
19
  ENV STREAMLIT_SERVER_HEADLESS=true
20
  ENV STREAMLIT_BROWSER_GATHER_USAGE_STATS=false
21
 
22
- # Se déplacer dans le dossier src
23
- WORKDIR /app/src
24
-
25
  # Commande de démarrage
26
- CMD ["streamlit", "run", "streamlit_app.py", "--server.port=8501", "--server.address=0.0.0.0"]
 
11
  COPY requirements.txt .
12
  RUN pip install --no-cache-dir -r requirements.txt
13
 
14
+ # Installation de PyTorch
15
+ RUN pip install --no-cache-dir --timeout=600 \
16
+ torch==2.0.1+cpu \
17
+ torchvision==0.15.2+cpu \
18
+ -f https://download.pytorch.org/whl/torch_stable.html
19
+
20
  # Copie du code source
21
  COPY . .
22
 
 
25
  ENV STREAMLIT_SERVER_HEADLESS=true
26
  ENV STREAMLIT_BROWSER_GATHER_USAGE_STATS=false
27
 
 
 
 
28
  # Commande de démarrage
29
+ CMD ["python", "app.py"]
app.py CHANGED
@@ -1,11 +1,32 @@
1
- from fastapi import FastAPI
2
- import uvicorn
 
3
 
4
- app = FastAPI()
 
 
 
 
 
 
5
 
6
- @app.get("/health")
7
- def health_check():
8
- return {"status": "healthy"}
9
-
10
- if __name__ == "__main__":
11
- uvicorn.run("app:app", host="0.0.0.0", port=8501)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import subprocess
2
+ import os
3
+ import sys
4
 
5
+ print("=== Démarrage du serveur Streamlit ===")
6
+ print(f"Python version: {sys.version}")
7
+ print(f"Working directory: {os.getcwd()}")
8
+ print("Contenu du répertoire courant:")
9
+ os.system("ls -la")
10
+ print("\nContenu du dossier src:")
11
+ os.system("ls -la src/")
12
 
13
+ try:
14
+ os.chdir("src")
15
+ print("\n=== Lancement de Streamlit ===")
16
+ subprocess.run([
17
+ "streamlit",
18
+ "run",
19
+ "streamlit_app.py",
20
+ "--server.port=8501",
21
+ "--server.address=0.0.0.0",
22
+ "--server.headless=true",
23
+ "--server.enableCORS=false",
24
+ "--server.enableXsrfProtection=false"
25
+ ], check=True)
26
+ except Exception as e:
27
+ print(f"Erreur: {str(e)}")
28
+ print("\n=== Stack Trace ===")
29
+ import traceback
30
+ traceback.print_exc()
31
+ # Garder le conteneur en vie pour voir les logs
32
+ input("Appuyez sur Entrée pour quitter...")