Skip to content

Commit 2911da5

Browse files
Add method to fix settings file path in task configuration
1 parent 8ce45b8 commit 2911da5

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/agentlab/benchmarks/osworld.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -645,9 +645,25 @@ def model_post_init(self, __context: Any) -> None:
645645
task_file = os.path.join(self.test_set_path, f"examples/{domain}/{task_id}.json")
646646
with open(task_file) as f:
647647
task = json.load(f)
648+
task = self.fix_settings_file_path_in_config(task)
648649
name = f"{self.name}.{task['id']}"
649650
task_env_args = deepcopy(self.env_args)
650651
task_env_args.task = task
651652
task_env_args.task_name = name
652653
self.env_args_list.append(task_env_args)
653654
logger.info(f"Loaded {len(self.env_args_list)} tasks from domain '{self.domain}'")
655+
656+
def fix_settings_file_path_in_config(self, task) -> str:
657+
"""Fix the settings file path in the task configuration.
658+
#TODO: We can create our own tiny_osworld.json with correct paths (OSWorld prefixed) to settings files. Meanwhile use this function to fix the paths.
659+
"""
660+
osworld_repo = os.getenv("OSWORLD_REPO", "OSWorld")
661+
updated_task = deepcopy(task) # Avoid modifying the original task
662+
for config in updated_task["config"]:
663+
if config.get("parameters", False) and config["parameters"].get(
664+
"settings_file", False
665+
):
666+
config["parameters"]["settings_file"] = os.path.join(
667+
osworld_repo, config["parameters"]["settings_file"]
668+
)
669+
return updated_task

0 commit comments

Comments
 (0)