Skip to content

Commit ef73e4d

Browse files
fix eval run progress printing by clearing line (#38)
fix the leftover "0s" after done [########################################] 2/2 (100.00%) | DONE0s
1 parent 66d8365 commit ef73e4d

File tree

1 file changed

+3
-1
lines changed
  • src/humanloop/eval_utils

1 file changed

+3
-1
lines changed

src/humanloop/eval_utils/run.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,14 +196,16 @@ def increment(self):
196196
time_per_item = elapsed_time / self._progress if self._progress > 0 else 0
197197
eta = (self._total - self._progress) * time_per_item
198198

199-
progress_display = f"\r[{bar}] {self._progress}/{self._total}"
199+
progress_display = f"[{bar}] {self._progress}/{self._total}"
200200
progress_display += f" ({percentage:.2f}%)"
201201

202202
if self._progress < self._total:
203203
progress_display += f" | ETA: {int(eta)}s"
204204
else:
205205
progress_display += " | DONE"
206206

207+
sys.stderr.write("\r") # Move the cursor to the beginning of the line
208+
sys.stderr.write("\033[K") # Clear the line from the cursor to the end
207209
sys.stderr.write(progress_display)
208210

209211
if self._progress >= self._total:

0 commit comments

Comments
 (0)