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
364 365 366 367 368 369 370 371 372 373 374 |
|
_config
instance-attribute
_config = LocalRuntimeConfig(**kwargs)
_sessions
instance-attribute
_sessions: dict[str, Session] = {}
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
470 471 472 473 474 |
|
close_session
async
close_session(request: CloseSessionRequest) -> CloseSessionResponse
Closes a shell session.
Source code in swerex/runtime/local.py
408 409 410 411 412 413 414 415 |
|
create_session
async
create_session(request: CreateSessionRequest) -> CreateSessionResponse
Creates a new session.
Source code in swerex/runtime/local.py
388 389 390 391 392 393 394 395 396 397 398 399 |
|
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
417 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 |
|
from_config
classmethod
from_config(config: LocalRuntimeConfig) -> Self
Source code in swerex/runtime/local.py
376 377 378 |
|
is_alive
async
is_alive(*, timeout: float | None = None) -> IsAliveResponse
Checks if the runtime is alive.
Source code in swerex/runtime/local.py
384 385 386 |
|
read_file
async
read_file(request: ReadFileRequest) -> ReadFileResponse
Reads a file
Source code in swerex/runtime/local.py
451 452 453 454 |
|
run_in_session
async
run_in_session(action: Action) -> Observation
Runs a command in a session.
Source code in swerex/runtime/local.py
401 402 403 404 405 406 |
|
upload
async
upload(request: UploadRequest) -> UploadResponse
Uploads a file
Source code in swerex/runtime/local.py
462 463 464 465 466 467 468 |
|
write_file
async
write_file(request: WriteFileRequest) -> WriteFileResponse
Writes a file
Source code in swerex/runtime/local.py
456 457 458 459 460 |
|