Skip to content

Commit 5e08117

Browse files
committed
remove containers after finishing
1 parent b1dd1e3 commit 5e08117

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

src/datasmith/agents/context_synthesis.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
import docker
1111
import dspy
12+
from docker.errors import NotFound
1213

1314
from datasmith.agents.tool_executor import ContainerToolExecutor
1415
from datasmith.docker.context import BuildResult, ContextRegistry, DockerContext
@@ -604,3 +605,14 @@ def agent_build_and_validate( # noqa: C901
604605
}
605606
finally:
606607
tool_exec.shutdown()
608+
# remove any containers that were built.
609+
try:
610+
cont = client.containers.get(task.with_tag("env").get_container_name())
611+
cont.remove(force=True)
612+
except NotFound:
613+
pass
614+
try:
615+
cont = client.containers.get(task.with_tag("pkg").get_container_name())
616+
cont.remove(force=True)
617+
except NotFound:
618+
pass

0 commit comments

Comments
 (0)