Skip to content
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

Optimized traversal of schema tree for schema cleaning (GenerateSchema.clean_schema) #1487

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

MarkusSintonen
Copy link
Contributor

@MarkusSintonen MarkusSintonen commented Oct 18, 2024

Change Summary

Adds schema tree traversal which gathers necessary schema nodes and information for schema inlining and discriminator handling. Schema tree traversal is done in a single pass gathering the needed information. This is used in GenerateSchema.clean_schema handling. Required for PR pydantic/pydantic#10655 This makes schema cleaning much more efficient where the biggest bottleneck has been the Python side tree traversal. This especially with lots of models or deep models.

Related issue number

See above Pydantic side PR.

Checklist

  • Unit tests for the changes exist
  • Documentation reflects the changes where applicable
  • Pydantic tests pass with this pydantic-core (except for expected changes)
  • My PR is ready to review, please add a comment including the phrase "please review" to assign reviewers

Selected Reviewer: @sydney-runkle

Copy link

codecov bot commented Oct 18, 2024

Codecov Report

Attention: Patch coverage is 98.86364% with 1 line in your changes missing coverage. Please review.

Project coverage is 89.13%. Comparing base (ab503cb) to head (4765254).
Report is 196 commits behind head on main.

Files with missing lines Patch % Lines
src/schema_traverse.rs 98.71% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1487      +/-   ##
==========================================
- Coverage   90.21%   89.13%   -1.09%     
==========================================
  Files         106      113       +7     
  Lines       16339    17915    +1576     
  Branches       36       40       +4     
==========================================
+ Hits        14740    15968    +1228     
- Misses       1592     1927     +335     
- Partials        7       20      +13     
Files with missing lines Coverage Δ
python/pydantic_core/__init__.py 93.10% <100.00%> (+0.51%) ⬆️
src/lib.rs 100.00% <100.00%> (+12.85%) ⬆️
src/schema_traverse.rs 98.71% <98.71%> (ø)

... and 51 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 92a259e...4765254. Read the comment docs.

Copy link

codspeed-hq bot commented Oct 18, 2024

CodSpeed Performance Report

Merging #1487 will not alter performance

Comparing MarkusSintonen:schema-gather (4765254) with main (92a259e)

Summary

✅ 155 untouched benchmarks

@MarkusSintonen MarkusSintonen changed the title Optimized traversal for schema node gathering for schema cleaning Optimized traversal of schema nodes for schema cleaning Oct 18, 2024
@MarkusSintonen
Copy link
Contributor Author

please review

@MarkusSintonen MarkusSintonen changed the title Optimized traversal of schema nodes for schema cleaning Optimized traversal of schema tree for schema cleaning (GenerateSchema.clean_schema) Oct 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants