2024-08-08 17:10:37 +08:00
|
|
|
"""
|
|
|
|
|
CLI entrance for all rdagent application.
|
|
|
|
|
|
2025-02-05 10:21:53 +08:00
|
|
|
This will
|
2024-08-08 17:10:37 +08:00
|
|
|
- make rdagent a nice entry and
|
|
|
|
|
- autoamtically load dotenv
|
|
|
|
|
"""
|
2024-10-24 20:38:13 +08:00
|
|
|
|
2024-09-10 19:38:35 +08:00
|
|
|
from dotenv import load_dotenv
|
|
|
|
|
|
|
|
|
|
load_dotenv(".env")
|
|
|
|
|
# 1) Make sure it is at the beginning of the script so that it will load dotenv before initializing BaseSettings.
|
|
|
|
|
# 2) The ".env" argument is necessary to make sure it loads `.env` from the current directory.
|
|
|
|
|
|
2024-08-09 17:23:45 +08:00
|
|
|
import subprocess
|
|
|
|
|
from importlib.resources import path as rpath
|
|
|
|
|
|
2024-08-08 17:10:37 +08:00
|
|
|
import fire
|
|
|
|
|
|
2025-06-18 14:35:45 +08:00
|
|
|
from rdagent.app.data_science.loop import main as data_science
|
2024-08-08 17:10:37 +08:00
|
|
|
from rdagent.app.general_model.general_model import (
|
|
|
|
|
extract_models_and_implement as general_model,
|
|
|
|
|
)
|
|
|
|
|
from rdagent.app.qlib_rd_loop.factor import main as fin_factor
|
|
|
|
|
from rdagent.app.qlib_rd_loop.factor_from_report import main as fin_factor_report
|
|
|
|
|
from rdagent.app.qlib_rd_loop.model import main as fin_model
|
2025-05-29 16:16:51 +08:00
|
|
|
from rdagent.app.qlib_rd_loop.quant import main as fin_quant
|
2024-11-28 15:35:13 +08:00
|
|
|
from rdagent.app.utils.health_check import health_check
|
2024-09-07 12:37:08 +08:00
|
|
|
from rdagent.app.utils.info import collect_info
|
2025-07-11 15:30:24 +08:00
|
|
|
from rdagent.log.mle_summary import grade_summary
|
2024-08-08 17:10:37 +08:00
|
|
|
|
|
|
|
|
|
2025-07-11 15:30:24 +08:00
|
|
|
def ui(port=19899, log_dir="", debug=False, data_science=False):
|
2024-08-09 17:23:45 +08:00
|
|
|
"""
|
|
|
|
|
start web app to show the log traces.
|
|
|
|
|
"""
|
2025-07-11 15:30:24 +08:00
|
|
|
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
|
2024-08-09 17:23:45 +08:00
|
|
|
with rpath("rdagent.log.ui", "app.py") as app_path:
|
2024-08-09 20:40:16 +08:00
|
|
|
cmds = ["streamlit", "run", app_path, f"--server.port={port}"]
|
|
|
|
|
if log_dir or debug:
|
|
|
|
|
cmds.append("--")
|
|
|
|
|
if log_dir:
|
|
|
|
|
cmds.append(f"--log_dir={log_dir}")
|
|
|
|
|
if debug:
|
|
|
|
|
cmds.append("--debug")
|
|
|
|
|
subprocess.run(cmds)
|
2024-08-09 17:23:45 +08:00
|
|
|
|
|
|
|
|
|
2025-06-06 18:52:19 +08:00
|
|
|
def server_ui(port=19899):
|
|
|
|
|
"""
|
|
|
|
|
start web app to show the log traces in real time
|
|
|
|
|
"""
|
|
|
|
|
subprocess.run(["python", "rdagent/log/server/app.py", f"--port={port}"])
|
|
|
|
|
|
|
|
|
|
|
2024-08-08 17:10:37 +08:00
|
|
|
def app():
|
|
|
|
|
fire.Fire(
|
|
|
|
|
{
|
|
|
|
|
"fin_factor": fin_factor,
|
|
|
|
|
"fin_factor_report": fin_factor_report,
|
|
|
|
|
"fin_model": fin_model,
|
2025-05-29 16:16:51 +08:00
|
|
|
"fin_quant": fin_quant,
|
2024-08-08 17:10:37 +08:00
|
|
|
"general_model": general_model,
|
2024-08-09 17:23:45 +08:00
|
|
|
"ui": ui,
|
2024-11-28 15:35:13 +08:00
|
|
|
"health_check": health_check,
|
2024-09-07 12:37:08 +08:00
|
|
|
"collect_info": collect_info,
|
2025-06-18 14:35:45 +08:00
|
|
|
"data_science": data_science,
|
2025-07-11 15:30:24 +08:00
|
|
|
"grade_summary": grade_summary,
|
2025-06-06 18:52:19 +08:00
|
|
|
"server_ui": server_ui,
|
2024-08-08 17:10:37 +08:00
|
|
|
}
|
|
|
|
|
)
|