rydlrKE commited on
Commit
71e925e
·
1 Parent(s): 5f7c735

Add entry/exit debug logs for example dropdown lifecycle

Browse files
Files changed (2) hide show
  1. kimodo/demo/app.py +21 -0
  2. kimodo/demo/ui.py +42 -3
kimodo/demo/app.py CHANGED
@@ -103,6 +103,7 @@ class Demo:
103
  self.floor_len = 20.0 # meters
104
 
105
  def ensure_examples_layout(self) -> None:
 
106
  os.makedirs(EXAMPLES_ROOT_DIR, exist_ok=True)
107
  for model_dir in MODEL_EXAMPLES_DIRS.values():
108
  os.makedirs(model_dir, exist_ok=True)
@@ -120,6 +121,18 @@ class Demo:
120
  if not os.path.exists(dst):
121
  shutil.move(src, dst)
122
 
 
 
 
 
 
 
 
 
 
 
 
 
123
  def get_examples_base_dir(self, model_name: str, absolute: bool = True) -> str:
124
  return MODEL_EXAMPLES_DIRS[model_name]
125
 
@@ -296,6 +309,14 @@ class Demo:
296
  model_name=self.default_model_name,
297
  model_fps=model_bundle.model_fps,
298
  )
 
 
 
 
 
 
 
 
299
  timeline_data = {
300
  "tracks": timeline_tracks,
301
  "tracks_ids": {val["name"]: key for key, val in timeline_tracks.items()},
 
103
  self.floor_len = 20.0 # meters
104
 
105
  def ensure_examples_layout(self) -> None:
106
+ print(f"[kimodo][examples_layout][entry] root={EXAMPLES_ROOT_DIR}")
107
  os.makedirs(EXAMPLES_ROOT_DIR, exist_ok=True)
108
  for model_dir in MODEL_EXAMPLES_DIRS.values():
109
  os.makedirs(model_dir, exist_ok=True)
 
121
  if not os.path.exists(dst):
122
  shutil.move(src, dst)
123
 
124
+ for model_name, model_dir in MODEL_EXAMPLES_DIRS.items():
125
+ model_examples = []
126
+ if os.path.isdir(model_dir):
127
+ model_examples = sorted([d for d in os.listdir(model_dir) if os.path.isdir(os.path.join(model_dir, d))])
128
+ print(
129
+ "[kimodo][examples_layout][model]"
130
+ f" model={model_name} dir={model_dir} count={len(model_examples)}"
131
+ f" has_09={'09_qwen_agentic_actions' in model_examples}"
132
+ f" tail={model_examples[-3:] if len(model_examples) >= 3 else model_examples}"
133
+ )
134
+ print("[kimodo][examples_layout][exit]")
135
+
136
  def get_examples_base_dir(self, model_name: str, absolute: bool = True) -> str:
137
  return MODEL_EXAMPLES_DIRS[model_name]
138
 
 
309
  model_name=self.default_model_name,
310
  model_fps=model_bundle.model_fps,
311
  )
312
+ dropdown_options = list(gui_examples_dropdown.options)
313
+ print(
314
+ "[kimodo][session_setup]"
315
+ f" client={client.client_id} model={self.default_model_name}"
316
+ f" example_dict_count={len(example_dict)} dropdown_count={len(dropdown_options)}"
317
+ f" has_09={'09_qwen_agentic_actions' in dropdown_options}"
318
+ f" tail={dropdown_options[-3:] if len(dropdown_options) >= 3 else dropdown_options}"
319
+ )
320
  timeline_data = {
321
  "tracks": timeline_tracks,
322
  "tracks_ids": {val["name"]: key for key, val in timeline_tracks.items()},
kimodo/demo/ui.py CHANGED
@@ -290,6 +290,12 @@ def create_gui(
290
  example_dict = viser_utils.load_example_cases(examples_base_dir)
291
  example_names = list(example_dict.keys())
292
  example_names.append(QWEN_EXAMPLE_NAME)
 
 
 
 
 
 
293
  gui_examples_dropdown = client.gui.add_dropdown(
294
  "Example",
295
  options=example_names,
@@ -305,12 +311,24 @@ def create_gui(
305
  new_example_dict: dict[str, str],
306
  keep_selection: bool = True,
307
  ) -> None:
 
 
 
 
 
308
  example_names_local = list(new_example_dict.keys())
309
  if QWEN_EXAMPLE_NAME not in example_names_local:
310
  example_names_local.append(QWEN_EXAMPLE_NAME)
311
  if QWEN_EXAMPLE_LEGACY_NAME not in example_names_local:
312
  example_names_local.append(QWEN_EXAMPLE_LEGACY_NAME)
313
  gui_examples_dropdown.options = example_names_local
 
 
 
 
 
 
 
314
  if keep_selection and gui_examples_dropdown.value in example_names_local:
315
  return
316
  gui_examples_dropdown.value = example_names_local[0]
@@ -2269,11 +2287,28 @@ def create_gui(
2269
  if session is None:
2270
  return
2271
 
2272
- if gui_examples_dropdown.value in (QWEN_EXAMPLE_NAME, QWEN_EXAMPLE_LEGACY_NAME):
 
 
 
 
 
 
 
 
 
 
 
 
2273
  load_qwen_example_plan(event_client)
2274
  return
2275
 
2276
- if not session.example_dict or (gui_examples_dropdown.value not in session.example_dict):
 
 
 
 
 
2277
  event_client.add_notification(
2278
  title="No examples available",
2279
  body="No examples found for the selected model.",
@@ -2282,7 +2317,11 @@ def create_gui(
2282
  )
2283
  return
2284
 
2285
- example_path = session.example_dict[gui_examples_dropdown.value]
 
 
 
 
2286
  load_example_from_path(event_client, example_path, gui_load_gt_checkbox.value)
2287
 
2288
  @gui_load_example_from_path_button.on_click
 
290
  example_dict = viser_utils.load_example_cases(examples_base_dir)
291
  example_names = list(example_dict.keys())
292
  example_names.append(QWEN_EXAMPLE_NAME)
293
+ print(
294
+ "[kimodo][examples][init]"
295
+ f" client={client_id} model={model_name} base={examples_base_dir}"
296
+ f" disk_count={len(example_dict)} has_09={QWEN_EXAMPLE_NAME in example_names}"
297
+ f" tail={example_names[-3:] if len(example_names) >= 3 else example_names}"
298
+ )
299
  gui_examples_dropdown = client.gui.add_dropdown(
300
  "Example",
301
  options=example_names,
 
311
  new_example_dict: dict[str, str],
312
  keep_selection: bool = True,
313
  ) -> None:
314
+ print(
315
+ "[kimodo][examples][update][entry]"
316
+ f" client={client_id} model={model_name} keep_selection={keep_selection}"
317
+ f" incoming_count={len(new_example_dict)} current_value={gui_examples_dropdown.value}"
318
+ )
319
  example_names_local = list(new_example_dict.keys())
320
  if QWEN_EXAMPLE_NAME not in example_names_local:
321
  example_names_local.append(QWEN_EXAMPLE_NAME)
322
  if QWEN_EXAMPLE_LEGACY_NAME not in example_names_local:
323
  example_names_local.append(QWEN_EXAMPLE_LEGACY_NAME)
324
  gui_examples_dropdown.options = example_names_local
325
+ print(
326
+ "[kimodo][examples][update][exit]"
327
+ f" client={client_id} model={model_name} count={len(example_names_local)}"
328
+ f" has_09={QWEN_EXAMPLE_NAME in example_names_local}"
329
+ f" has_legacy={QWEN_EXAMPLE_LEGACY_NAME in example_names_local}"
330
+ f" tail={example_names_local[-3:] if len(example_names_local) >= 3 else example_names_local}"
331
+ )
332
  if keep_selection and gui_examples_dropdown.value in example_names_local:
333
  return
334
  gui_examples_dropdown.value = example_names_local[0]
 
2287
  if session is None:
2288
  return
2289
 
2290
+ selected_example = gui_examples_dropdown.value
2291
+ print(
2292
+ "[kimodo][examples][load_click][entry]"
2293
+ f" client={client_id} selected={selected_example}"
2294
+ f" has_09={QWEN_EXAMPLE_NAME in list(gui_examples_dropdown.options)}"
2295
+ f" options_count={len(list(gui_examples_dropdown.options))}"
2296
+ )
2297
+
2298
+ if selected_example in (QWEN_EXAMPLE_NAME, QWEN_EXAMPLE_LEGACY_NAME):
2299
+ print(
2300
+ "[kimodo][examples][load_click][qwen]"
2301
+ f" client={client_id} selected={selected_example}"
2302
+ )
2303
  load_qwen_example_plan(event_client)
2304
  return
2305
 
2306
+ if not session.example_dict or (selected_example not in session.example_dict):
2307
+ print(
2308
+ "[kimodo][examples][load_click][missing]"
2309
+ f" client={client_id} selected={selected_example}"
2310
+ f" session_examples={len(session.example_dict) if session.example_dict else 0}"
2311
+ )
2312
  event_client.add_notification(
2313
  title="No examples available",
2314
  body="No examples found for the selected model.",
 
2317
  )
2318
  return
2319
 
2320
+ example_path = session.example_dict[selected_example]
2321
+ print(
2322
+ "[kimodo][examples][load_click][exit]"
2323
+ f" client={client_id} selected={selected_example} path={example_path}"
2324
+ )
2325
  load_example_from_path(event_client, example_path, gui_load_gt_checkbox.value)
2326
 
2327
  @gui_load_example_from_path_button.on_click