diff --git a/rdagent/app/cli.py b/rdagent/app/cli.py index 4b6536af..85e4f562 100644 --- a/rdagent/app/cli.py +++ b/rdagent/app/cli.py @@ -27,12 +27,18 @@ from rdagent.app.qlib_rd_loop.model import main as fin_model from rdagent.app.qlib_rd_loop.quant import main as fin_quant from rdagent.app.utils.health_check import health_check from rdagent.app.utils.info import collect_info +from rdagent.log.mle_summary import grade_summary -def ui(port=19899, log_dir="", debug=False): +def ui(port=19899, log_dir="", debug=False, data_science=False): """ start web app to show the log traces. """ + if data_science: + with rpath("rdagent.log.ui", "dsapp.py") as app_path: + cmds = ["streamlit", "run", app_path, f"--server.port={port}"] + subprocess.run(cmds) + return with rpath("rdagent.log.ui", "app.py") as app_path: cmds = ["streamlit", "run", app_path, f"--server.port={port}"] if log_dir or debug: @@ -63,6 +69,7 @@ def app(): "health_check": health_check, "collect_info": collect_info, "data_science": data_science, + "grade_summary": grade_summary, "server_ui": server_ui, } ) diff --git a/rdagent/log/mle_summary.py b/rdagent/log/mle_summary.py index 250befa5..16ee56f5 100644 --- a/rdagent/log/mle_summary.py +++ b/rdagent/log/mle_summary.py @@ -43,7 +43,7 @@ def save_grade_info(log_trace_path: Path): print(f"Error in {log_trace_path}: {e}", traceback.format_exc()) -def save_all_grade_info(log_folder): +def save_all_grade_info(log_folder: str | Path) -> None: for log_trace_path in Path(log_folder).iterdir(): if is_valid_session(log_trace_path): try: @@ -72,7 +72,7 @@ def _get_loop_and_fn_after_hours(log_folder: Path, hours: int): return stop_li, stop_fn -def summarize_folder(log_folder: Path, hours: int | None = None): +def summarize_folder(log_folder: Path, hours: int | None = None) -> None: test_eval = get_test_eval() is_mle = isinstance(test_eval, MLETestEval) @@ -242,7 +242,10 @@ def summarize_folder(log_folder: Path, hours: int | None = None): # } -def grade_summary(log_folder): +def grade_summary(log_folder: str | Path) -> None: + """ + Generate test scores for log traces in the log folder and save the summary. + """ log_folder = Path(log_folder) save_all_grade_info(log_folder) summarize_folder(log_folder)