-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
103 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
::: swerex.deployment.dummy.DummyDeployment |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
::: swerex.runtime.dummy.DummyRuntime |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
from swerex.deployment.abstract import AbstractDeployment | ||
from swerex.runtime.abstract import IsAliveResponse | ||
from swerex.runtime.dummy import DummyRuntime | ||
|
||
|
||
class DummyDeployment(AbstractDeployment): | ||
"""This deployment does nothing. | ||
Useful for testing. | ||
""" | ||
|
||
def __init__(self): | ||
self._runtime = DummyRuntime() # type: ignore | ||
|
||
async def is_alive(self, *, timeout: float | None = None) -> IsAliveResponse: | ||
return IsAliveResponse(is_alive=True) | ||
|
||
async def start(self): | ||
pass | ||
|
||
async def stop(self): | ||
pass | ||
|
||
@property | ||
def runtime(self) -> DummyRuntime: | ||
return self._runtime | ||
|
||
@runtime.setter | ||
def runtime(self, runtime: DummyRuntime): | ||
self._runtime = runtime |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
from swerex.runtime.abstract import ( | ||
AbstractRuntime, | ||
Action, | ||
BashObservation, | ||
CloseBashSessionResponse, | ||
CloseResponse, | ||
CloseSessionRequest, | ||
CloseSessionResponse, | ||
Command, | ||
CommandResponse, | ||
CreateBashSessionResponse, | ||
CreateSessionRequest, | ||
CreateSessionResponse, | ||
IsAliveResponse, | ||
Observation, | ||
ReadFileRequest, | ||
ReadFileResponse, | ||
UploadRequest, | ||
UploadResponse, | ||
WriteFileRequest, | ||
WriteFileResponse, | ||
) | ||
|
||
|
||
class DummyRuntime(AbstractRuntime): | ||
"""This runtime does nothing. | ||
Useful for testing. | ||
""" | ||
|
||
async def is_alive(self, *, timeout: float | None = None) -> IsAliveResponse: | ||
return IsAliveResponse(is_alive=True) | ||
|
||
async def create_session(self, request: CreateSessionRequest) -> CreateSessionResponse: | ||
if request.session_type == "bash": | ||
return CreateBashSessionResponse() | ||
msg = f"Unknown session type: {request.session_type}" | ||
raise ValueError(msg) | ||
|
||
async def run_in_session(self, action: Action) -> Observation: | ||
if action.session_type == "bash": | ||
return BashObservation(exit_code=0) | ||
msg = f"Unknown session type: {action.session_type}" | ||
raise ValueError(msg) | ||
|
||
async def close_session(self, request: CloseSessionRequest) -> CloseSessionResponse: | ||
if request.session_type == "bash": | ||
return CloseBashSessionResponse() | ||
msg = f"Unknown session type: {request.session_type}" | ||
raise ValueError(msg) | ||
|
||
async def execute(self, command: Command) -> CommandResponse: | ||
return CommandResponse(exit_code=0) | ||
|
||
async def read_file(self, request: ReadFileRequest) -> ReadFileResponse: | ||
return ReadFileResponse() | ||
|
||
async def write_file(self, request: WriteFileRequest) -> WriteFileResponse: | ||
return WriteFileResponse() | ||
|
||
async def upload(self, request: UploadRequest) -> UploadResponse: | ||
return UploadResponse() | ||
|
||
async def close(self) -> CloseResponse: | ||
return CloseResponse() |