marshad180 commited on
Commit
bfa7f43
·
verified ·
1 Parent(s): 412da63

Fix: Copy sample_cases.csv to Docker image

Browse files
Files changed (2) hide show
  1. Dockerfile +1 -0
  2. app.py +19 -7
Dockerfile CHANGED
@@ -26,6 +26,7 @@ RUN pip3 install --no-cache-dir --break-system-packages gradio>=4.44.0 requests
26
  # Copy the app files
27
  COPY app.py /app/
28
  COPY julia_server.jl /app/
 
29
 
30
  # Expose Gradio port
31
  EXPOSE 7860
 
26
  # Copy the app files
27
  COPY app.py /app/
28
  COPY julia_server.jl /app/
29
+ COPY sample_cases.csv /app/
30
 
31
  # Expose Gradio port
32
  EXPOSE 7860
app.py CHANGED
@@ -86,13 +86,27 @@ SYMPTOM_LABELS = {
86
  # Sample Test Cases - Loaded from CSV
87
  # ============================================================================
88
 
89
- def load_sample_cases(csv_path="sample_cases.csv"):
90
  """Load sample test cases from CSV file for transparency and trust."""
91
  cases = []
92
 
93
- # Handle relative path
94
- if not os.path.isabs(csv_path):
95
- csv_path = os.path.join(os.path.dirname(__file__), csv_path)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
96
 
97
  try:
98
  with open(csv_path, 'r', encoding='utf-8') as f:
@@ -106,10 +120,8 @@ def load_sample_cases(csv_path="sample_cases.csv"):
106
  "confidence": f"~{row['confidence_range']}"
107
  })
108
  print(f"Loaded {len(cases)} sample cases from {csv_path}")
109
- except FileNotFoundError:
110
- print(f"Warning: {csv_path} not found, using empty cases")
111
  except Exception as e:
112
- print(f"Error loading sample cases: {e}")
113
 
114
  return cases
115
 
 
86
  # Sample Test Cases - Loaded from CSV
87
  # ============================================================================
88
 
89
+ def load_sample_cases(csv_filename="sample_cases.csv"):
90
  """Load sample test cases from CSV file for transparency and trust."""
91
  cases = []
92
 
93
+ # Try multiple paths for Docker and local environments
94
+ possible_paths = [
95
+ os.path.join("/app", csv_filename), # Docker workdir
96
+ os.path.join(os.path.dirname(os.path.abspath(__file__)), csv_filename), # Same dir as script
97
+ csv_filename, # Current working directory
98
+ os.path.join(os.getcwd(), csv_filename), # Explicit cwd
99
+ ]
100
+
101
+ csv_path = None
102
+ for path in possible_paths:
103
+ if os.path.exists(path):
104
+ csv_path = path
105
+ break
106
+
107
+ if csv_path is None:
108
+ print(f"Warning: {csv_filename} not found in any of: {possible_paths}")
109
+ return cases
110
 
111
  try:
112
  with open(csv_path, 'r', encoding='utf-8') as f:
 
120
  "confidence": f"~{row['confidence_range']}"
121
  })
122
  print(f"Loaded {len(cases)} sample cases from {csv_path}")
 
 
123
  except Exception as e:
124
+ print(f"Error loading sample cases from {csv_path}: {e}")
125
 
126
  return cases
127