Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/swerex/runtime/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ class RemoteRuntimeConfig(BaseModel):
timeout: float = 0.15
"""The timeout for the runtime."""

timeout_request: float = 300.0
"""The timeout for request."""

type: Literal["remote"] = "remote"
"""Discriminator for (de)serialization/CLI. Do not change."""

Expand Down
12 changes: 6 additions & 6 deletions src/swerex/runtime/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@
__all__ = ["LocalRuntime", "BashSession"]


def _split_bash_command(inpt: str) -> list[str]:
def _split_bash_command(input: str) -> list[str]:
r"""Split a bash command with linebreaks, escaped newlines, and heredocs into a list of
individual commands.

Args:
inpt: The input string to split into commands.
input: The input string to split into commands.
Returns:
A list of commands as strings.

Expand All @@ -70,11 +70,11 @@ def _split_bash_command(inpt: str) -> list[str]:
"cmd1\\\n asdf" is one command (because the linebreak is escaped)
"cmd1<<EOF\na\nb\nEOF" is one command (because of the heredoc)
"""
inpt = inpt.strip()
if not inpt or all(l.strip().startswith("#") for l in inpt.splitlines()):
input = input.strip()
if not input or all(l.strip().startswith("#") for l in input.splitlines()):
# bashlex can't deal with empty strings or the like :/
return []
parsed = bashlex.parse(inpt)
parsed = bashlex.parse(input)
cmd_strings = []

def find_range(cmd: bashlex.ast.node) -> tuple[int, int]:
Expand All @@ -88,7 +88,7 @@ def find_range(cmd: bashlex.ast.node) -> tuple[int, int]:

for cmd in parsed:
start, end = find_range(cmd)
cmd_strings.append(inpt[start:end])
cmd_strings.append(input[start:end])
return cmd_strings


Expand Down
1 change: 1 addition & 0 deletions src/swerex/runtime/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ async def _request(self, endpoint: str, payload: BaseModel | None, output_class:
request_url,
json=payload.model_dump() if payload else None,
headers=headers,
timeout=aiohttp.ClientTimeout(total=self._config.timeout_request),
) as resp:
await self._handle_response_errors(resp)
return output_class(**await resp.json())
Expand Down
Loading