99def get_projects ():
1010 if not os .path .exists (TRACKIO_DIR ):
1111 return []
12- return [
12+ projects = sorted ( [
1313 d
1414 for d in os .listdir (TRACKIO_DIR )
1515 if os .path .isdir (os .path .join (TRACKIO_DIR , d ))
16- ]
16+ ])
17+ return gr .Dropdown (label = "Project" , choices = projects , value = projects [0 ] if projects else None )
1718
1819
1920def get_runs (project ):
@@ -38,25 +39,48 @@ def load_run_data(project, run):
3839
3940
4041def update_runs (project ):
41- runs = get_runs (project )
42+ if project is None :
43+ runs = []
44+ else :
45+ runs = get_runs (project )
4246 return gr .Dropdown (choices = runs , value = runs )
4347
4448
49+ def toggle_timer (cb_value ):
50+ if cb_value :
51+ return gr .Timer (active = True )
52+ else :
53+ return gr .Timer (active = False )
54+
55+
4556def launch_ui ():
4657 with gr .Blocks (theme = "citrus" ) as demo :
4758 with gr .Sidebar ():
4859 gr .Markdown ("# 🎯 Trackio Dashboard" )
49- project_dd = gr .Dropdown (label = "Project" , choices = get_projects ())
60+ project_dd = gr .Dropdown (label = "Project" )
61+ realtime_cb = gr .Checkbox (label = "Realtime" , value = True )
5062 with gr .Row ():
5163 run_dd = gr .Dropdown (label = "Run" , choices = [], multiselect = True )
5264
5365 timer = gr .Timer (value = 1 )
5466
5567 gr .on (
56- [demo .load , project_dd .change ],
68+ [demo .load , timer .tick ],
69+ fn = get_projects ,
70+ outputs = project_dd ,
71+ show_progress = False ,
72+ )
73+ gr .on (
74+ [demo .load , project_dd .change , timer .tick ],
5775 fn = update_runs ,
5876 inputs = project_dd ,
5977 outputs = run_dd ,
78+ show_progress = False ,
79+ )
80+ realtime_cb .change (
81+ fn = toggle_timer ,
82+ inputs = realtime_cb ,
83+ outputs = timer ,
6084 )
6185
6286 @gr .render (
0 commit comments