-
-
Notifications
You must be signed in to change notification settings - Fork 10.8k
perf(lint): skip and cache base gate passes, parallelize make lint, skip redundant prisma generate #32000
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
mateo-berri
merged 2 commits into
litellm_internal_staging
from
litellm_pre_commit_lint_speedups
Jul 3, 2026
Merged
perf(lint): skip and cache base gate passes, parallelize make lint, skip redundant prisma generate #32000
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| #!/usr/bin/env python3 | ||
| """Run ``prisma generate`` only when its inputs changed since the last run. | ||
|
|
||
| The generated client is a pure function of ``litellm/proxy/schema.prisma`` and | ||
| the installed prisma package version, so a stamp of those two written next to | ||
| the venv is enough to prove the client is current. The stamp lives under | ||
| ``sys.prefix`` so recreating the venv discards it, and a missing generated | ||
| client (a fresh or reinstalled prisma package) forces a regenerate even when | ||
| the stamp matches. The prisma package itself is never imported here: once | ||
| generated it re-exports the whole client on import, which costs more than the | ||
| generate this script exists to skip. | ||
| """ | ||
|
|
||
| import hashlib | ||
| import importlib.metadata | ||
| import importlib.util | ||
| import subprocess | ||
| import sys | ||
| from pathlib import Path | ||
|
|
||
| REPO_ROOT = Path(__file__).resolve().parent.parent | ||
| SCHEMA = REPO_ROOT / "litellm" / "proxy" / "schema.prisma" | ||
| STAMP = Path(sys.prefix) / "litellm-prisma-schema.stamp" | ||
|
|
||
|
|
||
| def stamp_value(schema_bytes: bytes, prisma_version: str) -> str: | ||
| return f"{hashlib.sha256(schema_bytes).hexdigest()}:{prisma_version}" | ||
|
|
||
|
|
||
| def should_skip(stamp: Path, expected: str, client_generated: bool) -> bool: | ||
| if not client_generated: | ||
| return False | ||
| try: | ||
| return stamp.read_text() == expected | ||
| except OSError: | ||
| return False | ||
|
|
||
|
|
||
| def client_is_generated() -> bool: | ||
| spec = importlib.util.find_spec("prisma") | ||
| if spec is None or not spec.submodule_search_locations: | ||
| return False | ||
| return any( | ||
| (Path(location) / "client.py").exists() | ||
| for location in spec.submodule_search_locations | ||
| ) | ||
|
|
||
|
|
||
| def main() -> int: | ||
| version = importlib.metadata.version("prisma") | ||
| expected = stamp_value(SCHEMA.read_bytes(), version) | ||
| if should_skip(STAMP, expected, client_is_generated()): | ||
| print( | ||
| f"Prisma client already generated for {SCHEMA.relative_to(REPO_ROOT)} " | ||
| f"(prisma {version}); skipping prisma generate" | ||
| ) | ||
| return 0 | ||
| result = subprocess.run( | ||
| [sys.executable, "-m", "prisma", "generate", "--schema", str(SCHEMA)], | ||
| cwd=REPO_ROOT, | ||
| ) | ||
| if result.returncode != 0: | ||
| return result.returncode | ||
| STAMP.write_text(expected) | ||
| return 0 | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| raise SystemExit(main()) |
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.