Repository navigation
feat(search): per-source rate limits and concurrency for UnifiedSearch, plus real-world fixes (#373) - #380
Merged
Conversation
…arch (#373) rate_limits={source: seconds} sets the delay per source (wins over rate_limit_delay); source_concurrency (int or dict, default 1) caps simultaneous calls to one source across all threads sharing the object. The limits that applied are in report.metadata["effective_limits"], and diagnostics rows add rate_limit_delay, max_concurrency and waited_seconds. Without an explicit delay arXiv, DBLP and Zenodo are now paced at 3 s (their provider limit / own default) instead of 1.2 s. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 6 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. @@ Coverage Diff @@
## main #380 +/- ##
==========================================
+ Coverage 82.47% 82.52% +0.04%
==========================================
Files 216 216
Lines 32966 33052 +86
Branches 5957 5970 +13
==========================================
+ Hits 27190 27276 +86
Misses 4491 4491
Partials 1285 1285
|
…t swallowed failures Found by running the live services through UnifiedSearch: - rate_limit_delay was never applied to a successful request by the HTTP source clients; each client now reserves a start slot under a lock (BaseHTTPClient._wait_turn), so requests start >= delay apart (arXiv: 3.0 s) - search(sources=[...]) skipped sources outside the configured set; any registered source can be named, its client is created on first use - clients that caught their own failure (Semantic Scholar 403, OpenAlex, DBLP bot check) looked like empty sources; last_error is raised by UnifiedSearch - real-world tests against the live services Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
3 tasks done
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…erging main Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Per-source rate limiting and concurrency for
UnifiedSearch(closes #373), plus three defects that real-world runs against the live services exposed along the way.The feature (#373)
rate_limits={"arxiv": 5.0}: delay between requests per source; wins overrate_limit_delay. Order:rate_limits[source], an explicitrate_limit_delay, then 1.2 s but never below the provider's ask (arXiv, DBLP, Zenodo: 3 s, a default change, see "Changed" in the CHANGELOG).source_concurrency(intor{source: n}, default 1): simultaneous calls per source across all threads sharing the object;max_workersstays the sources-per-search level.report.metadata["effective_limits"]); diagnostics rows addrate_limit_delay,max_concurrency,waited_seconds.Found by running it for real (all fixed here)
rate_limit_delaywas never applied to a successful request by the HTTP source clients (arXiv, PubMed, DOAJ, CORE, HAL, Zenodo, DBLP, ClinicalTrials.gov): the sleep sat at the end of the retry loop, which a success leaves by returning. Measured on real arXiv with a 3 s delay: requests 0.3 s apart. Each client now reserves a start slot under a lock (BaseHTTPClient._wait_turn): arXiv now sees exactly 3.0 s between requests, from any number of threads. Searches over these sources are correspondingly slower, as the delays always intended.search(sources=[...])skipped sources outside the configured set without a word: the MCP toolunified_search(sources=["openalex", ...])returned only Europe PMC and PubMed. Any registered source can now be named; clients are created on first use; one that cannot be created isunavailablewith the real reason; an unknown name raisesValueError.[], so a source wasempty. They now recordlast_error, andUnifiedSearchraises it when the answer is empty:error/rate_limitedwith the real message.Live result for ten sources in one call: 8 ok (79 merged records, 6 papers matched by more than one source), Semantic Scholar
error: HTTPError 403, DBLPerror: JSONDecodeError.Test plan
test_unified_search_limits.py(21 + 11 new): delay order, validation, concurrency peaks, throttle (gaps, threads, first request free, zero delay), sources named in a call, creation oncetest_unified_search_diagnostics.py(+7): swallowed failures, rate limit viaRetry-After, partial results kept, no leak between calls, base client records non-JSON bodiestests/integration/test_real_world_unified_search.py(--run-integration, live): 11 sources reported honestly, matched sources, effective limits, and three overlapping searches reach arXiv >= the delay apartmypy src/: no issues in 220 files🤖 Generated with Claude Code