-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_streamlit.py
More file actions
51 lines (41 loc) · 1.68 KB
/
Copy pathrun_streamlit.py
File metadata and controls
51 lines (41 loc) · 1.68 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
"""``f1-streamlit`` console script wrapper.
Exposed via ``[project.scripts]`` in ``pyproject.toml`` so a
``uv tool install`` of the repo gives the user a single-command launcher
for the Streamlit post-race UI alongside ``f1-sim`` (CLI) and
``f1-arcade`` (race replay + PySide6 dashboards).
Running this module delegates to the bundled ``streamlit`` binary via
``python -m streamlit``, pointing at the canonical ``src/telemetry/frontend/app/main.py``.
Extra CLI arguments are forwarded verbatim (``--server.port``,
``--server.headless``, etc.) so existing streamlit knobs keep working.
"""
from __future__ import annotations
import shlex
import subprocess
import sys
from pathlib import Path
def main() -> int:
"""Launch the Streamlit post-race app with ``python -m streamlit``.
Resolves the entrypoint relative to this file so the wrapper is
location-independent — it works whether the package was installed
via ``uv tool install`` (site-packages path) or run from a source
checkout. Propagates the child process's exit code."""
app_path = (
Path(__file__).resolve().parent.parent
/ "src"
/ "telemetry"
/ "frontend"
/ "app"
/ "main.py"
)
if not app_path.exists():
print(
f"f1-streamlit: cannot find Streamlit entrypoint at {app_path} — "
"ensure the package was installed with the frontend assets.",
file=sys.stderr,
)
return 2
cmd = [sys.executable, "-m", "streamlit", "run", str(app_path), *sys.argv[1:]]
print(f"$ {' '.join(shlex.quote(arg) for arg in cmd)}", file=sys.stderr)
return subprocess.call(cmd)
if __name__ == "__main__":
sys.exit(main())