Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -512,17 +512,50 @@ with gr.Blocks() as interface:
|
|
512 |
"\n".join(log_lines)
|
513 |
)
|
514 |
|
515 |
-
try:
|
516 |
-
|
517 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
518 |
all_rows.extend(rows)
|
519 |
-
processed_accessions += 1
|
520 |
if email.strip():
|
521 |
save_to_excel(all_rows, "", "", output_file_path, is_resume=False)
|
522 |
log_lines.append(f"β
Processed {acc} ({i+1}/{total})")
|
523 |
-
|
524 |
-
|
525 |
-
|
|
|
|
|
|
|
526 |
yield (
|
527 |
make_html_table(all_rows),
|
528 |
gr.update(visible=True),
|
@@ -531,6 +564,18 @@ with gr.Blocks() as interface:
|
|
531 |
"β³ Processing...",
|
532 |
"\n".join(log_lines)
|
533 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
534 |
|
535 |
# Step 3: Final usage update
|
536 |
usage_text = ""
|
|
|
512 |
"\n".join(log_lines)
|
513 |
)
|
514 |
|
515 |
+
# try:
|
516 |
+
# print("π Processing accession:", acc)
|
517 |
+
# rows = summarize_results(acc)
|
518 |
+
# all_rows.extend(rows)
|
519 |
+
# processed_accessions += 1 # β
only count success
|
520 |
+
# if email.strip():
|
521 |
+
# save_to_excel(all_rows, "", "", output_file_path, is_resume=False)
|
522 |
+
# log_lines.append(f"β
Processed {acc} ({i+1}/{total})")
|
523 |
+
print("π Processing accession:", acc)
|
524 |
+
|
525 |
+
# Run summarize_results in a separate process with stop flag support
|
526 |
+
success, rows = run_with_timeout(
|
527 |
+
summarize_results,
|
528 |
+
args=(acc,),
|
529 |
+
timeout=None, # or set max seconds per sample if you want
|
530 |
+
stop_value=global_stop_flag
|
531 |
+
)
|
532 |
+
|
533 |
+
# If stop was pressed during this accession
|
534 |
+
if not success and global_stop_flag.value:
|
535 |
+
log_lines.append(f"π Cancelled {acc} before completion")
|
536 |
+
yield (
|
537 |
+
make_html_table(all_rows),
|
538 |
+
gr.update(visible=True),
|
539 |
+
gr.update(visible=False),
|
540 |
+
"",
|
541 |
+
"π Stopped",
|
542 |
+
"\n".join(log_lines)
|
543 |
+
)
|
544 |
+
break # stop processing entirely
|
545 |
+
|
546 |
+
# If it finished normally
|
547 |
+
if success and rows:
|
548 |
all_rows.extend(rows)
|
549 |
+
processed_accessions += 1
|
550 |
if email.strip():
|
551 |
save_to_excel(all_rows, "", "", output_file_path, is_resume=False)
|
552 |
log_lines.append(f"β
Processed {acc} ({i+1}/{total})")
|
553 |
+
else:
|
554 |
+
# If it failed due to timeout or other error
|
555 |
+
if not global_stop_flag.value:
|
556 |
+
log_lines.append(f"β οΈ Skipped {acc} due to timeout or error")
|
557 |
+
|
558 |
+
# Always yield updated logs after each attempt
|
559 |
yield (
|
560 |
make_html_table(all_rows),
|
561 |
gr.update(visible=True),
|
|
|
564 |
"β³ Processing...",
|
565 |
"\n".join(log_lines)
|
566 |
)
|
567 |
+
|
568 |
+
# except Exception as e:
|
569 |
+
# log_lines.append(f"β Failed to process {acc}: {e}")
|
570 |
+
|
571 |
+
# yield (
|
572 |
+
# make_html_table(all_rows),
|
573 |
+
# gr.update(visible=True),
|
574 |
+
# gr.update(visible=False),
|
575 |
+
# "",
|
576 |
+
# "β³ Processing...",
|
577 |
+
# "\n".join(log_lines)
|
578 |
+
# )
|
579 |
|
580 |
# Step 3: Final usage update
|
581 |
usage_text = ""
|