Repository navigation
refactor(sdk): separate core AWS and tokenizer dependencies - #44447
Conversation
|
bugbot run |
|
|
@greptileai Please review the child-only diff against litellm_lean_sdk_dependencies at e83dac0. Current head is ee53ccc. This PR makes AWS, Hugging Face and validation dependencies optional; the parent owns UI/CLI extraction. Independent source verification passed; CI is running. |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
|
@greptileai @veria-ai Please review current tip d5f7570. The runtime tokenizer aliases now support core tiktoken/native callers without Hugging Face; installed and broken-import cases have regressions. Added real Polly/SageMaker signing and missing-extra tests. Local canonical checks and clean wheel profiles passed; focused independent verification is running. |
|
bugbot run |
|
@greptileai @veria-ai Please refresh review at 380ec95. The only change from d5f7570 is an empty Polly test-package init.py to satisfy the package-layout CI test. Runtime and wheel contents are unchanged; mapped tests and canonical lint pass. |
|
bugbot run |
380ec95 to
9238874
Compare
|
@greptileai @veria-ai Please review the rebased tip; scoped local checks pass and independent verification is refreshing. bugbot run |
|
@greptileai @veria-ai Please review the current tip. Callback configuration now uses a scoped standard-library patch; refreshed local checks pass. bugbot run |
|
bugbot run Please review the current rebased tip against its immediate parent; local lint and installation checks pass. |
80f9bc4 to
08acbf8
Compare
|
bugbot run Please review refreshed tip |
| if TYPE_CHECKING: | ||
| from litellm.litellm_core_utils.tokenizer import Encoding, HuggingFace |
There was a problem hiding this comment.
Tokenizer types cannot be inspected
Moving Encoding behind TYPE_CHECKING makes get_type_hints(openai_tokenizer_encoding) raise NameError instead of returning its types. The same problem affects tokenizer functions in litellm/rust_bridge/tokenizer.py. Keep the annotation names available at runtime without eagerly loading optional packages
614e1f1 to
034f2f0
Compare
|
@greptileai @veria-ai Please review |
|
bugbot run Please review |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 034f2f0. Configure here.
034f2f0 to
a5f8524
Compare
TLDR
Problem this solves:
How it solves it:
User Flow
Before: core installs AWS and Hugging Face dependencies for every application
litellm-corewheelAfter: core works without those packages, with explicit installation for Python features that require them
litellm-corewheelboto3for AWS signing/event decoding andtokenizers huggingface-hubfor Python Hugging Face tokenizationRelevant issues
Second of two existing PRs, depending on #44340. Head
litellm_optional_aws_tokenizerstargetslitellm_lean_sdk_dependenciesatfb233676cc22a066918306819b34b8a717745048Replayed only the child commits onto the updated parent, preserving upstream tests and SDK regression tests through the four append conflicts. The final child contains sixteen commits beyond the recorded parent boundary, including the scoped test-helper and Bedrock request-typing fixes
Release integration remains separate in project-releaser #293
Implementation
Core removes boto3, tokenizers, and huggingface-hub from mandatory dependencies and declares python-dateutil directly. jsonschema remains mandatory. Shared optional-import handling preserves actionable missing-package errors without masking unrelated import failures or retrying installation errors. Bedrock bearer preparation works without botocore; credential resolution, SigV4 signing and event decoding retain their existing implementations. Python tokenizer loading is deferred while native execution, runtime aliases, added-token decoding and sanitized fallback warnings remain supported. Legacy dependencies and lockfiles are unchanged
Squash and merge order
Both PRs remain open: #44340, head
litellm_lean_sdk_dependencies, targetsmain. #44447, headlitellm_optional_aws_tokenizers, targetslitellm_lean_sdk_dependenciesSquash-merge #44340 first when approved. Record its final head before merging. Then fetch
main, replay only the child commits withgit rebase --onto origin/main fb233676cc22a066918306819b34b8a717745048 <child-branch>, and retarget #44447 tomain. That boundary must be updated if the parent changes again. Inspect the child-only diff and refresh verification afterwardLocal squash rehearsal replayed the child commits cleanly and preserved the final file tree. Backup refs retain both pre-restack tips. No PR has been merged
Current verification
Current tip:
034f2f0b7ff685ff33d228e150bb388c00096f75. Parent targetsmainat591637d47571f82c8181ec020c07d68c890ed226; child targets parentfb233676cc22a066918306819b34b8a717745048. All ten parent patches and sixteen child patches remain identical. Both refreshed trees exactly match their previous tips combined with the three new main commitsThe refresh contains Akto logging-only support, OpenRouter pricing data and an encrypted-reasoning Router fallback fix. No Rust, packaging, dependency, AWS-auth or tokenizer implementation changed. Focused router/fallback checks passed 89 tests; the local proxy cases could not collect because the reused environment lacks APScheduler and remain covered by the hosted proxy suite
Whole Ruff, test-tree lint, formatting, strict-rule, type-discipline, test-quality, basedpyright, import and lock gates pass for both refreshed tips. CI and bot reviews are refreshing after the push
The completed independent source-build report covers parent
e8bd3e51ab12075f2a13c927eded80fd8f67f527and child614e1f175eef4874cf1aca7063270ea94bdefdd8against main1a42c5abde9a44c225e6526b589df67a782b826b. All ten source artifacts built successfully, parent and child standalone sdist rebuilds matched their wheels, installed core/legacy and co-install guard checks passed, and real proxy-to-OpenAI normal/streaming calls matched baseline with HTTP 200, pong and usage 13/4/17That report found no regressions. Its 49 native trace failures/errors were identical on baseline and child and were blocked by Docker Hub rate limiting for the ClickHouse test image. The existing hosted Rust import failure remains separately classified as unrelated
The agreed refresh scope preserves that evidence for the unchanged SDK patches and uses targeted router checks for the new interaction. No full Devin rerun or fresh artifact-build claim is made for the latest three-commit refresh. Historical reports below retain their exact tested SHAs
Pre-Submission checklist
Screenshots / Proof of Fix
Independent verification completed on October 8 in the Devin session, using fresh wheels and source archives from these exact commits
5d207d85ee547bc323d704bc6aaab901aa0be8b6dd1fd3b42c12b841cdfc5e87f6afdedba8268b67029a626c99ec8c6012512b18ecea075a90db9dcd5ed9ef148c612a9ce70b8a5c6649415bb41305ae/3e2229f5d14f894a4c981fab382241243421ed81Before (
5d207d8and parentdd1fd3b)/ui/,/ui/login/, favicon, JavaScript/CSS assets, custom UI, non-root fallback and the configured/litellmroot pathAfter (
029a626)pip checkclean and all 714 installed dashboard files matching their wheelReal proxy to real provider, October 9
The remaining proxy-path check passed on baseline
5d207d85ee547bc323d704bc6aaab901aa0be8b6and final child029a626c99ec8c6012512b18ecea075a90db9dcd. Each proxy used its source-built legacy wheel, with installed files checked against that wheel: 3,690 baseline files and 3,691 child files, zero mismatchesBoth proxies used this configuration, resolving credentials from environment variables
Baseline listened on port 4131, child on 4132. The same request was sent through each proxy to the real OpenAI provider
Repeat with port 4132 for the child. Streaming used the same body with
"stream":true,"stream_options":{"include_usage":true}pong, finish reasonstoppong, finish reasonstop[DONE],pong, usage 13/4/17[DONE],pong, usage 13/4/17Proxy access logs recorded HTTP 200 for both requests on both proxies. The secret scan found no key-pattern matches. Both task-owned proxies were stopped and their ports closed afterward; no source changes or rebuilds were needed
Redacted proxy smoke evidence, executed script, baseline response, child response
Authenticated dashboard coverage remains outside the executed checks
Evidence: case map, commands and run record, 39-case release output, proxy/UI output, AWS/tokenizer output, live-provider output. Attachments may require organization access
Coverage limits: no aarch64, musllinux, macOS or Windows builds, no manylinux_2_28 Docker leg, and no real publishing, OIDC or dispatch. The platform completeness negative correctly rejected 30 missing cells. Router calls were exercised, but Router-level retry behavior was not
Two behaviors matched baseline and are outside this change: optional MCP/Tenacity requirements for Responses/retries, and root-path UI file rewriting. The UI result above uses the clean copy-mode rerun, replacing an earlier run affected by shared hardlinks
Type
Refactoring, infrastructure and tests
Caveats
Severe
Medium
Final Attestation
Note
Medium Risk
Touches Bedrock/SageMaker auth, token counting fallbacks, and core package dependencies—behavior changes when optional packages are missing, though tests and CI profiles aim to lock that in.
Overview
Makes
litellm-coreleaner by dropping mandatoryboto3,tokenizers, andhuggingface-hubfrompackaging/litellm-core/pyproject.toml(addspython-dateutilexplicitly;jsonschemastays required).Optional dependencies load on demand. New
ensure_optional_importcentralizes actionablepip install …errors. AWS paths (Bedrock, SageMaker, Polly, secrets manager, S3 Focus upload) importboto3/botocoreonly when signing or uploading. Bearer-token Bedrock requests use aBearerPreparedRequestpath that does not need botocore. Tokenizer code deferstokenizersimports, keeps native/Rust paths, falls back to tiktoken with redacted warnings, and exposes runtime type aliases via__getattr__.Error handling tightens.
ImportError/ModuleNotFoundErrorforboto3/botocore(and Bedrock providers) pass through exception mapping unchanged; async retries skipImportError.Verification expands. Base SDK smoke checks gain
--profilemodes (corevsdependencies), a loopback HTTP harness (check_sdk_http.py), and CI runs core installs without optional packages before installing AWS/tokenizer deps for fuller checks.Reviewed by Cursor Bugbot for commit 034f2f0. Bugbot is set up for automated code reviews on this repo. Configure here.