Skip to content

Walk to an existing ancestor and place the staging directory in one place each - #5723

Merged
Koudai Aono (koxudaxi) merged 1 commit into
mainfrom
impl-batch-l
Oct 31, 2026
Merged

Koudai Aono (koxudaxi) merged 1 commit into
mainfrom
impl-batch-l

Conversation

@koxudaxi

@koxudaxi Koudai Aono (koxudaxi) commented Oct 31, 2026 •

Copy link
Copy Markdown
Member

Summary by CodeRabbit

  • Improvements
    • Improved handling of relative output paths and destinations located within an output directory when preparing generated files.
    • Improved discovery of existing directories for output creation, remote locking, and dependency watching, while retaining established behavior for legacy path cases.
    • When a required directory cannot be found, existing remote-lock error reporting is preserved.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-31T01:37:36.742960Z 576f792 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 66d0fba and 576f792.

Files ignored due to path filters: 9
  • docs/llms-full.txt is excluded by none and included by none
  • tests/data/decision_homes/homes.toml is excluded by none and included by none
  • tests/data/expected/decision_homes/decision_home_allowlist_is_written_from_the_scan_and_only_lowered.lowered.txt is excluded by !tests/data/**/*.txt and included by none
  • tests/data/expected/decision_homes/decision_home_allowlist_is_written_from_the_scan_and_only_lowered.seeded.txt is excluded by !tests/data/**/*.txt and included by none
  • tests/data/expected/decision_homes/decision_home_allowlist_is_written_from_the_scan_and_only_lowered.sizes.txt is excluded by !tests/data/**/*.txt and included by none
  • tests/data/expected/decision_homes/decision_home_cli_reports_and_writes_the_allowlist.txt is excluded by !tests/data/**/*.txt and included by none
  • tests/data/expected/decision_homes/decision_home_detector_reports_every_signature_kind.txt is excluded by !tests/data/**/*.txt and included by none
  • tests/data/expected/decision_homes/decision_home_planned_places_cover_hits_until_they_exist.txt is excluded by !tests/data/**/*.txt and included by none
  • tests/data/expected/decision_homes/decision_home_table_rejects_malformed_entries[unknown-kind].txt is excluded by !tests/data/**/*.txt and included by none
Files selected for processing: 10
  • docs/architecture.md
  • scripts/check_decision_homes.py
  • scripts/decision_homes.toml
  • src/datamodel_code_generator/_api_generation.py
  • src/datamodel_code_generator/_paths.py
  • src/datamodel_code_generator/_publication.py
  • src/datamodel_code_generator/remote_lock.py
  • src/datamodel_code_generator/watch_dependencies.py
  • tests/data/decision_homes/src/other.py
  • tests/test_decision_homes.py

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review.

Walkthrough

The pull request adds a shared path-ancestor helper and uses it in publication, staging, remote-lock, and watch-dependency code. It also updates decision-home checks and records the related decisions and legacy behaviors.

Changes: Ancestor Lookup

Layer / File(s) Summary
Shared ancestor lookup and callers
src/datamodel_code_generator/_paths.py, src/datamodel_code_generator/_publication.py, src/datamodel_code_generator/_api_generation.py, src/datamodel_code_generator/remote_lock.py, src/datamodel_code_generator/watch_dependencies.py
Adds existing_ancestor with configurable matching, root handling, and missing-path collection. Publication, staging, remote-lock, and watch-dependency code now use it. Staging selection accepts optional cwd and around paths.
Decision-home signatures and records
scripts/check_decision_homes.py, scripts/decision_homes.toml, tests/data/decision_homes/src/other.py, tests/test_decision_homes.py, docs/architecture.md
Adds an ancestor-walk signature to the checker and a fixture for that signature. Adds decision records and documents the ancestor lookup modes and two legacy behaviors.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Refactor

Possibly related issues

  • datamodel-code-generator/datamodel-code-generator issue 5722: The pull request updates the ancestor walks associated with staging, publication anchors, and parent creation.
  • datamodel-code-generator/datamodel-code-generator issue 5618: The pull request changes staging-parent selection and documents the case where the nearest existing ancestor is a regular file.

Possibly related PRs

Merge Risk: Minimal · up to 576f7

No merge-blocking issue is identified. The ancestor-lookup consolidation and decision-home updates appear mergeable subject to normal checks.

Pre-merge checks: Passed 5
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 changes: walking to an existing ancestor and centralizing staging-directory placement. It is specific and related to the changeset.
Docstring Coverage Passed Docstring coverage is 85.71% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentati…
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.
Full details: Docstring Coverage

Explanation

Docstring coverage is 85.71% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 7 functions across 8 files. (2 skipped: 2 unsupported.)

Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

Copy link
Copy Markdown
Contributor

@codecov

codecov Bot commented Oct 31, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@codspeed

codspeed Bot commented Oct 31, 2026

Copy link
Copy Markdown

Merging this PR will degrade performance by 18.9%

2 warnings

⚠️ Walltime results may be unreliable

Some benchmarks used the Walltime instrument outside CodSpeed Macro Runners, which can make the results inconsistent.

Learn more about Macro Runners

See affected benchmarks

⚠️ 49 benchmarks with a significant change ran on different hardware

Their base and head results were measured on machines with a different CPU, core count or memory, so the changes might not come from the code. Run base and head on the same runner type.

Learn more about Macro Runners

See affected benchmarks

❌ 49 regressed benchmarks
✅ 3 untouched benchmarks
⏩ 98 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Benchmark BASE HEAD Efficiency
❌ test_perf_load_pyproject_config[mapping-None] 257 µs 372.4 µs -30.98%
❌ test_perf_load_pyproject_config[config-None] 253.2 µs 364.4 µs -30.51%
❌ test_perf_load_pyproject_config[mapping-multiple] 267.8 µs 381.9 µs -29.89%
❌ test_perf_load_pyproject_config[config-multiple] 269.9 µs 381.5 µs -29.25%
❌ test_perf_pattern_properties_adapter_reuse 3 ms 4 ms -24.68%
❌ test_perf_client_calls[async] 35.8 ms 47.4 ms -24.44%
❌ test_perf_client_calls[sync] 32 ms 42.4 ms -24.4%
❌ test_perf_recommend_options_full_kubernetes_style 13.9 s 18 s -23.05%
❌ test_perf_deep_nested 4.5 s 5.8 s -22.07%
❌ test_perf_kubernetes_style_pydantic_v2 2.3 s 2.9 s -21.4%
❌ test_perf_extreme_large_schema 13.5 s 17 s -20.83%
❌ test_perf_empty_pydantic_v2_field_render_plans 29.5 ms 37.3 ms -20.78%
❌ test_perf_all_options_enabled 5 s 6.3 s -20.72%
❌ test_perf_complex_refs 1.8 s 2.2 s -20.59%
❌ test_perf_large_models_pydantic_v2 3.1 s 3.9 s -20.24%
❌ test_perf_pydantic_field_name_resolution 2.2 ms 2.7 ms -20%
❌ test_perf_stripe_style_pydantic_v2 1.8 s 2.3 s -19.41%
❌ test_perf_multiple_files_input 3.3 s 4 s -18.8%
❌ test_perf_target_render[client-large] 6.6 s 8.2 s -18.57%
❌ test_perf_graphql_style_pydantic_v2 732.3 ms 899 ms -18.55%
... ... ... ... ...

ℹ️ Only the first 20 benchmarks are displayed. Go to the app to view all benchmarks.

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing impl-batch-l (576f792) with main (66d0fba)

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

@koxudaxi
Koudai Aono (koxudaxi) merged commit 8c80d25 into main Oct 31, 2026
163 of 164 checks passed
@koxudaxi
Koudai Aono (koxudaxi) deleted the impl-batch-l branch October 31, 2026 01:51
@github-actions

Copy link
Copy Markdown
Contributor

Breaking Change Analysis

Result: No breaking changes detected

Reasoning: This PR is an internal refactor and adds no breaking changes. It moves several hand-written loops that climb a path's parents (in _publication.py publication_anchor, staging_directory_for and _create_target_parent, in _api_generation.py _staging, in remote_lock.py _nearest_existing_directory and in watch_dependencies.py _nearest_existing_directory) into one new private helper, _paths.existing_ancestor. The helper has named rows that keep each caller's old behaviour. The publication walks still keep going past a root that does not exist (legacy-unbounded-ancestor-walk). Private staging still accepts any existing path, a regular file included (legacy-staging-parent-may-be-a-file). The remote lock still raises RemoteLockError with the same message at a missing root, and the watcher still returns the root. staging_directory_for is in a private module and only gains optional keyword-only cwd and around parameters. With neither given, it computes the same staging parent as before, and _api_generation._staging now calls it with the same logic it had inline. Everything else is tooling, docs and tests: a new ancestor-walk signature kind in scripts/check_decision_homes.py, new rows in decision_homes.toml, two new architecture doc rows, and decision-home test fixtures. No CLI option, public Python API, template, Python version support or error message changes. The behaviour diff gate does list accepted cells, but all of them are allOf intersection changes that come from earlier work since the last release, which the gate notes credit to 5401. This PR does not touch any parser or model code, so those cells are not caused by this diff.


This analysis was produced by the release draft workflow

@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

🎉 Released in 0.88.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.

1 participant