Repository navigation
Expand file tree
/
Copy pathrun_web_viewer.py
More file actions
54 lines (42 loc) · 1.49 KB
/
Copy pathrun_web_viewer.py
File metadata and controls
54 lines (42 loc) · 1.49 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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/env python3
"""
CLI wrapper to launch the MUR web viewer using Streamlit.
This script is the entry point for the `mur-web-viewer` command.
It simply runs: streamlit run dataviewer/web_viewer.py
"""
import sys
import os
import subprocess
from pathlib import Path
def main():
"""Launch Streamlit with the web viewer."""
# Get the mur directory
mur_dir = Path(__file__).parent.resolve()
web_viewer_path = mur_dir / 'dataviewer' / 'web_viewer.py'
if not web_viewer_path.exists():
print(f"Error: Could not find web_viewer.py at {web_viewer_path}")
sys.exit(1)
# Set default base directory to ./testing if not already set
if 'MUR_BASE_DIR' not in os.environ:
default_base = mur_dir / 'testing'
os.environ['MUR_BASE_DIR'] = str(default_base)
print(f"Using default base directory: {default_base}")
# Build the streamlit command
cmd = ['streamlit', 'run', str(web_viewer_path)]
# Add any additional arguments passed to this script
if len(sys.argv) > 1:
cmd.append('--')
cmd.extend(sys.argv[1:])
# Change to mur directory so relative imports work
os.chdir(mur_dir)
# Execute streamlit
try:
sys.exit(subprocess.call(cmd))
except KeyboardInterrupt:
print("\n\nShutting down...")
sys.exit(0)
except FileNotFoundError:
print("Error: streamlit command not found. Install with: pip install streamlit")
sys.exit(1)
if __name__ == '__main__':
main()