diff --git a/README.md b/README.md index 408d5c821..c38d818c5 100644 --- a/README.md +++ b/README.md @@ -72,9 +72,9 @@ You can try our demo by running the following command: - The `.env.example` file contains the environment variables required for users using the OpenAI API (Please note that `.env.example` is an example file. `.env` is the one that will be finally used.) - please refer to [Configuration](docs/build/html/installation.html#azure-openai) for the detailed explanation of the `.env` ### 🚀 Run the Application -- Start streamlit web app to show log traces: +- Start web app to show log traces: ```sh - streamlit run rdagent/log/ui/app.py --server.port 8080 -- --log_dir + rdagent ui --port 80 --log_dir ``` The [🎥demo](https://rdagent.azurewebsites.net) is implemented by the following commands: @@ -108,7 +108,7 @@ The [🎥demo](https://rdagent.azurewebsites.net) is implemented by the followin ### 🚀 Monitor the Application - You can serve our demo app to monitor the RD loop by running the following command: ```sh - streamlit run rdagent/log/ui/app.py --server.port 8080 -- --log_dir + rdagent ui --port 80 --log_dir ``` # Scenarios diff --git a/docs/ui.rst b/docs/ui.rst index 0677c9ad6..22ca3bb1c 100644 --- a/docs/ui.rst +++ b/docs/ui.rst @@ -18,7 +18,7 @@ In `RD-Agent/` folder, run: .. code-block:: bash - streamlit run rdagent/log/ui/app.py --server.port -- --log_dir + rdagent ui --port --log_dir This will start a web app on `http://localhost:`. diff --git a/rdagent/app/cli.py b/rdagent/app/cli.py index b2d642caf..9894321f6 100644 --- a/rdagent/app/cli.py +++ b/rdagent/app/cli.py @@ -5,6 +5,9 @@ - make rdagent a nice entry and - autoamtically load dotenv """ +import subprocess +from importlib.resources import path as rpath + import fire from dotenv import load_dotenv @@ -19,6 +22,14 @@ load_dotenv() +def ui(port=80, log_dir="./log"): + """ + start web app to show the log traces. + """ + with rpath("rdagent.log.ui", "app.py") as app_path: + subprocess.run(["streamlit", "run", app_path, f"--server.port={port}", "--", f"--log_dir={log_dir}"]) + + def app(): fire.Fire( { @@ -27,5 +38,6 @@ def app(): "fin_model": fin_model, "med_model": med_model, "general_model": general_model, + "ui": ui, } ) diff --git a/rdagent/log/ui/app.py b/rdagent/log/ui/app.py index 83e2e4722..d4457af04 100644 --- a/rdagent/log/ui/app.py +++ b/rdagent/log/ui/app.py @@ -2,6 +2,7 @@ import textwrap from collections import defaultdict from datetime import datetime, timezone +from importlib.resources import files as rfiles from pathlib import Path from typing import Callable, Type @@ -526,7 +527,8 @@ def tasks_window(tasks: list[FactorTask | ModelTask]): with st.container(): image_c, scen_c = st.columns([3, 3], vertical_alignment="center") with image_c: - st.image("./docs/_static/flow.png") + img_path = rfiles("rdagent.log.ui").joinpath("flow.png") + st.image(str(img_path), use_column_width=True) with scen_c: st.header("Scenario Description📖", divider="violet", anchor="_scenario") # TODO: other scenarios diff --git a/docs/_static/flow.png b/rdagent/log/ui/flow.png similarity index 100% rename from docs/_static/flow.png rename to rdagent/log/ui/flow.png