From 92b8d55c2db6884e7883065a9003fc093903f6c2 Mon Sep 17 00:00:00 2001 From: Boxuan Li Date: Mon, 13 Jan 2025 20:32:45 -0800 Subject: [PATCH] Rename `trajectories_path` config to `save_trajectory_path` (#6216) Co-authored-by: Engel Nyst --- config.template.toml | 2 +- .../current/usage/configuration-options.md | 2 +- .../current/usage/configuration-options.md | 2 +- docs/modules/usage/configuration-options.md | 2 +- evaluation/benchmarks/the_agent_company/run_infer.py | 2 +- openhands/core/config/app_config.py | 4 ++-- openhands/core/main.py | 10 +++++----- 7 files changed, 12 insertions(+), 12 deletions(-) diff --git a/config.template.toml b/config.template.toml index de0ebf3a57..8f26eaf92b 100644 --- a/config.template.toml +++ b/config.template.toml @@ -34,7 +34,7 @@ workspace_base = "./workspace" # Path to store trajectories, can be a folder or a file # If it's a folder, the session id will be used as the file name -#trajectories_path="./trajectories" +#save_trajectory_path="./trajectories" # File store path #file_store_path = "/tmp/file_store" diff --git a/docs/i18n/fr/docusaurus-plugin-content-docs/current/usage/configuration-options.md b/docs/i18n/fr/docusaurus-plugin-content-docs/current/usage/configuration-options.md index 36024b2f3c..db275d415a 100644 --- a/docs/i18n/fr/docusaurus-plugin-content-docs/current/usage/configuration-options.md +++ b/docs/i18n/fr/docusaurus-plugin-content-docs/current/usage/configuration-options.md @@ -94,7 +94,7 @@ Les options de configuration de base sont définies dans la section `[core]` du - Description : Désactiver la couleur dans la sortie du terminal **Trajectoires** -- `trajectories_path` +- `save_trajectory_path` - Type : `str` - Valeur par défaut : `"./trajectories"` - Description : Chemin pour stocker les trajectoires (peut être un dossier ou un fichier). Si c'est un dossier, les trajectoires seront enregistrées dans un fichier nommé avec l'ID de session et l'extension .json, dans ce dossier. diff --git a/docs/i18n/zh-Hans/docusaurus-plugin-content-docs/current/usage/configuration-options.md b/docs/i18n/zh-Hans/docusaurus-plugin-content-docs/current/usage/configuration-options.md index 0cff6a5f93..848b85a531 100644 --- a/docs/i18n/zh-Hans/docusaurus-plugin-content-docs/current/usage/configuration-options.md +++ b/docs/i18n/zh-Hans/docusaurus-plugin-content-docs/current/usage/configuration-options.md @@ -91,7 +91,7 @@ - 描述: 禁用终端输出中的颜色 **轨迹** -- `trajectories_path` +- `save_trajectory_path` - 类型: `str` - 默认值: `"./trajectories"` - 描述: 存储轨迹的路径(可以是文件夹或文件)。如果是文件夹,轨迹将保存在该文件夹中以会话 ID 命名的 .json 文件中。 diff --git a/docs/modules/usage/configuration-options.md b/docs/modules/usage/configuration-options.md index cfebdec25a..136d88e431 100644 --- a/docs/modules/usage/configuration-options.md +++ b/docs/modules/usage/configuration-options.md @@ -50,7 +50,7 @@ The core configuration options are defined in the `[core]` section of the `confi - Description: Disable color in terminal output ### Trajectories -- `trajectories_path` +- `save_trajectory_path` - Type: `str` - Default: `"./trajectories"` - Description: Path to store trajectories (can be a folder or a file). If it's a folder, the trajectories will be saved in a file named with the session id name and .json extension, in that folder. diff --git a/evaluation/benchmarks/the_agent_company/run_infer.py b/evaluation/benchmarks/the_agent_company/run_infer.py index 0356191308..a82db6d560 100644 --- a/evaluation/benchmarks/the_agent_company/run_infer.py +++ b/evaluation/benchmarks/the_agent_company/run_infer.py @@ -39,7 +39,7 @@ def get_config( run_as_openhands=False, max_budget_per_task=4, max_iterations=100, - trajectories_path=os.path.join( + save_trajectory_path=os.path.join( mount_path_on_host, f'traj_{task_short_name}.json' ), sandbox=SandboxConfig( diff --git a/openhands/core/config/app_config.py b/openhands/core/config/app_config.py index 2dbb4aeaa8..a59f4fb1b8 100644 --- a/openhands/core/config/app_config.py +++ b/openhands/core/config/app_config.py @@ -27,7 +27,7 @@ class AppConfig: runtime: Runtime environment identifier. file_store: Type of file store to use. file_store_path: Path to the file store. - trajectories_path: Folder path to store trajectories. + save_trajectory_path: Either a folder path to store trajectories with auto-generated filenames, or a designated trajectory file path. workspace_base: Base path for the workspace. Defaults to `./workspace` as absolute path. workspace_mount_path: Path to mount the workspace. Defaults to `workspace_base`. workspace_mount_path_in_sandbox: Path to mount the workspace in sandbox. Defaults to `/workspace`. @@ -54,7 +54,7 @@ class AppConfig: runtime: str = 'docker' file_store: str = 'local' file_store_path: str = '/tmp/openhands_file_store' - trajectories_path: str | None = None + save_trajectory_path: str | None = None workspace_base: str | None = None workspace_mount_path: str | None = None workspace_mount_path_in_sandbox: str = '/workspace' diff --git a/openhands/core/main.py b/openhands/core/main.py index 65e3286483..b27cac1e58 100644 --- a/openhands/core/main.py +++ b/openhands/core/main.py @@ -164,12 +164,12 @@ async def run_controller( state = controller.get_state() # save trajectories if applicable - if config.trajectories_path is not None: - # if trajectories_path is a folder, use session id as file name - if os.path.isdir(config.trajectories_path): - file_path = os.path.join(config.trajectories_path, sid + '.json') + if config.save_trajectory_path is not None: + # if save_trajectory_path is a folder, use session id as file name + if os.path.isdir(config.save_trajectory_path): + file_path = os.path.join(config.save_trajectory_path, sid + '.json') else: - file_path = config.trajectories_path + file_path = config.save_trajectory_path os.makedirs(os.path.dirname(file_path), exist_ok=True) histories = [event_to_trajectory(event) for event in state.history] with open(file_path, 'w') as f: