deeploy-adubowski commited on
Commit
50ee05f
·
1 Parent(s): 9cb79eb

Add error handling for react exception

Browse files
Files changed (1) hide show
  1. app.py +47 -39
app.py CHANGED
@@ -326,45 +326,53 @@ elif st.session_state.predict_button_clicked and st.session_state.exp is not Non
326
  # + " \n For more details, see full explanation of the credit assessment below.",
327
  )
328
  explanation_expander = st.expander("Show explanation")
329
- with explanation_expander:
330
- # Show explanation
331
- col_pos, col_neg = st.columns(2)
332
-
333
- with col_pos:
334
- st.subheader("Factors :green[in favor] of loan approval")
335
- # st.success("**Factors in favor of loan approval**")
336
- st.dataframe(
337
- pos_exp_df_t,
338
- hide_index=True,
339
- width=600,
340
- column_config={
341
- "Weight": st.column_config.ProgressColumn(
342
- "Weight",
343
- width="small",
344
- format=" ",
345
- min_value=0,
346
- max_value=1,
347
- )
348
- },
349
- )
350
-
351
- with col_neg:
352
- st.subheader("Factors :red[against] loan approval")
353
- # st.error("**Factors against loan approval**")
354
- st.dataframe(
355
- neg_exp_df_t,
356
- hide_index=True,
357
- width=600,
358
- column_config={
359
- "Weight": st.column_config.ProgressColumn(
360
- "Weight",
361
- width="small",
362
- format=" ",
363
- min_value=0,
364
- max_value=1,
365
- )
366
- },
367
- )
 
 
 
 
 
 
 
 
368
 
369
  st.divider()
370
 
 
326
  # + " \n For more details, see full explanation of the credit assessment below.",
327
  )
328
  explanation_expander = st.expander("Show explanation")
329
+ try:
330
+ with explanation_expander:
331
+ # Show explanation
332
+ col_pos, col_neg = st.columns(2)
333
+
334
+ with col_pos:
335
+ st.subheader("Factors :green[in favor] of loan approval")
336
+ # st.success("**Factors in favor of loan approval**")
337
+ st.dataframe(
338
+ pos_exp_df_t,
339
+ hide_index=True,
340
+ width=600,
341
+ column_config={
342
+ "Weight": st.column_config.ProgressColumn(
343
+ "Weight",
344
+ width="small",
345
+ format=" ",
346
+ min_value=0,
347
+ max_value=1,
348
+ )
349
+ },
350
+ )
351
+
352
+ with col_neg:
353
+ st.subheader("Factors :red[against] loan approval")
354
+ # st.error("**Factors against loan approval**")
355
+ st.dataframe(
356
+ neg_exp_df_t,
357
+ hide_index=True,
358
+ width=600,
359
+ column_config={
360
+ "Weight": st.column_config.ProgressColumn(
361
+ "Weight",
362
+ width="small",
363
+ format=" ",
364
+ min_value=0,
365
+ max_value=1,
366
+ )
367
+ },
368
+ )
369
+ except Exception as e:
370
+ logging.error(e)
371
+ st.error(
372
+ "Failed to show the explanation."
373
+ + "Refresh the page to reset the application."
374
+ + "Contact Deeploy if the problem persists."
375
+ )
376
 
377
  st.divider()
378