Skip to content

Commit

Permalink
Fix lifecycle-spec in SchedulerPlacement (#1400)
Browse files Browse the repository at this point in the history
Forgot that proto3 does not support optional booleans, despite it's
proto2-compatible syntax, so represent the requested lifecycle using a
(nullable) string instead.
  • Loading branch information
irfansharif committed Feb 22, 2024
1 parent 738a254 commit b416092
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
6 changes: 5 additions & 1 deletion modal/scheduler_placement.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,12 @@ def __init__(
spot: Optional[bool] = None,
):
"""mdmd:hidden"""
_lifecycle: Optional[str] = None
if spot is not None:
_lifecycle = "spot" if spot else "on-demand"

self.proto = api_pb2.SchedulerPlacement(
_region=region,
_zone=zone,
_spot=spot,
_lifecycle=_lifecycle,
)
2 changes: 1 addition & 1 deletion modal_proto/api.proto
Original file line number Diff line number Diff line change
Expand Up @@ -848,7 +848,7 @@ message SchedulerPlacement {
// GPU types.
optional string _region = 1;
optional string _zone = 2;
optional bool _spot = 3;
optional string _lifecycle = 3; // "on-demand" or "spot", else ignored
}

message FunctionHandleMetadata {
Expand Down
2 changes: 1 addition & 1 deletion test/scheduler_placement_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ def test_scheduler_placement(servicer, client):
assert fn._experimental_scheduler_placement == api_pb2.SchedulerPlacement(
_region="us-east-1",
_zone="us-east-1a",
_spot=False,
_lifecycle="on-demand",
)

0 comments on commit b416092

Please sign in to comment.