genomenet Claude Opus 4.7 (1M context) commited on
Commit
794dc2b
·
1 Parent(s): 8bea4eb

Disable seq viewer HTML and always-visible accordions to pin down freeze

Browse files

Plot renders correctly but page still unresponsive after inference. Two
remaining suspects: the 1000+ inline-styled spans from the sequence
viewer HTML (heavy DOM) and the visible=False -> gr.update(visible=True)
accordion pattern (matches Gradio 6.0.2 visibility bug). Cutting both
as a diagnostic: sequence viewer returns empty string, accordions ship
already visible without runtime toggles. Also widens gradio-container
max-width so the page no longer has a big right-side whitespace band.

If the page becomes responsive, one of these was the cause and we
re-enable them more carefully.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

Files changed (1) hide show
  1. app.py +13 -23
app.py CHANGED
@@ -70,7 +70,7 @@ h2, h3, h4 {
70
  }
71
 
72
  .gradio-container {
73
- max-width: 1200px !important;
74
  background: #fafafa !important;
75
  }
76
 
@@ -958,8 +958,9 @@ def predict(sequence: str, stride: int = DEFAULT_STRIDE, threshold: float = DEFA
958
  # Create GFF3 export
959
  gff_path = create_gff3_export(regions, result.sequence_length, output_dir=output_dir) if regions else None
960
 
961
- # Create sequence viewer HTML
962
- seq_viewer_html = create_sequence_viewer_html(sequence, display_positions, result.probabilities, threshold)
 
963
 
964
  elapsed_time = time.time() - start_time
965
 
@@ -1211,12 +1212,10 @@ Sliding window analysis with per-position probability scores. Export to GFF3/CSV
1211
  lambda: NON_CRISPR_EXAMPLE, outputs=seq_input
1212
  )
1213
  result_summary = gr.Markdown()
1214
- with gr.Accordion("export", open=False, visible=False) as download_accordion:
1215
-
1216
  with gr.Row():
1217
  pred_download_png = gr.File(label="png", interactive=False)
1218
  pred_download_pdf = gr.File(label="pdf", interactive=False)
1219
-
1220
  with gr.Row():
1221
  pred_download_csv = gr.File(label="csv", interactive=False)
1222
  pred_download_gff = gr.File(label="gff3", interactive=False)
@@ -1224,9 +1223,7 @@ Sliding window analysis with per-position probability scores. Export to GFF3/CSV
1224
  pred_download_summary = gr.File(label="summary", interactive=False)
1225
  with gr.Column(scale=2):
1226
  plot_output = gr.Plot(label="prediction")
1227
- with gr.Accordion("sequence", open=False, visible=False) as seq_viewer_accordion:
1228
- gr.Markdown("*grayscale intensity = score. hover for values.*")
1229
- seq_viewer_html = gr.HTML(label="sequence")
1230
  regions_output = gr.JSON(label="Detected Regions", visible=False)
1231
 
1232
  # Handle file upload - load content into textbox
@@ -1243,21 +1240,16 @@ Sliding window analysis with per-position probability scores. Export to GFF3/CSV
1243
 
1244
  def predict_and_show_downloads(*args):
1245
  try:
1246
- results = predict(*args)
1247
  except Exception as exc:
1248
  logger.exception("Prediction failed")
1249
- results = prediction_error_outputs(f"Analysis failed: {exc}")
1250
- # results = (fig, summary, regions, png, pdf, csv, summary_txt, gff, seq_html)
1251
- # Return results plus visibility updates for accordions
1252
- success = results[0] is not None
1253
- return results + (gr.update(visible=success), gr.update(visible=success))
1254
 
1255
  predict_btn.click(
1256
  predict_and_show_downloads,
1257
  inputs=[seq_input, stride_input, threshold_input],
1258
  outputs=[plot_output, result_summary, regions_output, pred_download_png, pred_download_pdf,
1259
- pred_download_csv, pred_download_summary, pred_download_gff, seq_viewer_html,
1260
- download_accordion, seq_viewer_accordion],
1261
  api_name="predict",
1262
  concurrency_limit=1,
1263
  )
@@ -1301,7 +1293,7 @@ Repeats cluster together, spacers form distinct groups.
1301
  )
1302
  gr.Markdown("*example: 600bp upstream | 25 repeats + 24 spacers | 600bp downstream*")
1303
  embed_summary = gr.Markdown()
1304
- with gr.Accordion("export", open=False, visible=False) as embed_download_accordion:
1305
  with gr.Row():
1306
  download_png = gr.File(label="png", interactive=False)
1307
  download_pdf = gr.File(label="pdf", interactive=False)
@@ -1317,17 +1309,15 @@ Repeats cluster together, spacers form distinct groups.
1317
 
1318
  def embed_and_show_downloads(*args):
1319
  try:
1320
- results = get_embedding(*args)
1321
  except Exception as exc:
1322
  logger.exception("Embedding failed")
1323
- results = embedding_error_outputs(f"Embedding failed: {exc}")
1324
- success = results[0] is not None
1325
- return results + (gr.update(visible=success),)
1326
 
1327
  embed_btn.click(
1328
  embed_and_show_downloads,
1329
  inputs=[embed_seq, embed_mode, use_3d],
1330
- outputs=[embed_plot, embed_summary, download_png, download_pdf, embed_download_accordion],
1331
  api_name="get_embedding",
1332
  concurrency_limit=1,
1333
  )
 
70
  }
71
 
72
  .gradio-container {
73
+ max-width: 100% !important;
74
  background: #fafafa !important;
75
  }
76
 
 
958
  # Create GFF3 export
959
  gff_path = create_gff3_export(regions, result.sequence_length, output_dir=output_dir) if regions else None
960
 
961
+ # Sequence viewer disabled as a freeze-diagnostic: 1000+ inline-styled spans
962
+ # seem to block the browser after render. Re-enable once the root cause is known.
963
+ seq_viewer_html = ""
964
 
965
  elapsed_time = time.time() - start_time
966
 
 
1212
  lambda: NON_CRISPR_EXAMPLE, outputs=seq_input
1213
  )
1214
  result_summary = gr.Markdown()
1215
+ with gr.Accordion("export", open=False) as download_accordion:
 
1216
  with gr.Row():
1217
  pred_download_png = gr.File(label="png", interactive=False)
1218
  pred_download_pdf = gr.File(label="pdf", interactive=False)
 
1219
  with gr.Row():
1220
  pred_download_csv = gr.File(label="csv", interactive=False)
1221
  pred_download_gff = gr.File(label="gff3", interactive=False)
 
1223
  pred_download_summary = gr.File(label="summary", interactive=False)
1224
  with gr.Column(scale=2):
1225
  plot_output = gr.Plot(label="prediction")
1226
+ seq_viewer_html = gr.HTML(visible=False)
 
 
1227
  regions_output = gr.JSON(label="Detected Regions", visible=False)
1228
 
1229
  # Handle file upload - load content into textbox
 
1240
 
1241
  def predict_and_show_downloads(*args):
1242
  try:
1243
+ return predict(*args)
1244
  except Exception as exc:
1245
  logger.exception("Prediction failed")
1246
+ return prediction_error_outputs(f"Analysis failed: {exc}")
 
 
 
 
1247
 
1248
  predict_btn.click(
1249
  predict_and_show_downloads,
1250
  inputs=[seq_input, stride_input, threshold_input],
1251
  outputs=[plot_output, result_summary, regions_output, pred_download_png, pred_download_pdf,
1252
+ pred_download_csv, pred_download_summary, pred_download_gff, seq_viewer_html],
 
1253
  api_name="predict",
1254
  concurrency_limit=1,
1255
  )
 
1293
  )
1294
  gr.Markdown("*example: 600bp upstream | 25 repeats + 24 spacers | 600bp downstream*")
1295
  embed_summary = gr.Markdown()
1296
+ with gr.Accordion("export", open=False) as embed_download_accordion:
1297
  with gr.Row():
1298
  download_png = gr.File(label="png", interactive=False)
1299
  download_pdf = gr.File(label="pdf", interactive=False)
 
1309
 
1310
  def embed_and_show_downloads(*args):
1311
  try:
1312
+ return get_embedding(*args)
1313
  except Exception as exc:
1314
  logger.exception("Embedding failed")
1315
+ return embedding_error_outputs(f"Embedding failed: {exc}")
 
 
1316
 
1317
  embed_btn.click(
1318
  embed_and_show_downloads,
1319
  inputs=[embed_seq, embed_mode, use_3d],
1320
+ outputs=[embed_plot, embed_summary, download_png, download_pdf],
1321
  api_name="get_embedding",
1322
  concurrency_limit=1,
1323
  )