From a758acef2cf12b206d7172b47880dd876f8ad4bc Mon Sep 17 00:00:00 2001 From: Sohrab Saran Date: Mon, 17 Jul 2023 23:54:47 +0530 Subject: [PATCH] Fix `execute_python_file` workspace mount & Windows path formatting (#4996) * fix for #4975 * Add TODO based on code comment. * Use builtin `Path.as_posix()` * Remove TODO --------- Co-authored-by: Reinier van der Leer --- autogpt/commands/execute_code.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/autogpt/commands/execute_code.py b/autogpt/commands/execute_code.py index 2403b2ba..fb4cb70e 100644 --- a/autogpt/commands/execute_code.py +++ b/autogpt/commands/execute_code.py @@ -145,11 +145,14 @@ def execute_python_file(filename: str, agent: Agent) -> str: logger.debug(f"Running {file_path} in a {image_name} container...") container: DockerContainer = client.containers.run( image_name, - ["python", str(file_path.relative_to(agent.workspace.root))], + [ + "python", + file_path.relative_to(agent.workspace.root).as_posix(), + ], volumes={ agent.config.workspace_path: { "bind": "/workspace", - "mode": "ro", + "mode": "rw", } }, working_dir="/workspace",