Skip to content

Commit

Permalink
Send schedule configuration in function definition, not request (#2329)
Browse files Browse the repository at this point in the history
* Send schedule in function definition, not request

* Update mock servicer
  • Loading branch information
mwaskom authored Oct 15, 2024
1 parent 3a5af4e commit 12388fb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion modal/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -843,6 +843,7 @@ async def _load(self: _Function, resolver: Resolver, existing_object_id: Optiona
is_class=info.is_service_class(),
class_parameter_info=info.class_parameter_info(),
i6pn_enabled=i6pn_enabled,
schedule=schedule.proto_message if schedule is not None else None,
_experimental_group_size=group_size or 0, # Experimental: Grouped functions
_experimental_concurrent_cancellations=True,
_experimental_buffer_containers=_experimental_buffer_containers or 0,
Expand All @@ -863,6 +864,7 @@ async def _load(self: _Function, resolver: Resolver, existing_object_id: Optiona
web_url_info=function_definition.web_url_info,
webhook_config=function_definition.webhook_config,
custom_domain_info=function_definition.custom_domain_info,
schedule=schedule.proto_message if schedule is not None else None,
is_class=function_definition.is_class,
class_parameter_info=function_definition.class_parameter_info,
is_method=function_definition.is_method,
Expand Down Expand Up @@ -904,7 +906,6 @@ async def _load(self: _Function, resolver: Resolver, existing_object_id: Optiona
app_id=resolver.app_id,
function=function_definition,
function_data=function_data,
schedule=schedule.proto_message if schedule is not None else None,
existing_function_id=existing_object_id or "",
defer_updates=True,
)
Expand Down
6 changes: 4 additions & 2 deletions test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -870,8 +870,6 @@ async def FunctionCreate(self, stream):
else:
self.n_functions += 1
function_id = f"fu-{self.n_functions}"
if request.schedule:
self.function2schedule[function_id] = request.schedule

function: Optional[api_pb2.Function] = None
function_data: Optional[api_pb2.FunctionData] = None
Expand All @@ -890,8 +888,12 @@ async def FunctionCreate(self, stream):

assert (function is None) != (function_data is None)
function_defn = function or function_data
assert function_defn
self.app_functions[function_id] = function_defn

if function_defn.schedule:
self.function2schedule[function_id] = function_defn.schedule

await stream.send_message(
api_pb2.FunctionCreateResponse(
function_id=function_id,
Expand Down

0 comments on commit 12388fb

Please sign in to comment.