Add SandboxFileSystem.create_file#1698
Open
RitwijParmar wants to merge 1 commit into
Open
Conversation
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
Fixes #1520.
Adds
SandboxFileSystem.create_file()for creating sandbox files directly from in-memory text or bytes. This uses the existing sandbox upload RPC instead of shelling out in the sandbox.The helper keeps writes explicit and safe:
strandbytescontentsoverwrite=Trueinstance.fs.aio.create_file()Checks
sdk/.venv/bin/python -m pytest sdk/tests/test_sandbox_filesystem.py -qsdk/.venv/bin/python -m ruff check sdk/src/beta9/abstractions/sandbox.py sdk/tests/test_sandbox_filesystem.pypython3 -m compileall -q sdk/src/beta9/abstractions/sandbox.py sdk/tests/test_sandbox_filesystem.pygit diff --checkNote: I initially tried
uv runwith the default interpreter, but localuvselected Python 3.14 andpydantic-corein this repo does not build against that PyO3 version. I reran the checks with Python 3.11, which is inside the package support range.Summary by cubic
Add
SandboxFileSystem.create_file()to write files in the sandbox from in-memory text or bytes using the upload RPC. Also addsfs.aio.create_file()and avoids shelling out for simple writes.SandboxFileSystem.create_file()(andfs.aio.create_file()) creates files fromstr/byteswith optional encoding and filemode.parents=True), and refuses to overwrite unlessoverwrite=True.FileExistsErrorfor existing files without overwrite;SandboxFileSystemErrorfor RPC failures; validates paths and contents.Written for commit 372fb24. Summary will update on new commits.