hchevva commited on
Commit
2f89db1
·
verified ·
1 Parent(s): 630d650

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -1
app.py CHANGED
@@ -866,6 +866,16 @@ def _is_empty_value(v: Any) -> bool:
866
  return s.lower() in EMPTY_STRINGS
867
 
868
 
 
 
 
 
 
 
 
 
 
 
869
  def _record_id(file_name: str, chemical: str, endpoint: str) -> str:
870
  chemical = (chemical or "").strip() or "-"
871
  endpoint = (endpoint or "").strip() or "Paper"
@@ -1251,7 +1261,7 @@ def run_extraction(
1251
  "risk_calculation_refs": [],
1252
  },
1253
  }
1254
- json_path.write_text(json.dumps(details_payload, indent=2), encoding="utf-8")
1255
  prefilled_template_path = export_prefilled_cancer_risk_template(records)
1256
 
1257
  choices = [r.get("record_id") for r in records if r.get("record_id")]
 
866
  return s.lower() in EMPTY_STRINGS
867
 
868
 
869
+ def _json_default(o: Any):
870
+ if isinstance(o, np.integer):
871
+ return int(o)
872
+ if isinstance(o, np.floating):
873
+ return float(o)
874
+ if isinstance(o, np.ndarray):
875
+ return o.tolist()
876
+ raise TypeError(f"Object of type {o.__class__.__name__} is not JSON serializable")
877
+
878
+
879
  def _record_id(file_name: str, chemical: str, endpoint: str) -> str:
880
  chemical = (chemical or "").strip() or "-"
881
  endpoint = (endpoint or "").strip() or "Paper"
 
1261
  "risk_calculation_refs": [],
1262
  },
1263
  }
1264
+ json_path.write_text(json.dumps(details_payload, indent=2, default=_json_default), encoding="utf-8")
1265
  prefilled_template_path = export_prefilled_cancer_risk_template(records)
1266
 
1267
  choices = [r.get("record_id") for r in records if r.get("record_id")]