Skip to content

Commit c9cd01a

Browse files
Replace DockerExecutor Dockerfile with file object (#1738)
1 parent 8c28f22 commit c9cd01a

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

src/smolagents/remote_executors.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import time
2727
from contextlib import closing
2828
from io import BytesIO
29-
from pathlib import Path
3029
from textwrap import dedent
3130
from typing import Any, Optional
3231

@@ -410,13 +409,8 @@ def __init__(
410409

411410
if build_new_image:
412411
self.logger.log(f"Building Docker image {self.image_name}...", level=LogLevel.INFO)
413-
dockerfile_path = Path(__file__).parent / "Dockerfile"
414-
if not dockerfile_path.exists():
415-
with open(dockerfile_path, "w") as f:
416-
f.write(self.dockerfile_content)
417-
_, build_logs = self.client.images.build(
418-
path=str(dockerfile_path.parent), dockerfile=str(dockerfile_path), tag=self.image_name
419-
)
412+
dockerfile_obj = BytesIO(self.dockerfile_content.encode("utf-8"))
413+
_, build_logs = self.client.images.build(fileobj=dockerfile_obj, tag=self.image_name)
420414
for log_chunk in build_logs:
421415
# Only log non-empty messages
422416
if log_message := log_chunk.get("stream", "").rstrip():

0 commit comments

Comments
 (0)