ymlin105 commited on
Commit
332859c
·
1 Parent(s): 8647e41

debug: add environment and model hash to API response

Browse files
Files changed (1) hide show
  1. src/app.py +19 -1
src/app.py CHANGED
@@ -217,6 +217,17 @@ def predict(request: PredictionRequest):
217
  lower_bound = y_sales[0] * 0.85
218
  upper_bound = y_sales[0] * 1.15
219
 
 
 
 
 
 
 
 
 
 
 
 
220
  return PredictionResponse(
221
  Store=request.Store,
222
  Date=request.Date,
@@ -227,7 +238,14 @@ def predict(request: PredictionRequest):
227
  Status="success",
228
  DebugInfo={
229
  "y_log": float(y_log[0]),
230
- "X_row0": X.iloc[0].to_dict()
 
 
 
 
 
 
 
231
  }
232
  )
233
 
 
217
  lower_bound = y_sales[0] * 0.85
218
  upper_bound = y_sales[0] * 1.15
219
 
220
+ import hashlib
221
+ import xgboost
222
+ import sklearn
223
+ import pydantic
224
+
225
+ md5_hash = hashlib.md5()
226
+ with open(settings.MODEL_PATH, "rb") as f:
227
+ for byte_block in iter(lambda: f.read(4096), b""):
228
+ md5_hash.update(byte_block)
229
+ model_md5 = md5_hash.hexdigest()
230
+
231
  return PredictionResponse(
232
  Store=request.Store,
233
  Date=request.Date,
 
238
  Status="success",
239
  DebugInfo={
240
  "y_log": float(y_log[0]),
241
+ "X_row0": X.iloc[0].to_dict(),
242
+ "env": {
243
+ "xgboost": xgboost.__version__,
244
+ "sklearn": sklearn.__version__,
245
+ "pydantic": pydantic.__version__,
246
+ "model_md5": model_md5,
247
+ "model_path": settings.MODEL_PATH
248
+ }
249
  }
250
  )
251