2026-01-14 23:29:18 +08:00
from pydantic import BaseModel , ConfigDict , Field
class VolumeMountConfig ( BaseModel ) :
""" Configuration for a volume mount. """
host_path : str = Field ( . . . , description = " Path on the host machine " )
container_path : str = Field ( . . . , description = " Path inside the container " )
read_only : bool = Field ( default = False , description = " Whether the mount is read-only " )
2026-01-14 07:15:58 +08:00
class SandboxConfig ( BaseModel ) :
2026-01-14 23:29:18 +08:00
""" Config section for a sandbox.
Common options :
use : Class path of the sandbox provider ( required )
AioSandboxProvider specific options :
image : Docker image to use ( default : enterprise - public - cn - beijing . cr . volces . com / vefaas - public / all - in - one - sandbox : latest )
port : Base port for sandbox containers ( default : 8080 )
2026-03-11 10:03:01 +08:00
replicas : Maximum number of concurrent sandbox containers ( default : 3 ) . When the limit is reached the least - recently - used sandbox is evicted to make room .
2026-01-14 23:29:18 +08:00
container_prefix : Prefix for container names ( default : deer - flow - sandbox )
2026-01-30 21:58:43 +08:00
idle_timeout : Idle timeout in seconds before sandbox is released ( default : 600 = 10 minutes ) . Set to 0 to disable .
2026-01-14 23:29:18 +08:00
mounts : List of volume mounts to share directories with the container
2026-01-24 22:33:29 +08:00
environment : Environment variables to inject into the container ( values starting with $ are resolved from host env )
2026-01-14 23:29:18 +08:00
"""
2026-01-14 07:15:58 +08:00
use : str = Field (
. . . ,
2026-01-14 23:29:18 +08:00
description = " Class path of the sandbox provider (e.g. src.sandbox.local:LocalSandboxProvider) " ,
)
image : str | None = Field (
default = None ,
description = " Docker image to use for the sandbox container " ,
2026-01-14 07:15:58 +08:00
)
2026-01-14 23:29:18 +08:00
port : int | None = Field (
default = None ,
description = " Base port for sandbox containers " ,
)
2026-03-11 10:03:01 +08:00
replicas : int | None = Field (
2026-01-14 23:29:18 +08:00
default = None ,
2026-03-11 10:03:01 +08:00
description = " Maximum number of concurrent sandbox containers (default: 3). When the limit is reached the least-recently-used sandbox is evicted to make room. " ,
2026-01-14 23:29:18 +08:00
)
container_prefix : str | None = Field (
default = None ,
description = " Prefix for container names " ,
)
2026-01-30 21:58:43 +08:00
idle_timeout : int | None = Field (
default = None ,
description = " Idle timeout in seconds before sandbox is released (default: 600 = 10 minutes). Set to 0 to disable. " ,
)
2026-01-14 23:29:18 +08:00
mounts : list [ VolumeMountConfig ] = Field (
default_factory = list ,
description = " List of volume mounts to share directories between host and container " ,
)
2026-01-24 22:33:29 +08:00
environment : dict [ str , str ] = Field (
default_factory = dict ,
2026-01-29 08:23:50 +08:00
description = " Environment variables to inject into the sandbox container. Values starting with $ will be resolved from host environment variables. " ,
2026-01-24 22:33:29 +08:00
)
2026-01-14 23:29:18 +08:00
model_config = ConfigDict ( extra = " allow " )