Repository navigation
fix(sandbox): make DockerSandbox work on Colima and clean up job dirs - #20
Merged
Merged
Conversation
DockerSandbox bind-mounts its job dir into the container, but created it with tempfile.mkdtemp(), which on macOS lands under /var/folders. Colima does not share that path with its VM, so the container saw an empty /work and every run failed with "can't open file '/work/prog.py'". The agent then spent all of its retries on an infrastructure error. Job dirs now go under ~/.cache/dlens/sandbox/, which Colima and Docker Desktop both share by default. DLENS_SANDBOX_DIR overrides it.
Both sandboxes created a job dir with mkdtemp() and never removed it, so every codegen attempt and every test run left a directory behind. Job dirs are now TemporaryDirectory objects, removed when run() returns. Since the output file goes with them, ExecResult now carries the .npy bytes in `output`, replacing `output_path`. validate_output() loads from those bytes. Its checks and messages are unchanged.
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.
What was broken
DockerSandboxcreated its job dir withtempfile.mkdtemp(), which on macOS lands under/var/folders. Colima doesn't share that path with its VM, so the container saw an empty/workand every Docker run failed withcan't open file '/work/prog.py'. The codegen agent then burned all three retries on what was really an infrastructure error. The offline demo usesLocalSandbox, so it never caught this.Separately, neither sandbox ever deleted its job dir, so every attempt and every test run left a folder behind.
What this changes
~/.cache/dlens/sandbox/, which Colima and Docker Desktop both share by default.DLENS_SANDBOX_DIRoverrides it.TemporaryDirectory, removed whenrun()returns.API change: the output file is deleted along with the job dir, so
ExecResult.output_pathis replaced byExecResult.output, which holds the.npyfile's bytes.validate_output()loads from those bytes, and its checks and messages are unchanged. Nothing else in the repo usedoutput_path.Testing
uv run pytest: 124 passed. The 3 new tests cover the job-dir location and the cleanup, and they fail on main.dlens-lenstronomy:latest, lenstronomy 1.9.2). A lenstronomy script rendered and passed validation on the first attempt, and no job dirs were left behind.