Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions alphatrion/envs.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@
ENABLE_TRACING = "ALPHATRION_ENABLE_TRACING"
ROOT_PATH = "ALPHATRION_ROOT_PATH"
AUTO_CLEANUP = "ALPHATRION_AUTO_CLEANUP"

# Dashboard only related envs
DASHBOARD_USER_ID = "ALPHATRION_DASHBOARD_USER_ID"
34 changes: 31 additions & 3 deletions alphatrion/server/cmd/main.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# ruff: noqa: E501

import argparse
import os
import threading
import time
import webbrowser
Expand All @@ -17,6 +18,7 @@
from rich.console import Console
from rich.text import Text

from alphatrion import envs
from alphatrion.storage import runtime

load_dotenv()
Expand Down Expand Up @@ -59,7 +61,7 @@ def main():
dashboard.add_argument(
"--userid",
type=str,
required=True,
default=os.getenv(envs.DASHBOARD_USER_ID),
help="User ID to scope the dashboard (required)",
)
dashboard.set_defaults(func=start_dashboard)
Expand Down Expand Up @@ -140,7 +142,13 @@ def init_command(args):
console.print(Text(" Your team ID:", style="bold yellow"))
console.print(Text(f" {team_id}", style="bold cyan"))
console.print()
console.print(Text("💡 Use this user ID to launch the dashboard:", style="dim"))
console.print(
Text(
"💡 Use this user ID to launch the dashboard, "
"or set the ALPHATRION_DASHBOARD_USER_ID environment variable",
style="dim",
)
)
console.print(
Text(f" alphatrion dashboard --userid {user_id}", style="magenta")
)
Expand All @@ -154,7 +162,7 @@ def init_command(args):
console.print(Text(" import alphatrion as alpha", style="white"))
console.print(
Text(
f" alpha.init(user_id='{user_id}', team_id='{team_id}')",
f" alpha.init(user_id='{user_id}')",
style="white",
)
)
Expand Down Expand Up @@ -264,6 +272,26 @@ def start_dashboard(args):

app = FastAPI()

if not args.userid:
console.print(
Text(
"❌ Error: User ID is required to launch the dashboard!",
style="bold red",
)
)
console.print(
Text(
"Please provide a user ID using the --userid argument or set the ALPHATRION_DASHBOARD_USER_ID environment variable.",
style="yellow",
)
)
console.print(
Text(
"You can create a user and get their ID by running: alphatrion init",
style="cyan",
)
)
return
# Store user ID in app state
app.state.user_id = args.userid

Expand Down
Binary file added file:testdb
Binary file not shown.
Loading