James Frecheville commited on
Commit
94abab7
·
1 Parent(s): 4346c22

Optimize startup process and fix Playwright initialization

Browse files
Files changed (2) hide show
  1. Dockerfile +1 -0
  2. app.py +9 -22
Dockerfile CHANGED
@@ -70,6 +70,7 @@ ENV GRADIO_ALLOW_FLAGGING=false
70
  ENV GRADIO_QUEUE_ENABLED=false
71
  ENV DISPLAY=:99
72
  ENV PLAYWRIGHT_BROWSERS_PATH=/home/user/.cache/ms-playwright
 
73
 
74
  # Switch to non-root user
75
  USER user
 
70
  ENV GRADIO_QUEUE_ENABLED=false
71
  ENV DISPLAY=:99
72
  ENV PLAYWRIGHT_BROWSERS_PATH=/home/user/.cache/ms-playwright
73
+ ENV PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1
74
 
75
  # Switch to non-root user
76
  USER user
app.py CHANGED
@@ -2,41 +2,28 @@ import os
2
  import sys
3
  from pathlib import Path
4
 
5
- # Add current directory to Python path
6
  current_dir = Path(__file__).parent.absolute()
7
  if str(current_dir) not in sys.path:
8
  sys.path.append(str(current_dir))
9
 
10
- # Configure Gradio environment
11
- os.environ["GRADIO_ANALYTICS_ENABLED"] = "false"
12
- os.environ["GRADIO_SERVER_NAME"] = "0.0.0.0"
13
- os.environ["GRADIO_SERVER_PORT"] = "7861"
14
- os.environ["GRADIO_ALLOW_FLAGGING"] = "false"
15
- os.environ["GRADIO_QUEUE_ENABLED"] = "false"
16
-
17
- # Install browser dependencies if needed
18
- try:
19
- from playwright.sync_api import sync_playwright
20
- with sync_playwright() as p:
21
- p.chromium.launch()
22
- except Exception as e:
23
- print(f"Browser installation error: {e}")
24
- print("Attempting to install browser...")
25
- import subprocess
26
- subprocess.run(["playwright", "install", "chromium"], check=True)
27
 
28
  from owl.webapp import create_ui
 
29
 
30
- # Create Gradio interface
31
  demo = create_ui()
32
 
33
- # Launch the app
34
  if __name__ == "__main__":
35
  demo.launch(
36
  server_name="0.0.0.0",
37
  server_port=7861,
38
  share=False,
 
39
  show_error=True,
40
- favicon_path=None,
41
- allowed_paths=None
42
  )
 
2
  import sys
3
  from pathlib import Path
4
 
5
+ # Add the current directory to Python path
6
  current_dir = Path(__file__).parent.absolute()
7
  if str(current_dir) not in sys.path:
8
  sys.path.append(str(current_dir))
9
 
10
+ # Set environment variables for Playwright
11
+ os.environ["PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD"] = "1"
12
+ os.environ["PLAYWRIGHT_BROWSERS_PATH"] = "/home/user/.cache/ms-playwright"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
 
14
  from owl.webapp import create_ui
15
+ import gradio as gr
16
 
17
+ # Create the Gradio interface
18
  demo = create_ui()
19
 
20
+ # Launch the interface with optimized settings
21
  if __name__ == "__main__":
22
  demo.launch(
23
  server_name="0.0.0.0",
24
  server_port=7861,
25
  share=False,
26
+ favicon_path="assets/owl-favicon.ico",
27
  show_error=True,
28
+ debug=True
 
29
  )