Skip to content

sandbox: dynamic directory mount & snapshot#239

Merged
ehdr merged 14 commits intomainfrom
ehdr/fs/sandbox-subdirectory-snapshot-mount-poc
Dec 19, 2025
Merged

sandbox: dynamic directory mount & snapshot#239
ehdr merged 14 commits intomainfrom
ehdr/fs/sandbox-subdirectory-snapshot-mount-poc

Conversation

@ehdr
Copy link
Contributor

@ehdr ehdr commented Dec 17, 2025

Port of modal-labs/modal-client#3791.

Note that this change is on top of #238.


Note

Introduce experimental APIs to mount Images into Sandbox directories and snapshot them into new Images, with client support, example, and tests.

  • API (experimental):
    • Add Sandbox.experimentalMountImage(path, image?) to mount an Image at a Sandbox filesystem path.
    • Add Sandbox.experimentalSnapshotDirectory(path) to snapshot a mounted directory into a new Image.
  • gRPC client support:
    • Implement taskMountDirectory and taskSnapshotDirectory calls via TaskCommandRouterClientImpl (mountDirectory, snapshotDirectory).
    • Wire up proto messages TaskMountDirectoryRequest and TaskSnapshotDirectoryRequest.
  • Examples:
    • New examples/sandbox-image-mount.ts demonstrating mounting a repo directory and snapshotting it.
  • Tests:
    • Add skipped tests in test/sandbox_mount_image.test.ts covering empty mount, mount with image, snapshotting, and unbuilt image error.
    • Relax timeout threshold in test/sandbox.test.ts (<4000ms).

Written by Cursor Bugbot for commit a65eebd. This will update automatically on new commits. Configure here.

@ehdr ehdr force-pushed the ehdr/fs/sandbox-subdirectory-snapshot-mount-poc branch 4 times, most recently from d85a26d to c3c66c1 Compare December 18, 2025 10:02
@ehdr ehdr force-pushed the ehdr/fs/sandbox-subdirectory-snapshot-mount-poc branch 2 times, most recently from bc627e5 to f19da89 Compare December 18, 2025 10:14
@@ -0,0 +1,53 @@
// This example shows how to use Image mounts and directory snapshots in Sandboxes.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should add that this is an experimental feature only enabled for certain workspaces and people have to contact us if they want to use it for now

const app = await modal.apps.fromName("libmodal-example", {
createIfMissing: true,
});
const baseImage = modal.images.fromRegistry("debian:12-slim");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a comment about /usr/bin/mount needing to exist in the image (for now)

Copy link
Contributor

@freider freider left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor comments

@ehdr
Copy link
Contributor Author

ehdr commented Dec 18, 2025

Thanks, fixed now!

@ehdr
Copy link
Contributor Author

ehdr commented Dec 18, 2025

Tests fail because the feature is not yet enabled in our main workspace.

Base automatically changed from ehdr/sb-direct-exec to main December 19, 2025 13:41
@ehdr ehdr force-pushed the ehdr/fs/sandbox-subdirectory-snapshot-mount-poc branch from 6a77328 to ccf96a8 Compare December 19, 2025 13:42
* @alpha
* @param path - The path where the directory should be mounted
* @param image - Optional {@link Image} to mount. If undefined, mounts an empty directory.
*/
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Missing /usr/bin/mount requirement in API documentation (Bugbot Rules)

Per the PR discussion, @freider requested adding a comment about /usr/bin/mount needing to exist in the image. While this requirement is documented in the example file (line 26), the JSDoc for experimentalMountImage does not mention this critical prerequisite. Users calling this API directly without seeing the example would not know their base image needs /usr/bin/mount available.

Fix in Cursor Fix in Web

@ehdr ehdr merged commit a2d11ac into main Dec 19, 2025
6 checks passed
@ehdr ehdr deleted the ehdr/fs/sandbox-subdirectory-snapshot-mount-poc branch December 19, 2025 14:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants