From e2e50dcfd7390dc5364116f1542f1fbb7d391a7f Mon Sep 17 00:00:00 2001 From: Ruslan Kuprieiev Date: Fri, 18 Oct 2024 16:05:44 +0300 Subject: [PATCH] feat(fal): don't scale by default on deploy --- projects/fal/src/fal/api.py | 13 ++++++++++--- projects/fal/src/fal/cli/deploy.py | 6 ++++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/projects/fal/src/fal/api.py b/projects/fal/src/fal/api.py index 1b39d3b1..fa2642d1 100644 --- a/projects/fal/src/fal/api.py +++ b/projects/fal/src/fal/api.py @@ -430,6 +430,7 @@ def register( application_auth_mode: Literal["public", "shared", "private"] | None = None, metadata: dict[str, Any] | None = None, deployment_strategy: Literal["recreate", "rolling"] = "recreate", + scale: bool = False, ) -> str | None: environment_options = options.environment.copy() environment_options.setdefault("python_version", active_python()) @@ -439,15 +440,21 @@ def register( "machine_type", FAL_SERVERLESS_DEFAULT_MACHINE_TYPE ) keep_alive = options.host.get("keep_alive", FAL_SERVERLESS_DEFAULT_KEEP_ALIVE) - max_concurrency = options.host.get("max_concurrency") - min_concurrency = options.host.get("min_concurrency") - max_multiplexing = options.host.get("max_multiplexing") base_image = options.host.get("_base_image", None) scheduler = options.host.get("_scheduler", None) scheduler_options = options.host.get("_scheduler_options", None) exposed_port = options.get_exposed_port() request_timeout = options.host.get("request_timeout") + if scale: + max_concurrency = options.host.get("max_concurrency") + min_concurrency = options.host.get("min_concurrency") + max_multiplexing = options.host.get("max_multiplexing") + else: + max_concurrency = None + min_concurrency = None + max_multiplexing = None + machine_requirements = MachineRequirements( machine_types=machine_type, # type: ignore num_gpus=options.host.get("num_gpus"), diff --git a/projects/fal/src/fal/cli/deploy.py b/projects/fal/src/fal/cli/deploy.py index 4afdb25b..c0519faf 100644 --- a/projects/fal/src/fal/cli/deploy.py +++ b/projects/fal/src/fal/cli/deploy.py @@ -106,6 +106,7 @@ def _deploy_from_reference( application_auth_mode=app_auth, metadata=isolated_function.options.host.get("metadata", {}), deployment_strategy=deployment_strategy, + scale=args.scale, ) if app_id: @@ -219,5 +220,10 @@ def valid_auth_option(option): help="Deployment strategy.", default="recreate", ) + parser.add_argument( + "--scale", + action="store_true", + help="Scale the application.", + ) parser.set_defaults(func=_deploy)