Skip to content

Commit

Permalink
feat(cli): scale --request-timeout and --startup-timeout (#417)
Browse files Browse the repository at this point in the history
* feat(cli): scale --request-timeout and --startup-timeout

* feat(fal): show machine-type and request/startup timeouts
  • Loading branch information
efiop authored Feb 13, 2025
1 parent b217c98 commit 46fde2c
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 1 deletion.
2 changes: 1 addition & 1 deletion projects/fal/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ readme = "README.md"
requires-python = ">=3.8"
dependencies = [
"isolate[build]>=0.15.0,<0.16.0",
"isolate-proto>=0.6.4,<0.7.0",
"isolate-proto>=0.6.6,<0.7.0",
"grpcio==1.64.0",
"dill==0.3.7",
"cloudpickle==3.0.0",
Expand Down
26 changes: 26 additions & 0 deletions projects/fal/src/fal/cli/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ def _apps_table(apps: list[AliasInfo]):
table.add_column("Max Concurrency")
table.add_column("Max Multiplexing")
table.add_column("Keep Alive")
table.add_column("Request Timeout")
table.add_column("Startup Timeout")
table.add_column("Machine Type")
table.add_column("Active Workers")

for app in apps:
Expand All @@ -30,6 +33,9 @@ def _apps_table(apps: list[AliasInfo]):
str(app.max_concurrency),
str(app.max_multiplexing),
str(app.keep_alive),
str(app.request_timeout),
str(app.startup_timeout),
" ".join(app.machine_types),
str(app.active_runners),
)

Expand Down Expand Up @@ -67,6 +73,9 @@ def _app_rev_table(revs: list[ApplicationInfo]):
table.add_column("Max Concurrency")
table.add_column("Max Multiplexing")
table.add_column("Keep Alive")
table.add_column("Request Timeout")
table.add_column("Startup Timeout")
table.add_column("Machine Type")
table.add_column("Active Workers")

for rev in revs:
Expand All @@ -76,6 +85,9 @@ def _app_rev_table(revs: list[ApplicationInfo]):
str(rev.max_concurrency),
str(rev.max_multiplexing),
str(rev.keep_alive),
str(rev.request_timeout),
str(rev.startup_timeout),
" ".join(rev.machine_types),
str(rev.active_runners),
)

Expand Down Expand Up @@ -114,6 +126,8 @@ def _scale(args):
and args.max_multiplexing is None
and args.max_concurrency is None
and args.min_concurrency is None
and args.request_timeout is None
and args.startup_timeout is None
):
args.console.log("No parameters for update were provided, ignoring.")
return
Expand All @@ -124,6 +138,8 @@ def _scale(args):
max_multiplexing=args.max_multiplexing,
max_concurrency=args.max_concurrency,
min_concurrency=args.min_concurrency,
request_timeout=args.request_timeout,
startup_timeout=args.startup_timeout,
)
table = _apps_table([alias_info])

Expand Down Expand Up @@ -162,6 +178,16 @@ def _add_scale_parser(subparsers, parents):
type=int,
help="Minimum concurrency",
)
parser.add_argument(
"--request-timeout",
type=int,
help="Request timeout (seconds).",
)
parser.add_argument(
"--startup-timeout",
type=int,
help="Startup timeout (seconds).",
)
parser.set_defaults(func=_scale)


Expand Down
16 changes: 16 additions & 0 deletions projects/fal/src/fal/sdk.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,9 @@ class ApplicationInfo:
max_multiplexing: int
active_runners: int
min_concurrency: int
machine_types: list[str]
request_timeout: int
startup_timeout: int


@dataclass
Expand All @@ -208,6 +211,9 @@ class AliasInfo:
max_multiplexing: int
active_runners: int
min_concurrency: int
machine_types: list[str]
request_timeout: int
startup_timeout: int


@dataclass
Expand Down Expand Up @@ -313,6 +319,9 @@ def _from_grpc_application_info(
max_multiplexing=message.max_multiplexing,
active_runners=message.active_runners,
min_concurrency=message.min_concurrency,
machine_types=message.machine_types,
request_timeout=message.request_timeout,
startup_timeout=message.startup_timeout,
)


Expand All @@ -336,6 +345,9 @@ def _from_grpc_alias_info(message: isolate_proto.AliasInfo) -> AliasInfo:
max_multiplexing=message.max_multiplexing,
active_runners=message.active_runners,
min_concurrency=message.min_concurrency,
machine_types=message.machine_types,
request_timeout=message.request_timeout,
startup_timeout=message.startup_timeout,
)


Expand Down Expand Up @@ -564,13 +576,17 @@ def update_application(
max_multiplexing: int | None = None,
max_concurrency: int | None = None,
min_concurrency: int | None = None,
request_timeout: int | None = None,
startup_timeout: int | None = None,
) -> AliasInfo:
request = isolate_proto.UpdateApplicationRequest(
application_name=application_name,
keep_alive=keep_alive,
max_multiplexing=max_multiplexing,
max_concurrency=max_concurrency,
min_concurrency=min_concurrency,
request_timeout=request_timeout,
startup_timeout=startup_timeout,
)
res: isolate_proto.UpdateApplicationResult = self.stub.UpdateApplication(
request
Expand Down

0 comments on commit 46fde2c

Please sign in to comment.