Commit 316ed39
fix(dspy): keep LiteLLM's 3MB price map out of the cassette
CI failed test_dspy(latest) on Windows across 3.11-3.14. Two separate
problems, both from the LiteLLM 1.100.1 -> 1.102.0 bump.
1.102.0 fetches model_prices_and_context_window.json from GitHub on import.
My earlier re-record captured it, which both bloated the cassette by ~3MB and
displaced the tiktoken cl100k_base download that CI needs and my machine
(warm tiktoken cache) never makes. Setting LITELLM_LOCAL_MODEL_COST_MAP keeps
the fetch off the wire entirely, so the cassette goes back to being about the
traffic under test -- it is now byte-identical to main again.
The env var is scoped to the DSPy session on purpose: an older LiteLLM's
bundled map does not know newer model names, and test_litellm(1.74.0) fails
provider resolution for gpt-image-1-mini under it.
Also make patcher module resolution consult sys.modules before importlib.
Separately, test_mistral(latest) failed on ubuntu/3.10 with
`KeyError: <thread id>` raised from importlib._bootstrap while resolve_root()
imported mistralai.client.chat -- CPython 3.10's re-entrancy bookkeeping
tripping over our own lock traffic. We call import_module for every patcher on
every setup(), almost always for a module that is already imported, so the
sys.modules fast path removes nearly all of it. That failure does not
reproduce locally (3/3 green on 3.10), so this is a mitigation rather than a
proven cure; it is a worthwhile change on its own merits either way.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>1 parent 9b4868c commit 316ed39
4 files changed
Lines changed: 200811 additions & 35372 deletions
File tree
- py
- src/braintrust/integrations
- dspy/cassettes/latest
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
363 | 363 | | |
364 | 364 | | |
365 | 365 | | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
366 | 375 | | |
367 | 376 | | |
368 | 377 | | |
| |||
597 | 606 | | |
598 | 607 | | |
599 | 608 | | |
600 | | - | |
| 609 | + | |
601 | 610 | | |
602 | 611 | | |
603 | 612 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
93 | 93 | | |
94 | 94 | | |
95 | 95 | | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
| 96 | + | |
100 | 97 | | |
101 | 98 | | |
102 | 99 | | |
| |||
147 | 144 | | |
148 | 145 | | |
149 | 146 | | |
150 | | - | |
151 | | - | |
152 | | - | |
153 | | - | |
| 147 | + | |
154 | 148 | | |
155 | 149 | | |
156 | 150 | | |
| |||
274 | 268 | | |
275 | 269 | | |
276 | 270 | | |
277 | | - | |
278 | | - | |
279 | | - | |
280 | | - | |
| 271 | + | |
281 | 272 | | |
282 | 273 | | |
283 | 274 | | |
| |||
636 | 627 | | |
637 | 628 | | |
638 | 629 | | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
639 | 648 | | |
640 | 649 | | |
641 | 650 | | |
642 | | - | |
643 | | - | |
644 | | - | |
645 | | - | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
646 | 654 | | |
647 | 655 | | |
648 | 656 | | |
| |||
0 commit comments