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
instance-attribute
_app = lookup('swe-rex', create_if_missing=True)
_deployment_timeout
instance-attribute
_deployment_timeout = deployment_timeout
_hooks
instance-attribute
_hooks = CombinedDeploymentHook()
_image
instance-attribute
_image = auto(image)
_modal_kwargs
instance-attribute
_modal_kwargs = modal_sandbox_kwargs
_port
instance-attribute
_port = 8880
_runtime_timeout
instance-attribute
_runtime_timeout = runtime_timeout
_sandbox
instance-attribute
_sandbox: Sandbox | None = None
_startup_timeout
instance-attribute
_startup_timeout = startup_timeout
_user
instance-attribute
_user = _get_modal_user()
app
property
app: App
Returns the modal app
Raises:
Type | Description |
---|---|
DeploymentNotStartedError
|
If the deployment is not started. |
logger
instance-attribute
logger = logger or get_logger('rex-deploy')
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. |
_get_token
_get_token() -> str
Source code in swerex/deployment/modal.py
169 170 |
|
_start_swerex_cmd
_start_swerex_cmd(token: str) -> str
Start swerex-server on the remote. If swerex is not installed arelady, install pipx and then run swerex-server with pipx run
Source code in swerex/deployment/modal.py
193 194 195 196 197 198 |
|
_wait_until_alive
async
_wait_until_alive(timeout: float = 10.0)
Source code in swerex/deployment/modal.py
189 190 191 |
|
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 |
|