mirror of
https://github.com/NicolasBohn/NexQuant.git
synced 2026-07-27 15:37:44 +00:00
feat: add enable_cache toggle for UI data caching (#1075)
This commit is contained in:
@@ -18,5 +18,7 @@ class UIBasePropSetting(ExtendedBaseSettings):
|
||||
|
||||
trace_folder: str = "./traces"
|
||||
|
||||
enable_cache: bool = True
|
||||
|
||||
|
||||
UI_SETTING = UIBasePropSetting()
|
||||
|
||||
@@ -14,6 +14,7 @@ from streamlit import session_state as state
|
||||
|
||||
from rdagent.app.data_science.loop import DataScienceRDLoop
|
||||
from rdagent.log.storage import FileStorage
|
||||
from rdagent.log.ui.conf import UI_SETTING
|
||||
from rdagent.log.ui.utils import curve_figure, load_times, trace_figure
|
||||
from rdagent.log.utils import (
|
||||
LogColors,
|
||||
@@ -45,7 +46,6 @@ def convert_defaultdict_to_dict(d):
|
||||
return d
|
||||
|
||||
|
||||
@st.cache_data(persist=True)
|
||||
def load_data(log_path: Path):
|
||||
data = defaultdict(lambda: defaultdict(dict))
|
||||
llm_data = defaultdict(lambda: defaultdict(lambda: defaultdict(list)))
|
||||
@@ -132,6 +132,10 @@ def load_data(log_path: Path):
|
||||
)
|
||||
|
||||
|
||||
if UI_SETTING.enable_cache:
|
||||
load_data = st.cache_data(persist=True)(load_data)
|
||||
|
||||
|
||||
def load_stdout(stdout_path: Path):
|
||||
if stdout_path.exists():
|
||||
stdout = stdout_path.read_text()
|
||||
|
||||
@@ -8,6 +8,7 @@ from pathlib import Path
|
||||
import streamlit as st
|
||||
from streamlit import session_state
|
||||
|
||||
from rdagent.log.ui.conf import UI_SETTING
|
||||
from rdagent.log.utils import extract_evoid, extract_loopid_func_name
|
||||
|
||||
st.set_page_config(layout="wide", page_title="debug_llm", page_icon="🎓", initial_sidebar_state="expanded")
|
||||
@@ -18,7 +19,6 @@ parser.add_argument("--log_dir", type=str, help="Path to the log directory")
|
||||
args = parser.parse_args()
|
||||
|
||||
|
||||
@st.cache_data
|
||||
def get_folders_sorted(log_path):
|
||||
"""缓存并返回排序后的文件夹列表,并加入进度打印"""
|
||||
with st.spinner("正在加载文件夹列表..."):
|
||||
@@ -31,6 +31,10 @@ def get_folders_sorted(log_path):
|
||||
return [folder.name for folder in folders]
|
||||
|
||||
|
||||
if UI_SETTING.enable_cache:
|
||||
get_folders_sorted = st.cache_data(get_folders_sorted)
|
||||
|
||||
|
||||
# 设置主日志路径
|
||||
main_log_path = Path(args.log_dir) if args.log_dir else Path("./log")
|
||||
if not main_log_path.exists():
|
||||
|
||||
Reference in New Issue
Block a user