Skip to content

Commit

Permalink
Merge pull request #216 from Laredo-Labs/swebench-215
Browse files Browse the repository at this point in the history
Resolve an issue when attempting to call decode() on a streamed/potentially temporarily invalid utf-8 string.
  • Loading branch information
john-b-yang committed Sep 3, 2024
2 parents 7336033 + d934cdd commit 7470f5f
Showing 1 changed file with 3 additions and 3 deletions.
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

0 comments on commit 7470f5f

Please sign in to comment.