Cover parsed source cache parity#3535
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds a pytest module that compares generated output with and without the process-local parsed source cache across representative JSON Schema and OpenAPI fixtures. ChangesCache Parity Test
Estimated code review effort: 2 (Simple) | ~10 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
📚 Docs Preview: https://pr-3535.datamodel-code-generator.pages.dev |
bbe91f9 to
50fd4cf
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (1)
tests/main/test_parsed_source_cache_parity.py (1)
100-120: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueConsider a plain equality assertion instead of
assert_output.
assert_output(tests/conftest.py) is documented and used elsewhere for comparing generated output against a checked-in fixture file (e.g.EXPECTED_PATH / "output.py"). Herecached_outputis an ephemeraltmp_pathfile, not a fixture, which is a semantic mismatch even though it should work mechanically. A direct string comparison better documents intent and avoids relying on_assert_with_external_fileinternals (e.g., any fixture auto-update behavior) that aren't exercised in a meaningful way for a temp file.♻️ Suggested simplification
- assert_output(uncached_output.read_text(encoding="utf-8"), cached_output) + assert uncached_output.read_text(encoding="utf-8") == cached_output.read_text(encoding="utf-8")🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/main/test_parsed_source_cache_parity.py` around lines 100 - 120, The parity test currently uses assert_output to compare a tmp_path-generated file against another temp file, which is a mismatch with its fixture-comparison purpose. Update the test around _run_generate_with_parsed_source_cache to read both cached_output and uncached_output as strings and compare them directly with plain equality, so the intent is explicit and the test no longer depends on assert_output/_assert_with_external_file behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@tests/main/test_parsed_source_cache_parity.py`:
- Around line 100-120: The parity test currently uses assert_output to compare a
tmp_path-generated file against another temp file, which is a mismatch with its
fixture-comparison purpose. Update the test around
_run_generate_with_parsed_source_cache to read both cached_output and
uncached_output as strings and compare them directly with plain equality, so the
intent is explicit and the test no longer depends on
assert_output/_assert_with_external_file behavior.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: a592af3b-80d4-4841-b6d2-8574bdcd63aa
📒 Files selected for processing (1)
tests/main/test_parsed_source_cache_parity.py
Merging this PR will improve performance by 19.06%
|
| Mode | Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|---|
| ⚡ | WallTime | test_perf_all_options_enabled |
5.4 s | 4.5 s | +21.47% |
| ⚡ | WallTime | test_perf_multiple_files_input |
3.6 s | 2.9 s | +21.16% |
| ⚡ | WallTime | test_perf_complex_refs |
2 s | 1.7 s | +20.5% |
| ⚡ | WallTime | test_perf_aws_style_openapi_pydantic_v2 |
1.9 s | 1.6 s | +19.72% |
| ⚡ | WallTime | test_perf_large_models_pydantic_v2 |
3.6 s | 3 s | +19.3% |
| ⚡ | WallTime | test_perf_duplicate_names |
1,061.5 ms | 891.2 ms | +19.11% |
| ⚡ | WallTime | test_perf_deep_nested |
5.2 s | 4.4 s | +18.93% |
| ⚡ | WallTime | test_perf_openapi_large |
3 s | 2.5 s | +18.2% |
| ⚡ | WallTime | test_perf_stripe_style_pydantic_v2 |
2 s | 1.7 s | +18.19% |
| ⚡ | WallTime | test_perf_kubernetes_style_pydantic_v2 |
2.6 s | 2.2 s | +17.53% |
| ⚡ | WallTime | test_perf_graphql_style_pydantic_v2 |
785.4 ms | 678.7 ms | +15.72% |
Tip
Curious why this is faster? Comment @codspeedbot explain why this is faster on this PR, or directly use the CodSpeed MCP with your agent.
Comparing parsed-source-cache-parity (932a500) with main (cab75a2)
Footnotes
-
98 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3535 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 159 160 +1
Lines 34268 34295 +27
Branches 4001 4003 +2
=========================================
+ Hits 34268 34295 +27
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
50fd4cf to
6dac609
Compare
6dac609 to
932a500
Compare
Breaking Change AnalysisResult: No breaking changes detected Reasoning: The PR adds a single new test file (tests/main/test_parsed_source_cache_parity.py) that verifies generated output is identical with and without the process-local parsed source cache. It contains no changes to library/CLI source code, no removed options/parameters/functions, no template changes, no default behavior changes, and no deleted lines. Test-only additions cannot break existing users, so there are no breaking changes. This analysis was performed by Claude Code Action |
|
🎉 Released in 0.67.0 This PR is now available in the latest release. See the release notes for details. |
Summary by CodeRabbit