Skip to content

Commit 7bd2380

Browse files
committed
fix(ci): Unblock CI after the throttling and UI rework
Two issues surfaced in CI for the previous three commits: - test_app_model_label.py instantiates VibeApp via SimpleNamespace stubs and now needs the new _effective_active_model helper bound on the stub via MethodType, so the test exercises the real resolver rather than failing on AttributeError. - ruff flagged a tuple-membership check (PLR6201) in record_rate_limit and reformatted four files for trailing-comma and import-ordering conventions enforced by the pre-commit hook. No behaviour change.
1 parent c32c0de commit 7bd2380

5 files changed

Lines changed: 15 additions & 15 deletions

File tree

albert_code/cli/textual_ui/app.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1930,9 +1930,7 @@ def _refresh_quota_display(self) -> None:
19301930
if previous != effective.name:
19311931
self._last_displayed_model_name = effective.name
19321932
if previous is not None:
1933-
self.run_worker(
1934-
self._poll_daily_usage_once(), exclusive=False
1935-
)
1933+
self.run_worker(self._poll_daily_usage_once(), exclusive=False)
19361934
except Exception:
19371935
widget.clear()
19381936

albert_code/core/llm/quota.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ def midnight_utc_timestamp() -> int:
7373
import datetime as dt
7474

7575
return int(
76-
dt.datetime.now(dt.UTC)
76+
dt.datetime
77+
.now(dt.UTC)
7778
.replace(hour=0, minute=0, second=0, microsecond=0)
7879
.timestamp()
7980
)
@@ -115,10 +116,7 @@ async def fetch_albert_usage(
115116
async with httpx.AsyncClient(timeout=httpx.Timeout(timeout)) as client:
116117
offset = 0
117118
for _ in range(_USAGE_MAX_PAGES):
118-
params: dict[str, int] = {
119-
"limit": _USAGE_PAGE_LIMIT,
120-
"offset": offset,
121-
}
119+
params: dict[str, int] = {"limit": _USAGE_PAGE_LIMIT, "offset": offset}
122120
if since_timestamp is not None:
123121
params["start_time"] = since_timestamp
124122
response = await client.get(url, headers=headers, params=params)

albert_code/core/llm/throttling.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ def record_rate_limit(
331331
self._blocked_until = max(
332332
self._blocked_until, self._clock() + retry_after_seconds
333333
)
334-
if limit_type in ("tpm", "rpm"):
334+
if limit_type in {"tpm", "rpm"}:
335335
self._saturate_window(limit_type, model_alias)
336336
if model_alias is None:
337337
return

tests/cli/textual_ui/test_app_model_label.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
from __future__ import annotations
1414

15-
from types import SimpleNamespace
15+
from types import MethodType, SimpleNamespace
1616
from typing import cast
1717

1818
from albert_code.cli.textual_ui.app import VibeApp
@@ -34,7 +34,11 @@ def _make_stub(
3434
get_active_model=lambda: next(m for m in models if m.alias == active_alias),
3535
)
3636
agent_loop = SimpleNamespace(_last_resolved_model_alias=last_resolved)
37-
return cast(VibeApp, SimpleNamespace(config=config, agent_loop=agent_loop))
37+
stub = SimpleNamespace(config=config, agent_loop=agent_loop)
38+
# Bind the real helper so the test exercises actual resolution logic
39+
# rather than a duplicate. _format_model_label delegates to it.
40+
stub._effective_active_model = MethodType(VibeApp._effective_active_model, stub)
41+
return cast(VibeApp, stub)
3842

3943

4044
class TestFormatModelLabelPrimary:
@@ -115,7 +119,8 @@ def _raise() -> ModelConfig:
115119
active_model="ghost-model", models=[], get_active_model=_raise
116120
)
117121
agent_loop = SimpleNamespace(_last_resolved_model_alias=None)
118-
stub = cast(VibeApp, SimpleNamespace(config=config, agent_loop=agent_loop))
122+
stub = SimpleNamespace(config=config, agent_loop=agent_loop)
123+
stub._effective_active_model = MethodType(VibeApp._effective_active_model, stub)
119124

120-
label = VibeApp._format_model_label(stub)
125+
label = VibeApp._format_model_label(cast(VibeApp, stub))
121126
assert label == "⚙ ghost-model"

tests/core/test_quota.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def test_account_info_accepts_router_id_alias() -> None:
7979
"limits": [
8080
{"router_id": 342, "type": "rpm", "value": 500},
8181
{"router_id": 342, "type": "tpm", "value": None},
82-
],
82+
]
8383
})
8484
assert len(info.limits) == 2
8585
assert info.limits[0].router == 342
@@ -280,4 +280,3 @@ async def test_fetch_albert_usage_returns_none_on_http_error(
280280
return_value=httpx.Response(500, json={"detail": "boom"})
281281
)
282282
assert await fetch_albert_usage(_make_provider()) is None
283-

0 commit comments

Comments
 (0)