Skip to content
Open
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,7 @@ async def process_requests_from_file(

status_tracker.num_tasks_started += 1
status_tracker.num_tasks_in_progress += 1
status_tracker.update_display()

if pending_requests:
await asyncio.gather(*pending_requests)
Expand Down Expand Up @@ -561,6 +562,7 @@ async def handle_single_request_with_retries(
await self.append_generic_response(status_tracker, generic_response, response_file)
status_tracker.num_tasks_in_progress -= 1
status_tracker.num_tasks_failed += 1
status_tracker.update_display()
return
else:
self._add_output_token_moving_window(generic_response.token_usage.output)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ def update_display(self):
# 3. When costs or tokens change
should_update = (
current_time - self._last_stats_update >= _STATUS_UPDATE_INTERVAL # Time-based update
and (
or (
self.num_tasks_in_progress != getattr(self, "_last_in_progress", -1) # Task state change
or self.num_tasks_succeeded != getattr(self, "_last_succeeded", -1)
or self.num_tasks_failed != getattr(self, "_last_failed", -1)
Expand Down
28 changes: 27 additions & 1 deletion tests/unittests/test_online_status_tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def test_online_status_tracker_display():
assert "100" in captured # Total requests
assert "50✓" in captured.replace(" ", "") # Success count
assert "5✗" in captured.replace(" ", "") # Failed count
assert "10⋯" in captured.replace(" ", "") # In progress count
assert "10⋯" in captured.replace(" ", "") or "10…" in captured.replace(" ", "") # In progress count
assert "$0.123" in captured # Cost
assert "1000" in captured # Input tokens
assert "2000" in captured # Output tokens
Expand Down Expand Up @@ -120,3 +120,29 @@ def test_online_status_tracker_external_model_cost_missing_keys():
assert tracker.output_cost_per_million is None
assert "N/A" in tracker.input_cost_str
assert "N/A" in tracker.output_cost_str


def test_online_status_tracker_requests_in_progress_update():
"""Test that requests in progress update immediately via update_display."""
output = StringIO()
console = Console(file=output, width=200, force_terminal=True)
tracker = OnlineStatusTracker()
tracker.model = "test-model"
tracker.total_requests = 10
tracker.start_tracker(console)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT TEST_REGRESSION Exercise the TQDM path in this regression test

With the default USE_RICH_DISPLAY, start_tracker(console) selects the Rich branch, so this test never exercises the changed TQDM condition. It only checks counters and max concurrency, so it passes if the five-second TQDM gating remains broken.

Prompt to fix with AI

Copy this prompt into your AI coding assistant to fix this issue.

In tests/unittests/test_online_status_tracker.py at lines 127-148, make the regression test explicitly exercise the non-Rich/TQDM mode or otherwise isolate the TQDM update logic, and assert that the rendered/logged status changes immediately after incrementing and decrementing in-progress requests. Preserve the existing Rich-mode coverage separately if needed.


# Dispatch request: tasks started and in_progress increase
tracker.num_tasks_started += 1
tracker.num_tasks_in_progress += 1
tracker.update_display()

assert tracker.num_tasks_in_progress == 1
assert tracker.max_concurrent_requests_seen == 1

# Task finishes: in_progress decrements, succeeded increments
tracker.num_tasks_in_progress -= 1
tracker.num_tasks_succeeded += 1
tracker.update_display()

assert tracker.num_tasks_in_progress == 0
tracker.stop_tracker()
2 changes: 1 addition & 1 deletion tests/unittests/test_status_tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def test_online_status_tracker_display():
assert "test-model" in captured
assert "50✓" in captured.replace(" ", "") # Success count
assert "5✗" in captured.replace(" ", "") # Failed count
assert "10⋯" in captured.replace(" ", "") # In progress count
assert "10⋯" in captured.replace(" ", "") or "10…" in captured.replace(" ", "") # In progress count
assert "$0.123" in captured # Cost
assert "1000" in captured # Input tokens
assert "2000" in captured # Output tokens
Expand Down