Skip to content

Cover parsed source cache parity#3535

Merged
koxudaxi merged 1 commit into
mainfrom
parsed-source-cache-parity
Jul 2, 2026
Merged

Cover parsed source cache parity#3535
koxudaxi merged 1 commit into
mainfrom
parsed-source-cache-parity

Conversation

@koxudaxi

@koxudaxi koxudaxi commented Jul 2, 2026

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • Tests
    • Added a new parity test that compares generated Python output between runs with the parsed-source cache enabled and with the cache cleared.
    • Runs the generator with consistent CLI options (including timestamp disabling) and validates exact output equality across multiple reference-heavy JSON Schema and OpenAPI fixtures, supporting optional extra arguments.

@coderabbitai

coderabbitai Bot commented Jul 2, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 1f59d263-2bb3-4794-88c1-77d42235ad5b

📥 Commits

Reviewing files that changed from the base of the PR and between 6dac609 and 932a500.

📒 Files selected for processing (1)
  • tests/main/test_parsed_source_cache_parity.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/main/test_parsed_source_cache_parity.py

📝 Walkthrough

Walkthrough

Adds a pytest module that compares generated output with and without the process-local parsed source cache across representative JSON Schema and OpenAPI fixtures.

Changes

Cache Parity Test

Layer / File(s) Summary
CLI helpers and cache-aware runner
tests/main/test_parsed_source_cache_parity.py
Helpers map InputFileType to CLI values, build base CLI arguments, and clear the parsed source cache before invoking run_main_with_args with cache toggled on or off.
Parametrized fixtures and parity assertion
tests/main/test_parsed_source_cache_parity.py
A parametrized test matrix covers multiple JSON Schema/OpenAPI fixtures, generating output into separate temp paths and asserting the cached and uncached results match exactly.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adding coverage for parsed source cache parity.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch parsed-source-cache-parity

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

📚 Docs Preview: https://pr-3535.datamodel-code-generator.pages.dev

@koxudaxi koxudaxi force-pushed the parsed-source-cache-parity branch from bbe91f9 to 50fd4cf Compare July 2, 2026 06:13

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
tests/main/test_parsed_source_cache_parity.py (1)

100-120: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Consider 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"). Here cached_output is an ephemeral tmp_path file, 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_file internals (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

📥 Commits

Reviewing files that changed from the base of the PR and between cab75a2 and bbe91f9.

📒 Files selected for processing (1)
  • tests/main/test_parsed_source_cache_parity.py

Comment thread tests/main/test_parsed_source_cache_parity.py
@codspeed-hq

codspeed-hq Bot commented Jul 2, 2026

Copy link
Copy Markdown

Merging this PR will improve performance by 19.06%

⚠️ Unknown Walltime execution environment detected

Using the Walltime instrument on standard Hosted Runners will lead to inconsistent data.

For the most accurate results, we recommend using CodSpeed Macro Runners: bare-metal machines fine-tuned for performance measurement consistency.

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 11 improved benchmarks
⏩ 98 skipped benchmarks1

Performance Changes

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)

Open in CodSpeed

Footnotes

  1. 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

codecov Bot commented Jul 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (cab75a2) to head (932a500).

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     
Flag Coverage Δ
unittests 100.00% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@koxudaxi koxudaxi force-pushed the parsed-source-cache-parity branch from 50fd4cf to 6dac609 Compare July 2, 2026 06:21
@koxudaxi koxudaxi force-pushed the parsed-source-cache-parity branch from 6dac609 to 932a500 Compare July 2, 2026 06:28
@koxudaxi koxudaxi merged commit 4f20c04 into main Jul 2, 2026
61 checks passed
@koxudaxi koxudaxi deleted the parsed-source-cache-parity branch July 2, 2026 06:51
@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Breaking Change Analysis

Result: 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

@github-actions

github-actions Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

🎉 Released in 0.67.0

This PR is now available in the latest release. See the release notes for details.

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