re-type commited on
Commit
905619b
·
verified ·
1 Parent(s): 37ffc25

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -24
app.py CHANGED
@@ -780,32 +780,20 @@ def create_gradio_interface():
780
  title="🧬 Gene Analysis Pipeline (Error Mode)"
781
  )
782
  # --- Application Startup ---
783
- async def run_pipeline_from_file(fasta_file_obj, similarity_score, build_ml_tree):
784
- temp_file_path = None
785
  try:
786
- if fasta_file_obj is None:
787
- return "❌ No file provided", "", "", "", "", None, None, None, None, "No input", "No input", None, None
788
- with tempfile.NamedTemporaryFile(delete=False, suffix=".fasta", dir="/tmp") as temp_file:
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"Pipeline from file error: {main_error}", exc_info=True)
806
- cleanup_file(temp_file_path)
807
- error_msg = f"❌ Error: {str(main_error)}"
808
- return error_msg, "", "", "", "", None, None, None, None, error_msg, error_msg, None, None
 
 
 
 
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)