Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
azliu0 committed Jan 14, 2025
1 parent 7bcf942 commit b6c1176
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
7 changes: 6 additions & 1 deletion modal/sandbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ def _new(
unencrypted_ports: Sequence[int] = [],
proxy: Optional[_Proxy] = None,
_experimental_scheduler_placement: Optional[SchedulerPlacement] = None,
enable_memory_snapshots: bool = False,
) -> "_Sandbox":
"""mdmd:hidden"""

Expand Down Expand Up @@ -178,6 +179,7 @@ async def _load(self: _Sandbox, resolver: Resolver, _existing_object_id: Optiona
open_ports=api_pb2.PortSpecs(ports=open_ports),
network_access=network_access,
proxy_id=(proxy.object_id if proxy else None),
enable_memory_snapshots=enable_memory_snapshots,
)

# Note - `resolver.app_id` will be `None` for app-less sandboxes
Expand Down Expand Up @@ -225,6 +227,8 @@ async def create(
unencrypted_ports: Sequence[int] = [],
# Reference to a Modal Proxy to use in front of this Sandbox.
proxy: Optional[_Proxy] = None,
# Enable memory snapshots.
enable_memory_snapshots: bool = False,
_experimental_scheduler_placement: Optional[
SchedulerPlacement
] = None, # Experimental controls over fine-grained scheduling (alpha).
Expand Down Expand Up @@ -262,6 +266,7 @@ async def create(
unencrypted_ports=unencrypted_ports,
proxy=proxy,
_experimental_scheduler_placement=_experimental_scheduler_placement,
enable_memory_snapshots=enable_memory_snapshots,
)

app_id: Optional[str] = None
Expand Down Expand Up @@ -531,7 +536,7 @@ async def exec(
resp = await retry_transient_errors(self._client.stub.ContainerExec, req)
by_line = bufsize == 1
return _ContainerProcess(resp.exec_id, self._client, stdout=stdout, stderr=stderr, text=text, by_line=by_line)

async def snapshot(self) -> str:
req = api_pb2.SandboxSnapshotRequest(sandbox_id=self.object_id)
resp = await retry_transient_errors(self._client.stub.SandboxSnapshot, req)
Expand Down
3 changes: 3 additions & 0 deletions modal_proto/api.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2180,6 +2180,9 @@ message Sandbox {
NetworkAccess network_access = 22;

optional string proxy_id = 23;

// Enable memory snapshots.
bool enable_memory_snapshots = 24;
}

message SandboxCreateRequest {
Expand Down

0 comments on commit b6c1176

Please sign in to comment.