feat: add a web UI server (#1345)

* update rdagent cmd

* fix log error message

* use multiProcessing.Process instead of subprocess.Popen

* add traces to gitignore

* add user interactor in RDLoop (finance scenarios)

* add interactor (feedback, hypothesis) for quant scens

* fix the test_end in qlib conf

* add features init config, general instruction to qlib scenarios

* set base features for based exp

* fix bug when combine factors

* move traces folder to git_ignore_folder

* fix bug in features init

* fix quant interact bug

* fix logger warning error

* bug fixes

* modify rdagent logger, now it can set file output

* adjust cli functions and fix logger bug

* fix server port transport problem

* update server_ui in cli

* add web code

* fix CI problem

* black fix

* update web ui README

* update README

* update readme
This commit is contained in:
XianBW
2026-03-18 14:04:52 +08:00
committed by GitHub
parent 7cd64a26fd
commit 14395488b9
141 changed files with 12852 additions and 279 deletions
+127 -11
View File
@@ -16,10 +16,13 @@ load_dotenv(".env")
import subprocess
from importlib.resources import path as rpath
from typing import Optional
import typer
from typing_extensions import Annotated
from rdagent.app.data_science.loop import main as data_science
from rdagent.app.finetune.llm.loop import main as llm_finetune
from rdagent.app.general_model.general_model import (
extract_models_and_implement as general_model,
)
@@ -33,6 +36,11 @@ from rdagent.log.mle_summary import grade_summary as grade_summary
app = typer.Typer()
CheckoutOption = Annotated[bool, typer.Option("--checkout/--no-checkout", "-c/-C")]
CheckEnvOption = Annotated[bool, typer.Option("--check-env/--no-check-env", "-e/-E")]
CheckDockerOption = Annotated[bool, typer.Option("--check-docker/--no-check-docker", "-d/-D")]
CheckPortsOption = Annotated[bool, typer.Option("--check-ports/--no-check-ports", "-p/-P")]
def ui(port=19899, log_dir="", debug: bool = False, data_science: bool = False):
"""
@@ -56,9 +64,11 @@ def ui(port=19899, log_dir="", debug: bool = False, data_science: bool = False):
def server_ui(port=19899):
"""
start web app to show the log traces in real time
start the Flask log server in real time
"""
subprocess.run(["python", "rdagent/log/server/app.py", f"--port={port}"])
from rdagent.log.server.app import main as log_server_main
log_server_main(port=port)
def ds_user_interact(port=19900):
@@ -69,17 +79,123 @@ def ds_user_interact(port=19900):
subprocess.run(commands)
app.command(name="fin_factor")(fin_factor)
app.command(name="fin_model")(fin_model)
app.command(name="fin_quant")(fin_quant)
app.command(name="fin_factor_report")(fin_factor_report)
app.command(name="general_model")(general_model)
app.command(name="data_science")(data_science)
app.command(name="grade_summary")(grade_summary)
@app.command(name="fin_factor")
def fin_factor_cli(
path: Optional[str] = None,
step_n: Optional[int] = None,
loop_n: Optional[int] = None,
all_duration: Optional[str] = None,
checkout: CheckoutOption = True,
):
fin_factor(path=path, step_n=step_n, loop_n=loop_n, all_duration=all_duration, checkout=checkout)
@app.command(name="fin_model")
def fin_model_cli(
path: Optional[str] = None,
step_n: Optional[int] = None,
loop_n: Optional[int] = None,
all_duration: Optional[str] = None,
checkout: CheckoutOption = True,
):
fin_model(path=path, step_n=step_n, loop_n=loop_n, all_duration=all_duration, checkout=checkout)
@app.command(name="fin_quant")
def fin_quant_cli(
path: Optional[str] = None,
step_n: Optional[int] = None,
loop_n: Optional[int] = None,
all_duration: Optional[str] = None,
checkout: CheckoutOption = True,
):
fin_quant(path=path, step_n=step_n, loop_n=loop_n, all_duration=all_duration, checkout=checkout)
@app.command(name="fin_factor_report")
def fin_factor_report_cli(
report_folder: Optional[str] = None,
path: Optional[str] = None,
all_duration: Optional[str] = None,
checkout: CheckoutOption = True,
):
fin_factor_report(report_folder=report_folder, path=path, all_duration=all_duration, checkout=checkout)
@app.command(name="general_model")
def general_model_cli(report_file_path: str):
general_model(report_file_path)
@app.command(name="data_science")
def data_science_cli(
path: Optional[str] = None,
checkout: CheckoutOption = True,
step_n: Optional[int] = None,
loop_n: Optional[int] = None,
timeout: Optional[str] = None,
competition: Optional[str] = None,
):
data_science(
path=path,
checkout=checkout,
step_n=step_n,
loop_n=loop_n,
timeout=timeout,
competition=competition,
)
@app.command(name="llm_finetune")
def llm_finetune_cli(
path: Optional[str] = None,
checkout: CheckoutOption = True,
benchmark: Optional[str] = None,
benchmark_description: Optional[str] = None,
dataset: Optional[str] = None,
base_model: Optional[str] = None,
upper_data_size_limit: Optional[int] = None,
step_n: Optional[int] = None,
loop_n: Optional[int] = None,
timeout: Optional[str] = None,
):
llm_finetune(
path=path,
checkout=checkout,
benchmark=benchmark,
benchmark_description=benchmark_description,
dataset=dataset,
base_model=base_model,
upper_data_size_limit=upper_data_size_limit,
step_n=step_n,
loop_n=loop_n,
timeout=timeout,
)
@app.command(name="grade_summary")
def grade_summary_cli(log_folder: str):
grade_summary(log_folder)
app.command(name="ui")(ui)
app.command(name="server_ui")(server_ui)
app.command(name="health_check")(health_check)
app.command(name="collect_info")(collect_info)
@app.command(name="health_check")
def health_check_cli(
check_env: CheckEnvOption = True,
check_docker: CheckDockerOption = True,
check_ports: CheckPortsOption = True,
):
health_check(check_env=check_env, check_docker=check_docker, check_ports=check_ports)
@app.command(name="collect_info")
def collect_info_cli():
collect_info()
app.command(name="ds_user_interact")(ds_user_interact)