Skip to content

Commit 4158270

Browse files
committed
fix(chutes): address PR review feedback
- Use 'rotator_library' logger for consistency (chutes_provider.py) - Add HTTPStatusError handling in get_models() for 4xx/5xx responses - Add timeout=30.0 to httpx.AsyncClient in run_background_job() - Remove unused UsageManager import from chutes_quota_tracker.py
1 parent 8105c20 commit 4158270

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

src/rotator_library/providers/chutes_provider.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
# Create a local logger for this module
1212
import logging
1313

14-
lib_logger = logging.getLogger(__name__)
14+
lib_logger = logging.getLogger("rotator_library")
1515

1616
# Concurrency limit for parallel quota fetches
1717
QUOTA_FETCH_CONCURRENCY = 5
@@ -67,7 +67,7 @@ async def get_models(self, api_key: str, client: httpx.AsyncClient) -> List[str]
6767
return [
6868
f"chutes/{model['id']}" for model in response.json().get("data", [])
6969
]
70-
except httpx.RequestError as e:
70+
except (httpx.RequestError, httpx.HTTPStatusError) as e:
7171
lib_logger.error(f"Failed to fetch chutes.ai models: {e}")
7272
return []
7373

@@ -138,7 +138,7 @@ async def refresh_single_credential(
138138
lib_logger.warning(f"Failed to refresh Chutes quota usage: {e}")
139139

140140
# Fetch all credentials in parallel with shared HTTP client
141-
async with httpx.AsyncClient() as client:
141+
async with httpx.AsyncClient(timeout=30.0) as client:
142142
tasks = [
143143
refresh_single_credential(api_key, client) for api_key in credentials
144144
]

src/rotator_library/providers/utilities/chutes_quota_tracker.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,10 @@
1919
import logging
2020
import time
2121
from datetime import datetime, timezone, timedelta
22-
from typing import Any, Dict, List, Optional, Tuple, TYPE_CHECKING
22+
from typing import Any, Dict, List, Optional, Tuple
2323

2424
import httpx
2525

26-
if TYPE_CHECKING:
27-
from ...usage_manager import UsageManager
28-
2926
# Use the shared rotator_library logger
3027
lib_logger = logging.getLogger("rotator_library")
3128

0 commit comments

Comments
 (0)