mirror of
https://github.com/aljazceru/Auto-GPT.git
synced 2025-12-23 00:44:22 +01:00
The unlooping and fixing of file execution. (#3368)
* The unlooping and fixing of file execution. * lint * Use static random seed during testing. remove unused import. * Fix bug * Actually fix bug. * lint * Unloop a bit more an fix json. * Fix another bug. * lint. --------- Co-authored-by: merwanehamadi <merwanehamadi@gmail.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
"""Execute code in a Docker container"""
|
||||
import os
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
|
||||
import docker
|
||||
from docker.errors import ImageNotFound
|
||||
@@ -40,7 +41,6 @@ def execute_python_file(filename: str) -> str:
|
||||
|
||||
try:
|
||||
client = docker.from_env()
|
||||
|
||||
# You can replace this with the desired Python image/version
|
||||
# You can find available Python images on Docker Hub:
|
||||
# https://hub.docker.com/_/python
|
||||
@@ -60,10 +60,9 @@ def execute_python_file(filename: str) -> str:
|
||||
print(f"{status}: {progress}")
|
||||
elif status:
|
||||
print(status)
|
||||
|
||||
container = client.containers.run(
|
||||
image_name,
|
||||
f"python {filename}",
|
||||
f"python {Path(filename).relative_to(CFG.workspace_path)}",
|
||||
volumes={
|
||||
CFG.workspace_path: {
|
||||
"bind": "/workspace",
|
||||
|
||||
Reference in New Issue
Block a user