Tolulope Ogunremi commited on
Commit
430935f
·
1 Parent(s): 0749314

trying to fix model group tabs

Browse files
Files changed (1) hide show
  1. app.py +12 -12
app.py CHANGED
@@ -1018,11 +1018,11 @@ def create_integrated_gradio_interface(analyzer: MultiModelAnalyzer):
1018
 
1019
  return demo
1020
 
1021
-
1022
  def create_root_interface(output_dir):
1023
  subdirs = get_top_level_dirs(output_dir)
1024
 
1025
- # Store column references
 
1026
  columns = {}
1027
 
1028
  with gr.Blocks() as demo:
@@ -1034,22 +1034,22 @@ def create_root_interface(output_dir):
1034
  label="Model Group"
1035
  )
1036
 
1037
- # Create a separate interface for each analyzer, but hide all except the first
1038
- for idx, subdir in enumerate(subdirs):
1039
- analyzer = load_analyzer_for_subdir(subdir)
1040
-
1041
- with gr.Column(visible=(idx == 0)) as col:
1042
  create_integrated_gradio_interface(analyzer)
1043
-
1044
- columns[subdir.name] = col
1045
 
1046
  def switch_view(selected):
1047
- """Toggle visibility of analyzer columns"""
1048
  updates = []
1049
- for name, col in columns.items():
1050
- updates.append(gr.update(visible=(name == selected)))
 
 
1051
  return updates
1052
 
 
1053
  subdir_dropdown.change(
1054
  fn=switch_view,
1055
  inputs=[subdir_dropdown],
 
1018
 
1019
  return demo
1020
 
 
1021
  def create_root_interface(output_dir):
1022
  subdirs = get_top_level_dirs(output_dir)
1023
 
1024
+ # Pre-load all analyzers
1025
+ analyzers = {d.name: load_analyzer_for_subdir(d) for d in subdirs}
1026
  columns = {}
1027
 
1028
  with gr.Blocks() as demo:
 
1034
  label="Model Group"
1035
  )
1036
 
1037
+ # Create all interfaces upfront
1038
+ for idx, (name, analyzer) in enumerate(analyzers.items()):
1039
+ with gr.Column(visible=(idx == 0), render=True) as col:
 
 
1040
  create_integrated_gradio_interface(analyzer)
1041
+ columns[name] = col
 
1042
 
1043
  def switch_view(selected):
1044
+ """Return visibility updates for each column"""
1045
  updates = []
1046
+ for name in columns.keys():
1047
+ is_visible = (name == selected)
1048
+ print(f"Setting {name} visible={is_visible}") # DEBUG
1049
+ updates.append(gr.update(visible=is_visible))
1050
  return updates
1051
 
1052
+ # Connect the dropdown change event
1053
  subdir_dropdown.change(
1054
  fn=switch_view,
1055
  inputs=[subdir_dropdown],