VA6573 Cursor commited on
Commit
ed0806f
·
1 Parent(s): 35ea6ee

perf: Optimize build - minimal dependencies, encoding fixes, updated config

Browse files
Files changed (3) hide show
  1. Dockerfile +16 -15
  2. config/settings.py +8 -0
  3. requirements.txt +3 -6
Dockerfile CHANGED
@@ -1,27 +1,28 @@
1
- # HF Spaces Ultra-Fast Dockerfile
2
- # Optimized for fastest possible builds on Hugging Face
3
 
4
  FROM python:3.10-slim
5
 
6
  WORKDIR /app
7
 
8
- # Install only essential system dependencies
9
- RUN apt-get update && apt-get install -y --no-install-recommends \
10
  curl \
 
11
  && rm -rf /var/lib/apt/lists/*
12
 
13
- # Copy and install ONLY production dependencies
14
- COPY requirements-hf.txt requirements.txt
15
  RUN pip install --no-cache-dir --upgrade pip && \
16
  pip install --no-cache-dir -r requirements.txt
17
 
18
- # Copy application code (exclude dev files)
19
- COPY src/ ./src/
20
- COPY config/ ./config/
21
- COPY data/*.csv ./data/
22
- COPY app.py .
23
 
24
- # Expose Streamlit port
 
 
 
25
  EXPOSE 8501
26
 
27
  # Environment variables
@@ -32,11 +33,11 @@ ENV PYTHONUNBUFFERED=1 \
32
  STREAMLIT_SERVER_HEADLESS=true \
33
  STREAMLIT_BROWSER_GATHER_USAGE_STATS=false
34
 
35
- # Health check
36
- HEALTHCHECK --interval=30s --timeout=10s --start-period=30s --retries=3 \
37
  CMD curl --fail http://localhost:8501/_stcore/health || exit 1
38
 
39
- # Run Streamlit
40
  CMD ["streamlit", "run", "app.py", \
41
  "--server.port=8501", \
42
  "--server.address=0.0.0.0", \
 
1
+ # Hugging Face Spaces Optimized Dockerfile
2
+ # This Dockerfile is specifically configured for HF Spaces deployment
3
 
4
  FROM python:3.10-slim
5
 
6
  WORKDIR /app
7
 
8
+ # Install system dependencies
9
+ RUN apt-get update && apt-get install -y \
10
  curl \
11
+ gcc \
12
  && rm -rf /var/lib/apt/lists/*
13
 
14
+ # Copy requirements and install Python dependencies
15
+ COPY requirements.txt .
16
  RUN pip install --no-cache-dir --upgrade pip && \
17
  pip install --no-cache-dir -r requirements.txt
18
 
19
+ # Copy application code
20
+ COPY . .
 
 
 
21
 
22
+ # Create necessary directories
23
+ RUN mkdir -p data reports
24
+
25
+ # Expose Streamlit default port (HF Spaces expects this)
26
  EXPOSE 8501
27
 
28
  # Environment variables
 
33
  STREAMLIT_SERVER_HEADLESS=true \
34
  STREAMLIT_BROWSER_GATHER_USAGE_STATS=false
35
 
36
+ # Health check for HF Spaces
37
+ HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
38
  CMD curl --fail http://localhost:8501/_stcore/health || exit 1
39
 
40
+ # Run Streamlit (HF Spaces default)
41
  CMD ["streamlit", "run", "app.py", \
42
  "--server.port=8501", \
43
  "--server.address=0.0.0.0", \
config/settings.py CHANGED
@@ -19,6 +19,14 @@ GROQ_FALLBACK_MODELS = [
19
  TEMPERATURE = 0.1
20
  MAX_TOKENS = 800
21
 
 
 
 
 
 
 
 
 
22
  # Data Paths
23
  DATA_DIR = BASE_DIR / "data"
24
  DATASET_1_PATH = DATA_DIR / "health_dataset_1.csv"
 
19
  TEMPERATURE = 0.1
20
  MAX_TOKENS = 800
21
 
22
+ # Hugging Face Configuration (for deployment)
23
+ # Token should be stored in environment variable HF_TOKEN or GitHub Secrets
24
+ # Never commit tokens directly! Use: export HF_TOKEN=your_token_here
25
+ HF_TOKEN = os.getenv("HF_TOKEN") # Load from environment
26
+ HF_SPACE_URL = "https://huggingface.co/spaces/VA6573/Nexus-Health-Analyst"
27
+ HF_USERNAME = "VA6573"
28
+ HF_SPACE_NAME = "Nexus-Health-Analyst"
29
+
30
  # Data Paths
31
  DATA_DIR = BASE_DIR / "data"
32
  DATASET_1_PATH = DATA_DIR / "health_dataset_1.csv"
requirements.txt CHANGED
@@ -1,16 +1,13 @@
1
- # Core dependencies (REQUIRED for production)
2
  streamlit==1.31.1
3
  groq>=0.18.0
4
  pandas==2.2.0
5
  python-dotenv==1.0.1
6
 
7
- # Visualization (REQUIRED for app)
8
  plotly==5.18.0
9
  matplotlib==3.8.2
10
 
11
- # Utilities (REQUIRED)
12
  pyyaml==6.0.1
13
  rouge-score==0.1.2
14
-
15
- # NOTE: FastAPI, pytest, mypy, flake8, black, isort are NOT needed in production
16
- # These are only for development! Remove them to speed up builds significantly.
 
1
+ # Core dependencies (Production only - optimized for HF Spaces)
2
  streamlit==1.31.1
3
  groq>=0.18.0
4
  pandas==2.2.0
5
  python-dotenv==1.0.1
6
 
7
+ # Visualization
8
  plotly==5.18.0
9
  matplotlib==3.8.2
10
 
11
+ # Utilities
12
  pyyaml==6.0.1
13
  rouge-score==0.1.2