Skip to content

Commit

Permalink
CI: Allow to line up return values in dummy runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
klieret committed Nov 15, 2024
1 parent 3cc22f3 commit fc85341
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/swerex/runtime/dummy.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ class DummyRuntime(AbstractRuntime):
Useful for testing.
"""

def __init__(
self,
):
self.run_in_session_outputs: list[BashObservation] | BashObservation = BashObservation(exit_code=0)
"""Predefine returns of run_in_session. If set to list, will pop from list, else will
return the same value.
"""

async def is_alive(self, *, timeout: float | None = None) -> IsAliveResponse:
return IsAliveResponse(is_alive=True)

Expand All @@ -37,10 +45,9 @@ async def create_session(self, request: CreateSessionRequest) -> CreateSessionRe
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)
if isinstance(self.run_in_session_outputs, list):
return self.run_in_session_outputs.pop(0)
return self.run_in_session_outputs

async def close_session(self, request: CloseSessionRequest) -> CloseSessionResponse:
if request.session_type == "bash":
Expand Down

0 comments on commit fc85341

Please sign in to comment.