Boghdady9 commited on
Commit
d6145e3
Β·
1 Parent(s): 50bda14

πŸ”§ Add debugging and error handling for Gradio startup

Browse files

- Enhanced start_app.sh with detailed logging and process tracking
- Added comprehensive error handling to gradio_app.py launch
- Include file listing and directory checks for troubleshooting
- Added timing delays between backend and frontend startup
- Better error reporting with full tracebacks for debugging

Files changed (2) hide show
  1. src/gradio_app.py +23 -7
  2. src/start_app.sh +23 -1
src/gradio_app.py CHANGED
@@ -475,10 +475,26 @@ def create_medivision_app():
475
 
476
  # Create and launch the app
477
  if __name__ == "__main__":
478
- app = create_medivision_app()
479
- app.launch(
480
- server_name="0.0.0.0",
481
- server_port=7860,
482
- share=True,
483
- show_api=False
484
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
475
 
476
  # Create and launch the app
477
  if __name__ == "__main__":
478
+ print("πŸš€ Initializing MediVision Gradio App...")
479
+ try:
480
+ print("πŸ“ Creating Gradio interface...")
481
+ app = create_medivision_app()
482
+ print("βœ… Gradio interface created successfully!")
483
+
484
+ print("🌐 Launching Gradio app...")
485
+ print(f"πŸ”— Server: 0.0.0.0:7860")
486
+ print(f"πŸ”— Share: True")
487
+
488
+ app.launch(
489
+ server_name="0.0.0.0",
490
+ server_port=7860,
491
+ share=True,
492
+ show_api=False
493
+ )
494
+
495
+ except Exception as e:
496
+ print(f"❌ Error launching Gradio app: {str(e)}")
497
+ import traceback
498
+ print(f"πŸ“‹ Full traceback:")
499
+ traceback.print_exc()
500
+ raise
src/start_app.sh CHANGED
@@ -1,19 +1,41 @@
1
  #!/bin/bash
2
 
 
 
3
  echo "πŸ”¬ MediVision - AI-Powered Radiology Report System"
4
  echo "=================================================="
5
 
 
 
 
 
 
6
  # Check if argument provided
7
  if [ "$1" = "streamlit" ]; then
8
  echo "🌐 Starting with Streamlit..."
9
  cd /app/backend && uvicorn service:app --host 0.0.0.0 --port 8001 &
 
 
 
10
  cd /app && streamlit run streamlit_app.py --server.port 8501 --server.address 0.0.0.0 --server.enableXsrfProtection=false
11
  elif [ "$1" = "gradio" ]; then
12
  echo "🌐 Starting with Gradio..."
13
  cd /app/backend && uvicorn service:app --host 0.0.0.0 --port 8001 &
 
 
 
 
14
  cd /app && python gradio_app.py
15
  else
16
  echo "🌐 Starting with Gradio (default)..."
17
  cd /app/backend && uvicorn service:app --host 0.0.0.0 --port 8001 &
18
- cd /app && python gradio_app.py
 
 
 
 
 
 
 
 
19
  fi
 
1
  #!/bin/bash
2
 
3
+ echo "===== Application Startup at $(date) ====="
4
+ echo ""
5
  echo "πŸ”¬ MediVision - AI-Powered Radiology Report System"
6
  echo "=================================================="
7
 
8
+ # Check current directory and list files
9
+ echo "πŸ“‚ Current directory: $(pwd)"
10
+ echo "πŸ“ Available files:"
11
+ ls -la /app/
12
+
13
  # Check if argument provided
14
  if [ "$1" = "streamlit" ]; then
15
  echo "🌐 Starting with Streamlit..."
16
  cd /app/backend && uvicorn service:app --host 0.0.0.0 --port 8001 &
17
+ BACKEND_PID=$!
18
+ echo "πŸ”§ Backend started with PID: $BACKEND_PID"
19
+ sleep 2
20
  cd /app && streamlit run streamlit_app.py --server.port 8501 --server.address 0.0.0.0 --server.enableXsrfProtection=false
21
  elif [ "$1" = "gradio" ]; then
22
  echo "🌐 Starting with Gradio..."
23
  cd /app/backend && uvicorn service:app --host 0.0.0.0 --port 8001 &
24
+ BACKEND_PID=$!
25
+ echo "πŸ”§ Backend started with PID: $BACKEND_PID"
26
+ sleep 3
27
+ echo "πŸš€ Starting Gradio frontend..."
28
  cd /app && python gradio_app.py
29
  else
30
  echo "🌐 Starting with Gradio (default)..."
31
  cd /app/backend && uvicorn service:app --host 0.0.0.0 --port 8001 &
32
+ BACKEND_PID=$!
33
+ echo "πŸ”§ Backend started with PID: $BACKEND_PID"
34
+ sleep 3
35
+ echo "πŸš€ Starting Gradio frontend..."
36
+ cd /app
37
+ echo "πŸ“ About to run: python gradio_app.py"
38
+ echo "πŸ“ Files in current directory:"
39
+ ls -la
40
+ python gradio_app.py
41
  fi