Modal
swerex.deployment.modal.ModalDeployment
ModalDeployment(*, logger: Logger | None = None, image: str | Image | PurePath, startup_timeout: float = 0.4, runtime_timeout: float = 1800.0, modal_sandbox_kwargs: dict[str, Any] | None = None, install_pipx: bool = True, deployment_timeout: float = 1800.0)
Bases: AbstractDeployment
Deployment for modal.com. The deployment will only start when the
start
method is being called.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
image
|
str | Image | PurePath
|
Image to use for the deployment. One of the following:
1. |
required |
startup_timeout
|
float
|
The time to wait for the runtime to start. |
0.4
|
runtime_timeout
|
float
|
The runtime timeout. |
1800.0
|
deployment_timeout
|
float
|
The deployment timeout. |
1800.0
|
modal_sandbox_kwargs
|
dict[str, Any] | None
|
Additional arguments to pass to |
None
|
Source code in swerex/deployment/modal.py
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 |
|
app
property
app: App
Returns the modal app
Raises:
Type | Description |
---|---|
DeploymentNotStartedError
|
If the deployment is not started. |
runtime
property
runtime: RemoteRuntime
Returns the runtime if running.
Raises:
Type | Description |
---|---|
DeploymentNotStartedError
|
If the deployment was not started. |
sandbox
property
sandbox: Sandbox
Returns the modal sandbox
Raises:
Type | Description |
---|---|
DeploymentNotStartedError
|
If the deployment is not started. |
add_hook
add_hook(hook: DeploymentHook)
Source code in swerex/deployment/modal.py
155 156 |
|
from_config
classmethod
from_config(config: ModalDeploymentConfig) -> Self
Source code in swerex/deployment/modal.py
158 159 160 161 162 163 164 165 166 167 |
|
get_modal_log_url
get_modal_log_url() -> str
Returns URL to modal logs
Raises:
Type | Description |
---|---|
DeploymentNotStartedError
|
If the deployment was not started. |
Source code in swerex/deployment/modal.py
200 201 202 203 204 205 206 |
|
is_alive
async
is_alive(*, timeout: float | None = None) -> IsAliveResponse
Checks if the runtime is alive. The return value can be tested with bool().
Raises:
Type | Description |
---|---|
DeploymentNotStartedError
|
If the deployment was not started. |
Source code in swerex/deployment/modal.py
172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 |
|
start
async
start()
Starts the runtime.
Source code in swerex/deployment/modal.py
208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 |
|
stop
async
stop()
Stops the runtime.
Source code in swerex/deployment/modal.py
242 243 244 245 246 247 248 249 250 |
|