dzs commited on
Commit
17bb12d
·
1 Parent(s): cab891c

added debug mechanism

Browse files
Files changed (1) hide show
  1. main.py +12 -10
main.py CHANGED
@@ -683,6 +683,9 @@ def update_chart(n_clicks,
683
  # TODO: replace with logic that uses the form inputs
684
  # For now, simply return the same figure when "Calculate" is clicked.
685
 
 
 
 
686
  df = pd.DataFrame()
687
  df['CASRN'] = soluteData['CASRN'].to_numpy()
688
 
@@ -715,8 +718,13 @@ def update_chart(n_clicks,
715
  Iterations = float(c1_iter)
716
  Lbath = float(c1_volume) / float(surface_area)
717
 
718
- medians, lowers, uppers = ExtractMonteCarlo(soluteData, Solvent_PI, w, ExtractionT, Polymer_Tg, Solvent_Name, Solvent_MW,
 
719
  ExtractionTime, Swell, Iterations, CHRIS_category, L, Lbath, N)
 
 
 
 
720
 
721
  df['Condition 1'] = medians
722
  df['Cond1_err_plus'] = uppers-medians
@@ -749,15 +757,9 @@ def update_chart(n_clicks,
749
  df['Cond2_err_plus'] = uppers - medians
750
  df['Cond2_err_minus'] = medians - lowers
751
 
752
- t0 = time.time()
753
- try:
754
- # your current code
755
- fig = build_figure(df)
756
- return fig, f"OK in {time.time() - t0:.2f}s"
757
- except Exception:
758
- return no_update, traceback.format_exc()
759
-
760
- #return build_figure(df)
761
 
762
  def ConservativeMonteCarlo(soluteData, CHRIS_category, L, time, N):
763
 
 
683
  # TODO: replace with logic that uses the form inputs
684
  # For now, simply return the same figure when "Calculate" is clicked.
685
 
686
+ t0 = time.time()
687
+ debug = [f"run={run_id} click={n_clicks}"]
688
+
689
  df = pd.DataFrame()
690
  df['CASRN'] = soluteData['CASRN'].to_numpy()
691
 
 
718
  Iterations = float(c1_iter)
719
  Lbath = float(c1_volume) / float(surface_area)
720
 
721
+ try:
722
+ medians, lowers, uppers = ExtractMonteCarlo(soluteData, Solvent_PI, w, ExtractionT, Polymer_Tg, Solvent_Name, Solvent_MW,
723
  ExtractionTime, Swell, Iterations, CHRIS_category, L, Lbath, N)
724
+ except Exception:
725
+ debug.append("c1 FAILED")
726
+ debug.append(traceback.format_exc())
727
+ return no_update, "\n".join(debug)
728
 
729
  df['Condition 1'] = medians
730
  df['Cond1_err_plus'] = uppers-medians
 
757
  df['Cond2_err_plus'] = uppers - medians
758
  df['Cond2_err_minus'] = medians - lowers
759
 
760
+ fig = build_figure(df)
761
+ debug.append(f"fig ok total {time.time() - t0:.2f}s")
762
+ return fig, "\n".join(debug)
 
 
 
 
 
 
763
 
764
  def ConservativeMonteCarlo(soluteData, CHRIS_category, L, time, N):
765