Skip to content

Abstract

swerex.runtime.abstract.AbstractRuntime

AbstractRuntime(*args: Any, **kwargs: Any)

Bases: ABC

This is the main entry point for running stuff.

It keeps track of all the sessions (individual repls) that are currently open.

Source code in swerex/runtime/abstract.py
227
228
def __init__(self, *args: Any, **kwargs: Any):
    self.logger: logging.Logger

logger instance-attribute

logger: Logger

close abstractmethod async

close() -> CloseResponse

Closes the runtime.

Source code in swerex/runtime/abstract.py
272
273
274
275
@abstractmethod
async def close(self) -> CloseResponse:
    """Closes the runtime."""
    pass

close_session abstractmethod async

close_session(request: CloseSessionRequest) -> CloseSessionResponse

Closes a shell session (e.g., a bash shell that we started earlier).

Source code in swerex/runtime/abstract.py
247
248
249
250
@abstractmethod
async def close_session(self, request: CloseSessionRequest) -> CloseSessionResponse:
    """Closes a shell session (e.g., a bash shell that we started earlier)."""
    pass

create_session abstractmethod async

create_session(request: CreateSessionRequest) -> CreateSessionResponse

Creates a new session (e.g., a bash shell).

Source code in swerex/runtime/abstract.py
235
236
237
238
@abstractmethod
async def create_session(self, request: CreateSessionRequest) -> CreateSessionResponse:
    """Creates a new session (e.g., a bash shell)."""
    pass

execute abstractmethod async

execute(command: Command) -> CommandResponse

Executes a command (in a sub-shell, similar to subprocess.run()).

Source code in swerex/runtime/abstract.py
252
253
254
255
@abstractmethod
async def execute(self, command: Command) -> CommandResponse:
    """Executes a command (in a sub-shell, similar to `subprocess.run()`)."""
    pass

is_alive abstractmethod async

is_alive(*, timeout: float | None = None) -> IsAliveResponse

Checks if the runtime is alive and running.

Source code in swerex/runtime/abstract.py
230
231
232
233
@abstractmethod
async def is_alive(self, *, timeout: float | None = None) -> IsAliveResponse:
    """Checks if the runtime is alive and running."""
    pass

read_file abstractmethod async

read_file(request: ReadFileRequest) -> ReadFileResponse

Reads a file and returns the content as a string.

Source code in swerex/runtime/abstract.py
257
258
259
260
@abstractmethod
async def read_file(self, request: ReadFileRequest) -> ReadFileResponse:
    """Reads a file and returns the content as a string."""
    pass

run_in_session abstractmethod async

run_in_session(action: Action) -> Observation

Runs a command in a session (e.g., a bash shell). The name of the session is determined by the session field in the Action.

Source code in swerex/runtime/abstract.py
240
241
242
243
244
245
@abstractmethod
async def run_in_session(self, action: Action) -> Observation:
    """Runs a command in a session (e.g., a bash shell).
    The name of the session is determined by the `session` field in the `Action`.
    """
    pass

upload abstractmethod async

upload(request: UploadRequest) -> UploadResponse

Uploads a file from the local machine to the remote machine.

Source code in swerex/runtime/abstract.py
267
268
269
270
@abstractmethod
async def upload(self, request: UploadRequest) -> UploadResponse:
    """Uploads a file from the local machine to the remote machine."""
    pass

write_file abstractmethod async

write_file(request: WriteFileRequest) -> WriteFileResponse

Writes a string to a file.

Source code in swerex/runtime/abstract.py
262
263
264
265
@abstractmethod
async def write_file(self, request: WriteFileRequest) -> WriteFileResponse:
    """Writes a string to a file."""
    pass