Repository navigation
feat(run-docker-container): run a docker_image artifact without building - #574
Merged
Merged
Conversation
run_docker_container always staged a build context and ran docker build, even for an image that already existed, so a task run many times paid a build per run. It now also takes image_artifact_id / image_artifact_version, a docker_image artifact it runs as it is: the image is put on the sandbox with load_docker_images, as install_agent puts an agent's there, and started with nothing staged or built. On the local sandbox a context-only image is built once per sources and kept across runs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Comment on lines
+61
to
+69
| first = CliRunner().invoke(cli, ["run", str(root)]) | ||
|
|
||
| assert first.exit_code == 0 and "tasks/grade.json v1: passed" in first.output, first.output | ||
| assert len(builds) == 1, (first.output, builds) | ||
|
|
||
| again = CliRunner().invoke(cli, ["run", str(root)]) | ||
|
|
||
| assert again.exit_code == 0 and "tasks/grade.json v1: passed" in again.output, again.output | ||
| assert "building with docker" not in again.output and len(builds) == 1, (again.output, builds) |
There was a problem hiding this comment.
This test leaves its Docker image behind. Its temporary bundle gets a new image name on each test run, and sandbox teardown deliberately keeps that image. Add a finally block that removes it after the reuse assertions, including when an assertion fails, so repeated test runs do not fill Docker storage.
Prompt To Fix With AI
This is a comment left during a code review.
Path: tst/integration/cli/run_bundle_task_image_test.py
Line: 61-69
Comment:
**Test images accumulate**
This test leaves its Docker image behind. Its temporary bundle gets a new image name on each test run, and sandbox teardown deliberately keeps that image. Add a `finally` block that removes it after the reuse assertions, including when an assertion fails, so repeated test runs do not fill Docker storage.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.
Collaborator
Author
There was a problem hiding this comment.
Agreed. This PR is merged, so the cleanup (removing the image in a finally) goes into the next PR.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
run_docker_containeralways staged a build context and randocker build, even when the image already existed. A task run many times, for example as RL episodes, paid a build for every episode. Pre-building a base and having each episode build onlyFROM <base>still means a build per episode, and under load that was 214 s for 16 episodes.run_docker_containernow also takesimage_artifact_id/image_artifact_version: adocker_imageartifact whose image it runs as it is. A step names exactly one of that,docker_context_artifact_idanddocker_context_url.load_docker_images, asinstall_agentputs an agent's image there. It's pulled by digest, loaded from a tar.gz, or built from its build context, only where the sandbox doesn't already hold it. Thendocker runstarts it, with nothing staged and nothing built.host_images.buildreturns when this machine holds one built from the same sources). Later runs only inspect it, and a sandbox's teardown leaves it, since it doesn't carry the sandbox's label.artifacts/task-image/with a Dockerfile, orref = "<image>"in itsartifact.toml.image_tagandbuild_argsonly apply to a build, so beside an image artifact they're a config problem, not silently ignored.Tests
tst/unit/task_step/run_docker_container_test.py: the fields round-trip, two sources are refused, build options beside an image are a config problem, and a run loads the image and starts it with nothing staged or built.tst/integration/task_step/test_run_docker_container_local.py: two runs of one context-only image artifact on the local sandbox. The first builds it, the second builds nothing, and teardown leaves the image.tst/integration/cli/run_bundle_task_image_test.py(slow tier):agent-env runof a bundle task whose container comes from an image folder and is graded through a reward file. The first run builds once, and a rerun builds nothing.run_docker_containerintegration tests and the bundle test pass (5).make unit-testpasses apart from two MCP CLI codegen tests that also fail onmainon that box; 14,164 passed, 9 skipped.ruff checkis clean.🤖 Generated with Claude Code
The PR appears safe to merge, with a non-blocking cleanup issue in the new bundle test.
Fix with agent prompt
Summary
run_docker_containercan now load adocker_imageartifact instead of staging and building a context.Diagram
%%{init: {'theme': 'neutral'}}%% flowchart TD Source{Container source} -->|Image artifact| Load[Load image through sandbox] Source -->|Context artifact or URL| Build[Stage context and build image] Load --> Run[Start labelled container] Build --> Run Run --> Record[Record container in task context]Reviews (1) · Last reviewed commit: "feat(run-docker-container): run a docker..." · Reviewed by Greptile