chore: improved fix for terminal error

This commit is contained in:
Matthias
2024-08-29 20:38:25 +02:00
parent ca3dee7b37
commit 1c5ca0f022
+5 -1
View File
@@ -59,7 +59,8 @@ class HyperoptOutput:
max_rows: Optional[int] = None max_rows: Optional[int] = None
if self._streaming and "pytest" not in sys.modules: if self._streaming:
try:
ts = get_terminal_size() ts = get_terminal_size()
# Get terminal size. # Get terminal size.
# Account for header, borders, and for the progress bar. # Account for header, borders, and for the progress bar.
@@ -70,6 +71,9 @@ class HyperoptOutput:
max_rows = -(int(ts.lines / 2) - 6) max_rows = -(int(ts.lines / 2) - 6)
else: else:
max_rows = -(ts.lines - 6) max_rows = -(ts.lines - 6)
except OSError:
# If we can't get the terminal size, we will just display the last 10 rows.
pass
self.__init_table() self.__init_table()
for r in self._results[max_rows:]: for r in self._results[max_rows:]: