Skip to content

Commit

Permalink
Show docker build errors (All-Hands-AI#6695)
Browse files Browse the repository at this point in the history
  • Loading branch information
kripper authored Feb 15, 2025
1 parent 4443417 commit 30e39e8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 3 additions & 0 deletions openhands/core/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,11 +156,13 @@ class RollingLogger:
max_lines: int
char_limit: int
log_lines: list[str]
all_lines: str

def __init__(self, max_lines=10, char_limit=80):
self.max_lines = max_lines
self.char_limit = char_limit
self.log_lines = [''] * self.max_lines
self.all_lines = ''

def is_enabled(self):
return DEBUG and sys.stdout.isatty()
Expand All @@ -175,6 +177,7 @@ def add_line(self, line):
self.log_lines.pop(0)
self.log_lines.append(line[: self.char_limit])
self.print_lines()
self.all_lines += line + '\n'

def write_immediately(self, line):
self._write(line)
Expand Down
4 changes: 3 additions & 1 deletion openhands/runtime/builder/docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,10 @@ def build(
)

except subprocess.CalledProcessError as e:
logger.error(f'Image build failed:\n{e}')
logger.error(f'Image build failed:\n{e}') # TODO: {e} is empty
logger.error(f'Command output:\n{e.output}')
if self.rolling_logger.is_enabled():
logger.error("Docker build output:\n" + self.rolling_logger.all_lines) # Show the error
raise

except subprocess.TimeoutExpired:
Expand Down

0 comments on commit 30e39e8

Please sign in to comment.