re-type commited on
Commit
3c94bd8
·
verified ·
1 Parent(s): 434da56

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -5
app.py CHANGED
@@ -1,8 +1,9 @@
1
  import os
2
  # Disable GPU to avoid CUDA errors
3
  os.environ["CUDA_VISIBLE_DEVICES"] = ""
 
4
  # Suppress TensorFlow warnings
5
- os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
6
 
7
  import gradio as gr
8
  import torch
@@ -763,9 +764,13 @@ def create_gradio_interface():
763
  # --- Application Startup ---
764
  def run_application():
765
  try:
 
766
  main_gradio_app = create_gradio_interface()
 
 
 
767
  main_gradio_app = gr.mount_gradio_app(app, main_gradio_app, path="/gradio")
768
- logger.info("🧬 Gene Analysis Pipeline Starting...")
769
  logger.info("=" * 50)
770
  logger.info("🔍 Checking system components...")
771
  logger.info(f"🤖 Boundary Model: {'✅ Loaded' if boundary_model else '❌ Missing'}")
@@ -784,22 +789,28 @@ def run_application():
784
  host="0.0.0.0",
785
  port=7860,
786
  log_level="info",
787
- access_log=True
 
788
  )
789
  except Exception as main_error:
790
  logger.error(f"Application startup failed: {main_error}", exc_info=True)
791
  try:
792
  logger.info("🔄 Falling back to Gradio-only mode...")
793
  fallback_gradio_app = create_gradio_interface()
 
 
 
794
  logger.info("🧬 Gradio interface available at: http://localhost:7860")
795
  fallback_gradio_app.launch(
796
  server_name="0.0.0.0",
797
  server_port=7860,
798
- prevent_thread_lock=True
 
799
  )
800
  except Exception as fallback_error:
801
  logger.error(f"Fallback failed: {fallback_error}", exc_info=True)
802
- print("❌ Application failed to start. Check logs for details.")
 
803
 
804
  if __name__ == "__main__":
805
  print("🧬 Gene Analysis Pipeline Starting...")
 
1
  import os
2
  # Disable GPU to avoid CUDA errors
3
  os.environ["CUDA_VISIBLE_DEVICES"] = ""
4
+ os.environ["TF_FORCE_GPU_ALLOW_GROWTH"] = "true" # Prevent TensorFlow memory issues
5
  # Suppress TensorFlow warnings
6
+ os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3' # More aggressive suppression
7
 
8
  import gradio as gr
9
  import torch
 
764
  # --- Application Startup ---
765
  def run_application():
766
  try:
767
+ logger.info("🧬 Initializing Gene Analysis Pipeline...")
768
  main_gradio_app = create_gradio_interface()
769
+ if main_gradio_app is None:
770
+ raise RuntimeError("Gradio interface creation returned None")
771
+ logger.info("✅ Gradio interface created successfully")
772
  main_gradio_app = gr.mount_gradio_app(app, main_gradio_app, path="/gradio")
773
+ logger.info(" Gradio mounted to FastAPI at /gradio")
774
  logger.info("=" * 50)
775
  logger.info("🔍 Checking system components...")
776
  logger.info(f"🤖 Boundary Model: {'✅ Loaded' if boundary_model else '❌ Missing'}")
 
789
  host="0.0.0.0",
790
  port=7860,
791
  log_level="info",
792
+ access_log=True,
793
+ timeout_keep_alive=120
794
  )
795
  except Exception as main_error:
796
  logger.error(f"Application startup failed: {main_error}", exc_info=True)
797
  try:
798
  logger.info("🔄 Falling back to Gradio-only mode...")
799
  fallback_gradio_app = create_gradio_interface()
800
+ if fallback_gradio_app is None:
801
+ raise RuntimeError("Fallback Gradio interface creation returned None")
802
+ logger.info("✅ Fallback Gradio interface created successfully")
803
  logger.info("🧬 Gradio interface available at: http://localhost:7860")
804
  fallback_gradio_app.launch(
805
  server_name="0.0.0.0",
806
  server_port=7860,
807
+ prevent_thread_lock=True,
808
+ quiet=True
809
  )
810
  except Exception as fallback_error:
811
  logger.error(f"Fallback failed: {fallback_error}", exc_info=True)
812
+ print("❌ Application failed to start. Check logs at /tmp/app.log for details.")
813
+ sys.exit(1)
814
 
815
  if __name__ == "__main__":
816
  print("🧬 Gene Analysis Pipeline Starting...")