-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_streamlit.py
More file actions
executable file
·34 lines (28 loc) · 1.05 KB
/
run_streamlit.py
File metadata and controls
executable file
·34 lines (28 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/env python
"""
Wrapper script to run the WronAI Streamlit application.
This resolves import issues by running the app as a module.
"""
import os
import sys
import subprocess
if __name__ == "__main__":
# Add the project root to the Python path
project_root = os.path.dirname(os.path.abspath(__file__))
# Modify the app.py file to use absolute imports instead of relative imports
app_path = os.path.join(project_root, "wronai", "web", "app.py")
# Create a modified environment with the project root in PYTHONPATH
env = os.environ.copy()
if "PYTHONPATH" in env:
env["PYTHONPATH"] = f"{project_root}:{env['PYTHONPATH']}"
else:
env["PYTHONPATH"] = project_root
# Run the Streamlit app using subprocess
cmd = ["streamlit", "run", app_path, "--server.headless", "true"]
print(f"Running: {' '.join(cmd)}")
try:
process = subprocess.run(cmd, env=env)
sys.exit(process.returncode)
except Exception as e:
print(f"Error running Streamlit: {e}")
sys.exit(1)