Skip to content

Commit

Permalink
Fix experimental spawn test.
Browse files Browse the repository at this point in the history
  • Loading branch information
danielshaar committed Dec 11, 2024
1 parent 2575b23 commit 695de9e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
7 changes: 7 additions & 0 deletions test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -819,6 +819,13 @@ async def EnvironmentGetOrCreate(self, stream):

### Function

async def FunctionAsyncInvoke(self, stream):
self.fcidx += 1
request: api_pb2.FunctionAsyncInvokeRequest = await stream.recv_message()
function_call_id = f"fc-{self.fcidx}"
self.function_id_for_function_call[function_call_id] = request.function_id
await stream.send_message(api_pb2.FunctionAsyncInvokeResponse(function_call_id=function_call_id))

async def FunctionBindParams(self, stream):
from modal._serialization import deserialize

Expand Down
7 changes: 4 additions & 3 deletions test/function_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

import modal
from modal import App, Image, Mount, NetworkFileSystem, Proxy, asgi_app, batched, web_endpoint
from modal._serialization import deserialize
from modal._utils.async_utils import synchronize_api
from modal._vendor import cloudpickle
from modal.exception import ExecutionError, InvalidError
Expand Down Expand Up @@ -1012,9 +1013,9 @@ def test_experimental_spawn(client, servicer):
with app.run(client=client):
dummy_modal._experimental_spawn(1, 2)

# Verify the correct invocation type is set
function_map = ctx.pop_request("FunctionMap")
assert function_map.function_call_invocation_type == api_pb2.FUNCTION_CALL_INVOCATION_TYPE_ASYNC
# Verify the correct input was passed to the function.
request = ctx.pop_request("FunctionAsyncInvoke")
assert deserialize(request.input.args, client) == ((1, 2), {})


def test_from_name_web_url(servicer, set_env_client):
Expand Down

0 comments on commit 695de9e

Please sign in to comment.