tabito12345678910 commited on
Commit
4478f12
·
1 Parent(s): f991fae

Fix numpy dependency: specify exact versions and install order in Dockerfile

Browse files
Files changed (3) hide show
  1. Dockerfile +5 -0
  2. app.py +4 -20
  3. requirements.txt +3 -3
Dockerfile CHANGED
@@ -11,6 +11,11 @@ RUN apt-get update && apt-get install -y \
11
 
12
  # Copy requirements first for better caching
13
  COPY requirements.txt .
 
 
 
 
 
14
  RUN pip install --no-cache-dir -r requirements.txt
15
 
16
  # Copy application code
 
11
 
12
  # Copy requirements first for better caching
13
  COPY requirements.txt .
14
+
15
+ # Install numpy and pandas first to avoid dependency conflicts
16
+ RUN pip install --no-cache-dir numpy==1.24.3 pandas==2.0.3 scipy==1.11.1
17
+
18
+ # Install the rest of the requirements
19
  RUN pip install --no-cache-dir -r requirements.txt
20
 
21
  # Copy application code
app.py CHANGED
@@ -183,28 +183,12 @@ def predict(request: PredictionRequest):
183
  detail=f"Missing required fields: {missing_en}"
184
  )
185
 
186
- # Map fields to match inference engine expectations
187
- mapped_data = {
188
- 'INDUSTRY': incoming['INDUSTRY'],
189
- 'EMPLOYEE_RANGE': incoming['EMPLOYEE_RANGE'],
190
- 'FRIDGE_RANGE': incoming['FRIDGE_RANGE'],
191
- 'PAYMENT_METHOD': incoming['PAYMENT_METHOD'],
192
- 'PREFECTURE': incoming['PREFECTURE'],
193
- 'FIRST_YEAR': incoming['FIRST_YEAR'],
194
- 'FIRST_MONTH': incoming['FIRST_MONTH'],
195
- 'LAT': incoming['LAT'],
196
- 'LONG': incoming['LONG'],
197
- 'DELIVERY_NUM': incoming['DELIVERY_NUM'],
198
- 'TOTAL_VOLUME': incoming['DELIVERY_NUM'], # Map DELIVERY_NUM to TOTAL_VOLUME
199
- 'MEDIAN_GENDER_RATIO': incoming['MEDIAN_GENDER_RATIO'],
200
- 'MODE_TOP_AGE_RANGE_1': incoming['MODE_TOP_AGE_RANGE_1'],
201
- 'MODE_TOP_AGE_RANGE_2': incoming['MODE_TOP_AGE_RANGE_2'],
202
- 'MODE_TOP_AGE_RANGE_3': incoming['MODE_TOP_AGE_RANGE_3'],
203
- 'topK': incoming.get('topK', 30)
204
- }
205
 
206
  # Predict
207
- recommendations = engine.predict(mapped_data)
208
  requested_k = int(incoming.get("topK", 30))
209
  if len(recommendations) > requested_k:
210
  recommendations = recommendations[:requested_k]
 
183
  detail=f"Missing required fields: {missing_en}"
184
  )
185
 
186
+ # Ensure TOTAL_VOLUME is present for the inference engine
187
+ if 'TOTAL_VOLUME' not in incoming and 'DELIVERY_NUM' in incoming:
188
+ incoming['TOTAL_VOLUME'] = incoming['DELIVERY_NUM']
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
189
 
190
  # Predict
191
+ recommendations = engine.predict(incoming)
192
  requested_k = int(incoming.get("topK", 30))
193
  if len(recommendations) > requested_k:
194
  recommendations = recommendations[:requested_k]
requirements.txt CHANGED
@@ -3,8 +3,8 @@ uvicorn[standard]==0.24.0
3
  pydantic==2.5.0
4
  torch==1.13.1
5
  git+https://github.com/Yura52/rtdl.git@main
6
- pandas
7
- numpy
8
- scipy
9
  python-multipart==0.0.6
10
  requests
 
3
  pydantic==2.5.0
4
  torch==1.13.1
5
  git+https://github.com/Yura52/rtdl.git@main
6
+ numpy==1.24.3
7
+ pandas==2.0.3
8
+ scipy==1.11.1
9
  python-multipart==0.0.6
10
  requests