Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
aksh-at committed Sep 6, 2024
1 parent 3c0b077 commit f2f4fea
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
3 changes: 1 addition & 2 deletions modal/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ def foo():
"""

_all_apps: ClassVar[Dict[Optional[str], List["_App"]]] = {}
_container_app: ClassVar[Optional[RunningApp]] = None

_name: Optional[str]
_description: Optional[str]
Expand All @@ -141,8 +142,6 @@ def foo():
_running_app: Optional[RunningApp] # Various app info
_client: Optional[_Client]

_container_app: ClassVar[Optional[RunningApp]] = None

def __init__(
self,
name: Optional[str] = None,
Expand Down
2 changes: 2 additions & 0 deletions test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ def __init__(self, blob_host, blobs):
self.volume_reloads: Dict[str, int] = defaultdict(lambda: 0)

self.sandbox_defs = []
self.sandbox_app_id = None
self.sandbox: asyncio.subprocess.Process = None
self.sandbox_result: Optional[api_pb2.GenericResult] = None

Expand Down Expand Up @@ -1181,6 +1182,7 @@ async def SandboxCreate(self, stream):
stdin=asyncio.subprocess.PIPE,
)

self.sandbox_app_id = request.app_id
self.sandbox_defs.append(request.definition)

await stream.send_message(api_pb2.SandboxCreateResponse(sandbox_id="sb-123"))
Expand Down
6 changes: 6 additions & 0 deletions test/container_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2065,3 +2065,9 @@ def test_max_concurrency(servicer):

outputs = [deserialize(item.result.data, ret.client) for item in ret.items]
assert n_inputs in outputs


@skip_github_non_linux
def test_sandbox_infers_app(servicer, event_loop):
_run_container(servicer, "test.supports.sandbox", "spawn_sandbox")
assert servicer.sandbox_app_id == "ap-1"
8 changes: 8 additions & 0 deletions test/supports/sandbox.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import modal

app = modal.App()


@app.function()
def spawn_sandbox(x):
modal.Sandbox.create("bash", "-c", "echo bar")

0 comments on commit f2f4fea

Please sign in to comment.