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:
BillSchumacher
2023-04-26 23:07:28 -05:00
committed by GitHub
parent 65b6c2706e
commit d8c16de123
6 changed files with 52 additions and 9 deletions

View File

@@ -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",