Skip to content

refactor(server): vendor token bucket rate limiter from phoenix-evals#12430

Merged
RogerHYang merged 4 commits intomainfrom
dustin/vendor-token-bucket
Mar 29, 2026
Merged

refactor(server): vendor token bucket rate limiter from phoenix-evals#12430
RogerHYang merged 4 commits intomainfrom
dustin/vendor-token-bucket

Conversation

@anticorrelator
Copy link
Copy Markdown
Contributor

@anticorrelator anticorrelator commented Mar 28, 2026

Resolves #12330

Summary

  • Vendors AdaptiveTokenBucket and RateLimiter from phoenix-evals into src/phoenix/server/rate_limiters.py, decoupling the server from the evals package
  • Adds async_on_rate_limit_error() using asyncio.sleep instead of time.sleep to avoid blocking the event loop in the server's async context
  • Updates playground_clients.py to import from the server-local module
  • First step toward removing arize-phoenix-evals from pyproject.toml dependencies

Test plan

  • uv run pytest tests/unit/server/test_rate_limiters.py -q — all vendored rate limiter tests pass
  • uv run pytest tests/unit/server/api/helpers/test_playground_clients.py -q — playground client tests pass
  • uv run ruff check — no lint issues
  • uv run mypy src/phoenix/server/rate_limiters.py — type checks pass

Vendor AdaptiveTokenBucket and RateLimiter into src/phoenix/server/rate_limiters.py
to decouple arize-phoenix from arize-phoenix-evals. This is the first step toward
removing the evals dependency from pyproject.toml.

Key changes:
- Copy AdaptiveTokenBucket and RateLimiter from phoenix-evals into server module
- Add async_on_rate_limit_error() using asyncio.sleep instead of time.sleep to
  avoid blocking the event loop in the server's async context
- Update playground_clients.py to import RateLimiter from server module
- Add comprehensive tests for the vendored implementation
@anticorrelator anticorrelator requested a review from a team as a code owner March 28, 2026 05:42
@mintlify
Copy link
Copy Markdown
Contributor

mintlify Bot commented Mar 28, 2026

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated (UTC)
arize-phoenix 🟢 Ready View Preview Mar 28, 2026, 5:43 AM

@github-project-automation github-project-automation Bot moved this to 📘 Todo in phoenix Mar 28, 2026
@dosubot dosubot Bot added the size:XL This PR changes 500-999 lines, ignoring generated files. label Mar 28, 2026
Comment thread src/phoenix/server/rate_limiters.py Outdated
Copy link
Copy Markdown
Contributor

@RogerHYang RogerHYang left a comment

Choose a reason for hiding this comment

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

Can you also update pyproject.toml to remove the dependency?

@github-project-automation github-project-automation Bot moved this from 📘 Todo to 👍 Approved in phoenix Mar 29, 2026
Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>
@claude
Copy link
Copy Markdown
Contributor

claude Bot commented Mar 29, 2026

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

@RogerHYang RogerHYang disabled auto-merge March 29, 2026 06:25
@RogerHYang RogerHYang enabled auto-merge (squash) March 29, 2026 06:26
@RogerHYang RogerHYang disabled auto-merge March 29, 2026 06:26
@RogerHYang RogerHYang merged commit 3c42b03 into main Mar 29, 2026
45 checks passed
@github-project-automation github-project-automation Bot moved this from 👍 Approved to ✅ Done in phoenix Mar 29, 2026
@RogerHYang RogerHYang deleted the dustin/vendor-token-bucket branch March 29, 2026 06:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XL This PR changes 500-999 lines, ignoring generated files.

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

vendor the token bucket algorithm for the phoenix server (de-couple from evals token bucket)

2 participants