Spaces:
No application file
No application file
Update app.py
Browse files
app.py
CHANGED
|
@@ -780,32 +780,20 @@ def create_gradio_interface():
|
|
| 780 |
title="🧬 Gene Analysis Pipeline (Error Mode)"
|
| 781 |
)
|
| 782 |
# --- Application Startup ---
|
| 783 |
-
|
| 784 |
-
temp_file_path = None
|
| 785 |
try:
|
| 786 |
-
|
| 787 |
-
|
| 788 |
-
|
| 789 |
-
if isinstance(fasta_file_obj, UploadFile):
|
| 790 |
-
content = await fasta_file_obj.read()
|
| 791 |
-
temp_file.write(content)
|
| 792 |
-
else:
|
| 793 |
-
with open(fasta_file_obj, 'rb') as f:
|
| 794 |
-
content = f.read()
|
| 795 |
-
temp_file.write(content)
|
| 796 |
-
temp_file_path = temp_file.name
|
| 797 |
-
dna_input = read_fasta_file(temp_file_path)
|
| 798 |
-
if not dna_input:
|
| 799 |
-
cleanup_file(temp_file_path)
|
| 800 |
-
return "❌ Failed to read FASTA file", "", "", "", "", None, None, None, None, "No input", "No input", None, None
|
| 801 |
-
result = run_pipeline(dna_input, similarity_score, build_ml_tree)
|
| 802 |
-
cleanup_file(temp_file_path)
|
| 803 |
-
return result
|
| 804 |
except Exception as main_error:
|
| 805 |
-
logger.error(f"
|
| 806 |
-
|
| 807 |
-
|
| 808 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 809 |
if __name__ == "__main__":
|
| 810 |
print("🧬 Gene Analysis Pipeline Starting...")
|
| 811 |
print("=" * 50)
|
|
|
|
| 780 |
title="🧬 Gene Analysis Pipeline (Error Mode)"
|
| 781 |
)
|
| 782 |
# --- Application Startup ---
|
| 783 |
+
def run_application():
|
|
|
|
| 784 |
try:
|
| 785 |
+
main_gradio_app = create_gradio_interface()
|
| 786 |
+
main_gradio_app = gr.mount_gradio_app(app, main_gradio_app, path="/gradio")
|
| 787 |
+
# ... (logging and uvicorn.run)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 788 |
except Exception as main_error:
|
| 789 |
+
logger.error(f"Application startup failed: {main_error}", exc_info=True)
|
| 790 |
+
try:
|
| 791 |
+
logger.info("🔄 Falling back to Gradio-only mode...")
|
| 792 |
+
fallback_gradio_app = create_gradio_interface()
|
| 793 |
+
# ... (launch fallback)
|
| 794 |
+
except Exception as fallback_error:
|
| 795 |
+
logger.error(f"Fallback failed: {fallback_error}", exc_info=True)
|
| 796 |
+
print("❌ Application failed to start. Check logs for details.")
|
| 797 |
if __name__ == "__main__":
|
| 798 |
print("🧬 Gene Analysis Pipeline Starting...")
|
| 799 |
print("=" * 50)
|