Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve an issue when attempting to call decode() on a streamed/potentially temporarily invalid utf-8 string. #216

Merged
merged 1 commit into from
Sep 3, 2024
Merged
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
6 changes: 3 additions & 3 deletions swebench/harness/docker_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ def exec_run_with_timeout(container, cmd, timeout: int|None=60):
timeout (int): Timeout in seconds.
"""
# Local variables to store the result of executing the command
exec_result = ''
exec_result = b''
exec_id = None
exception = None
timed_out = False
Expand All @@ -195,7 +195,7 @@ def run_command():
exec_id = container.client.api.exec_create(container.id, cmd)["Id"]
exec_stream = container.client.api.exec_start(exec_id, stream=True)
for chunk in exec_stream:
exec_result += chunk.decode()
exec_result += chunk
except Exception as e:
exception = e

Expand All @@ -215,7 +215,7 @@ def run_command():
container.exec_run(f"kill -TERM {exec_pid}", detach=True)
timed_out = True
end_time = time.time()
return exec_result, timed_out, end_time - start_time
return exec_result.decode(), timed_out, end_time - start_time


def find_dependent_images(client: docker.DockerClient, image_name: str):
Expand Down
Loading