-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlaunch_console.py
More file actions
85 lines (68 loc) · 2.31 KB
/
Copy pathlaunch_console.py
File metadata and controls
85 lines (68 loc) · 2.31 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
"""
CuraFrame Console Launcher
This script launches the CuraFrame Streamlit console from the project root.
Purpose:
- Single, reproducible entry point for the UI
- No application logic
- No constraint reasoning
- No configuration decisions
Usage:
python launch_console.py
Or with Streamlit arguments:
python launch_console.py --server.port 8502
Philosophy:
This is a convenience wrapper only.
All logic lives in cura_frame (core) and apps/console_streamlit (UI).
"""
import sys
import subprocess
from pathlib import Path
def main():
"""Launch the CuraFrame Streamlit console."""
# Locate app.py relative to this script
script_dir = Path(__file__).parent
app_path = script_dir / "apps" / "console_streamlit" / "app.py"
# Verify app.py exists
if not app_path.exists():
print(f"Error: Could not find Streamlit app at {app_path}", file=sys.stderr)
print(f"Expected path: {app_path.absolute()}", file=sys.stderr)
sys.exit(1)
# Check if streamlit is available
try:
result = subprocess.run(
[sys.executable, "-m", "streamlit", "--version"],
capture_output=True,
text=True,
timeout=5,
check=False
)
if result.returncode != 0:
raise FileNotFoundError
except (subprocess.TimeoutExpired, FileNotFoundError):
print(
"Error: Streamlit is not installed or not accessible.\n"
"Install it with: pip install streamlit",
file=sys.stderr
)
sys.exit(1)
# Build command
cmd = [sys.executable, "-m", "streamlit", "run", str(app_path)]
# Forward any CLI arguments (e.g., --server.port 8502)
if len(sys.argv) > 1:
cmd.extend(sys.argv[1:])
# Display launch message
print("Launching CuraFrame Console...")
print(f"App: {app_path.relative_to(script_dir)}")
print(f"Command: {' '.join(cmd)}")
print("-" * 60)
# Launch Streamlit
try:
subprocess.run(cmd, check=True)
except subprocess.CalledProcessError as e:
print(f"\nError: Streamlit exited with code {e.returncode}", file=sys.stderr)
sys.exit(e.returncode)
except KeyboardInterrupt:
print("\nShutdown requested by user.")
sys.exit(0)
if __name__ == "__main__":
main()