yeq6x commited on
Commit
08d5f7b
·
1 Parent(s): 67b33c8

Refactor refresh functionality in app.py to retrieve checkpoints and scripts together

Browse files

Update the _refresh_all function to collect both checkpoints and scripts from the latest dataset directory, improving the efficiency of the refresh process. Modify the UI button to reflect these changes, enhancing user experience by providing comprehensive access to training resources.

Files changed (1) hide show
  1. app.py +14 -6
app.py CHANGED
@@ -1034,18 +1034,26 @@ def build_ui() -> gr.Blocks:
1034
  outputs=[logs, ckpt_files, scripts_files],
1035
  )
1036
 
1037
- # 回収ボタン: 直近の dataset_ ディレクトリからファイルを再取得
1038
- def _refresh_scripts() -> List[str]:
1039
  try:
1040
  ds_dir = _find_latest_dataset_dir(DATA_ROOT_RUNTIME)
1041
- return _collect_scripts_and_config(ds_dir)
1042
  except Exception:
1043
- return _collect_scripts_and_config(None)
 
 
 
 
 
 
 
 
 
1044
 
1045
  refresh_scripts_btn.click(
1046
- fn=_refresh_scripts,
1047
  inputs=[],
1048
- outputs=[scripts_files],
1049
  )
1050
 
1051
  with gr.TabItem("Prompt Generator"):
 
1034
  outputs=[logs, ckpt_files, scripts_files],
1035
  )
1036
 
1037
+ # 回収ボタン: 直近の dataset_ ディレクトリからチェックポイントとスクリプト/設定を再取得
1038
+ def _refresh_all() -> tuple:
1039
  try:
1040
  ds_dir = _find_latest_dataset_dir(DATA_ROOT_RUNTIME)
 
1041
  except Exception:
1042
+ ds_dir = None
1043
+ try:
1044
+ ck = _list_checkpoints(ds_dir) if ds_dir else []
1045
+ except Exception:
1046
+ ck = []
1047
+ try:
1048
+ sc = _collect_scripts_and_config(ds_dir)
1049
+ except Exception:
1050
+ sc = _collect_scripts_and_config(None)
1051
+ return ck, sc
1052
 
1053
  refresh_scripts_btn.click(
1054
+ fn=_refresh_all,
1055
  inputs=[],
1056
+ outputs=[ckpt_files, scripts_files],
1057
  )
1058
 
1059
  with gr.TabItem("Prompt Generator"):