Skip to content

Commit

Permalink
Remove SandboxEnvironment.exec() claim (and associated test) that c…
Browse files Browse the repository at this point in the history
…ommands won't be terminated. (#792)
  • Loading branch information
craigwalton-dsit authored Nov 1, 2024
1 parent f8e0942 commit f3358c4
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 20 deletions.
3 changes: 1 addition & 2 deletions src/inspect_ai/util/_sandbox/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,7 @@ async def exec(
filesystem context.
Each output stream (stdout and stderr) is limited to 1 MiB. If exceeded, an
`OutputLimitExceededError` will be raised. This will not cause the command to be
terminated.
`OutputLimitExceededError` will be raised.
Args:
cmd (str | list[str]): Command or command and arguments to execute.
Expand Down
18 changes: 0 additions & 18 deletions src/inspect_ai/util/_sandbox/self_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ async def self_check(sandbox_env: SandboxEnvironment) -> dict[str, bool | str]:
test_cwd_absolute,
test_exec_stdout_is_limited,
test_exec_stderr_is_limited,
test_exec_limit_exceeded_does_not_terminate_command,
]:
results[fn.__name__] = await check_test_fn(fn, sandbox_env)

Expand Down Expand Up @@ -313,23 +312,6 @@ async def test_exec_stderr_is_limited(sandbox_env: SandboxEnvironment) -> None:
assert truncated_output and len(truncated_output) == 1024**2


async def test_exec_limit_exceeded_does_not_terminate_command(
sandbox_env: SandboxEnvironment,
) -> None:
file = "limit-exceeded-but-still-running.file"
# Write 2 MiB to stdout, then create a file.
script = f"""\
yes | head -c {2 * 1024**2}
touch {file}
"""
with pytest.raises(OutputLimitExceededError):
await sandbox_env.exec(["sh", "-c", script])
# Verify that exceeding the output limit did not terminate the command.
test_result = await sandbox_env.exec(["test", "-f", file])
assert test_result.returncode == 0
await _cleanup_file(sandbox_env, file)


# TODO: write a test for when cwd doesn't exist

# Generic type variable for exceptions
Expand Down

0 comments on commit f3358c4

Please sign in to comment.