Local
swerex.runtime.local.LocalRuntime
LocalRuntime(*, logger: Logger | None = None, **kwargs: Any)
Bases: AbstractRuntime
A Runtime that runs locally and actually executes commands in a shell. If you are deploying to Modal/Fargate/etc., this class will be running within the docker container on Modal/Fargate/etc.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs
|
Any
|
Keyword arguments (see |
{}
|
Source code in swerex/runtime/local.py
366 367 368 369 370 371 372 373 374 375 376 | |
logger
instance-attribute
logger = logger or get_logger('rex-runtime')
sessions
property
sessions: dict[str, Session]
close
async
close() -> CloseResponse
Closes the runtime.
Source code in swerex/runtime/local.py
474 475 476 477 478 | |
close_session
async
close_session(request: CloseSessionRequest) -> CloseSessionResponse
Closes a shell session.
Source code in swerex/runtime/local.py
410 411 412 413 414 415 416 417 | |
create_session
async
create_session(request: CreateSessionRequest) -> CreateSessionResponse
Creates a new session.
Source code in swerex/runtime/local.py
390 391 392 393 394 395 396 397 398 399 400 401 | |
execute
async
execute(command: Command) -> CommandResponse
Executes a command (independent of any shell session).
Raises:
| Type | Description |
|---|---|
CommandTimeoutError
|
If the command times out. |
NonZeroExitCodeError
|
If the command has a non-zero exit code and |
Source code in swerex/runtime/local.py
419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 | |
from_config
classmethod
from_config(config: LocalRuntimeConfig) -> Self
Source code in swerex/runtime/local.py
378 379 380 | |
is_alive
async
is_alive(*, timeout: float | None = None) -> IsAliveResponse
Checks if the runtime is alive.
Source code in swerex/runtime/local.py
386 387 388 | |
read_file
async
read_file(request: ReadFileRequest) -> ReadFileResponse
Reads a file
Source code in swerex/runtime/local.py
455 456 457 458 | |
run_in_session
async
run_in_session(action: Action) -> Observation
Runs a command in a session.
Source code in swerex/runtime/local.py
403 404 405 406 407 408 | |
upload
async
upload(request: UploadRequest) -> UploadResponse
Uploads a file
Source code in swerex/runtime/local.py
466 467 468 469 470 471 472 | |
write_file
async
write_file(request: WriteFileRequest) -> WriteFileResponse
Writes a file
Source code in swerex/runtime/local.py
460 461 462 463 464 | |