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
365 366 367 368 369 370 371 372 373 374 375 |
|
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
471 472 473 474 475 |
|
close_session
async
close_session(request: CloseSessionRequest) -> CloseSessionResponse
Closes a shell session.
Source code in swerex/runtime/local.py
409 410 411 412 413 414 415 416 |
|
create_session
async
create_session(request: CreateSessionRequest) -> CreateSessionResponse
Creates a new session.
Source code in swerex/runtime/local.py
389 390 391 392 393 394 395 396 397 398 399 400 |
|
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
418 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 |
|
from_config
classmethod
from_config(config: LocalRuntimeConfig) -> Self
Source code in swerex/runtime/local.py
377 378 379 |
|
is_alive
async
is_alive(*, timeout: float | None = None) -> IsAliveResponse
Checks if the runtime is alive.
Source code in swerex/runtime/local.py
385 386 387 |
|
read_file
async
read_file(request: ReadFileRequest) -> ReadFileResponse
Reads a file
Source code in swerex/runtime/local.py
452 453 454 455 |
|
run_in_session
async
run_in_session(action: Action) -> Observation
Runs a command in a session.
Source code in swerex/runtime/local.py
402 403 404 405 406 407 |
|
upload
async
upload(request: UploadRequest) -> UploadResponse
Uploads a file
Source code in swerex/runtime/local.py
463 464 465 466 467 468 469 |
|
write_file
async
write_file(request: WriteFileRequest) -> WriteFileResponse
Writes a file
Source code in swerex/runtime/local.py
457 458 459 460 461 |
|