feat: Improve rate limiter implementation#8
Merged
Conversation
…ructure - Migrate rate limiting utilities from `pybdl.api.utils` to `pybdl.utils.rate_limiter` - Update import paths in documentation and client code to reflect new structure - Remove deprecated files related to rate limiting - Introduce a base class for shared logic between synchronous and asynchronous rate limiters - Ensure backward compatibility with existing functionality while improving organization
…rkflow - Simplified the release workflow by removing the push and pull_request triggers, retaining only the workflow_dispatch event.
- Adjusted the example formatting in the BaseAccess class to use a block-style example for clarity.
- Bump project version in pyproject.toml from 0.0.1 to 0.1.0. - Include .worktrees directory in .gitignore to prevent tracking of worktree files.
- Streamlined the type conversion process for DataFrame columns in the BaseAccess class. - Enhanced checks for object and string dtypes before attempting conversion to numeric or boolean types. - Improved handling of non-null values to ensure accurate type casting.
- Refactored the numeric conversion checks for DataFrame columns to improve readability and efficiency. - Consolidated conditional statements for dtype checks and non-null value handling. - Ensured accurate type casting for integer-like values in the DataFrame.
… BaseAPIClient - Added new module for HTTP caching utilities, including functions to build sync and async HTTP clients with caching support. - Updated BaseAPIClient to utilize new caching functions, improving cache management and client initialization. - Implemented helper functions to determine if responses are served from cache. - Added tests for caching functionality to ensure correct behavior across different cache backends.
Contributor
Test Results553 tests 542 ✅ 7s ⏱️ Results for commit 61475cf. ♻️ This comment has been updated with latest results. |
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
Rate limiting and HTTP response caching move from
pybdl.api.utilsintopybdl.utils, withBaseAPIClientcalling dedicated HTTP client factories.BaseAccesscolumn typing is tightened for object and string dtypes. The branch also bumps the version to 0.1.0, limits releases toworkflow_dispatch, ignores.worktrees/, and updatesuv.lock.Purpose & Context
Keeping transport concerns (hishel-backed caching, quota persistence) under
pybdl.utilsclarifies layering: the API package stays oriented around BDL client behavior while public symbols remain available frompybdl.utils.rate_limiter. Factoring HTTP cache setup intopybdl.utils.http_cacheisolates testable construction logic. The access-layer change reduces fragile coercion when columns are already typed or empty and aligns behavior with current pandas APIs.Changes Made
pybdl.utils.rate_limiter(_sync,_async,_cache,_decorators, shared base); removespybdl.api.utilsrate limiter andquota_cachemodules. Docs and tests import frompybdl.utils.rate_limiter; package tests cover the exported API.pybdl.utils.http_cachefor cache DB path resolution, sync/async client builders, and cache-hit inspection;pybdl/api/client.pyconsumes these.pybdl/access/base.py_convert_column_typesand RST example fix; release workflow,.gitignore, version, lockfile.Testing
uv run pytest tests/unit/utils/utils/test_http_cache.py tests/unit/utils/utils/rate_limiter/ tests/unit/api/test_api_client_cache.py— 75 passed. Full suite and Sphinx build were not run for this description.Breaking Changes & Migration Notes
Anyone importing from
pybdl.api.utils.rate_limiter(or the removedquota_cachemodule) must switch topybdl.utils.rate_limiter(and usePersistentQuotaCachefrom there). Behavior of rate limiting and HTTP caching is intended to be equivalent; verify any code that relied on undocumented internal modules.Review Focus Areas
resolve_http_cache_db_pathties the on-disk cache to the quota cache file location; confirm this still matches deployment and multi-process expectations.Dependencies & Side Effects
uv.lockhas a large refresh alongside the version bump; reviewers may want to skim dependency deltas if supply-chain or reproducibility policies apply.