AppDeployer(
name: Optional[str] = None,
port: Optional[int] = None,
description: Optional[str] = None,
app_type: Optional[str] = None,
image: Optional[str] = None,
tags: Optional[list] = None,
secrets: Optional[list] = None,
compute_pools: Optional[list] = None,
environment: Optional[dict] = None,
commands: Optional[list] = None,
resources: Optional[ResourceConfigDict] = None,
auth: Optional[AuthConfigDict] = None,
replicas: Optional[ReplicaConfigDict] = None,
code_package: Optional[tuple] = None,
force_upgrade: Optional[bool] = None,
use_base_image_command: Optional[bool] = None,
skip_code_package: Optional[bool] = None,
persistence: Optional[str] = None,
project: Optional[str] = None,
branch: Optional[str] = None,
models: Optional[list] = None,
data: Optional[list] = None,
generate_static_url: Optional[bool] = None,
**kwargs
)
Hide Constructor Parameter Reference
Hide Constructor Parameter Reference
string
The name of the app to deploy.
integer
The port the app listens on when deployed.
string
A description of the app.
string
A user-defined type for the app, used for bookkeeping purposes.
string
The Docker image to deploy the app with.
string[]
Tags to apply to the app.
string[]
Platform integrations to attach to the app. Use the value you set in the
@secrets decorator in your code.string[]
A list of compute pools to deploy the app to.
object
Environment variables to set on the app.
string[]
The commands used to launch the app.
object
Resource configuration for the app.
cpu(str): CPU requests.memory(str): Memory requests.gpu(str): GPU requests.disk(str): Storage disk size.shared_memory(str): Shared memory.
object
Auth configuration for the app.
type(str): The type of authentication to use for the app.public(bool): Whether the app is public.
object
The number of replicas to deploy the app with.
fixed(int): A fixed number of replicas. Cannot be combined withminandmax.min(int): The minimum number of replicas.max(int): The maximum number of replicas.scaling_policy(object): The metric the replicas scale on. Applied whenminandmaxare set and are not the same. The default is 60 requests per minute.rpm(int): Scale up replicas when requests per minute cross this threshold.
object
Pre-packaged code from
package_code(). A PackagedCode named tuple containing url and key.boolean
Force an upgrade even if the app is currently being upgraded.
boolean
When true, skip providing startup commands and rely on the container’s entrypoint/CMD. Only available in the programmatic API. In CLI mode, use
--no-deps without passing a command to enable this behavior.boolean
When true, skip code packaging and rely on the container’s embedded source code. When set, you cannot pass
code_package.string
The persistence mode for the app. Experimental; might change in the future.
string
The project to deploy the app to. Experimental; might change in the future.
string
The branch to deploy the app to. Experimental; might change in the future.
string[]
Experimental; might change in the future.
string[]
Experimental; might change in the future.
boolean
Generate a static URL for the app based on its project, branch, and name.
bake_image and package_code:
from metaflow.apps import bake_image, package_code, AppDeployer
# Step 1: Bake dependencies into an image
baked = bake_image(pypi={"flask": ">=2.0", "requests": ""})
# Step 2: Package your application code
pkg = package_code(src_paths=["./src"])
# Step 3: Create deployer and deploy
deployer = AppDeployer(
name="my-flask-app",
port=8000,
image=baked.image,
code_package=pkg,
commands=["python server.py"],
replicas={"min": 1, "max": 3},
resources={"cpu": "1", "memory": "2048Mi"},
)
deployed = deployer.deploy()
print(deployed.public_url)
deployer = AppDeployer(
name="my-api",
port=8000,
image=baked.image,
code_package=pkg,
commands=["python api.py"],
auth={"type": "API"},
)
deployed = deployer.deploy()
deployer = AppDeployer(
name="my-app",
port=8000,
image=baked.image,
code_package=pkg,
commands=["python app.py"],
environment={"DEBUG": "false", "LOG_LEVEL": "info"},
secrets=["my-api-keys"],
)
deployed = deployer.deploy()
# Get app info
info = deployed.info()
# Get logs from all workers
logs = deployed.logs()
# Scale to zero workers
deployed.scale_to_zero()
# Delete the app
deployed.delete()