Skip to content

fix(BA-6015): persist resolved model-definition path when set None from request#11638

Open
seedspirit wants to merge 3 commits into
mainfrom
fix/BA-6015
Open

fix(BA-6015): persist resolved model-definition path when set None from request#11638
seedspirit wants to merge 3 commits into
mainfrom
fix/BA-6015

Conversation

@seedspirit
Copy link
Copy Markdown
Contributor

@seedspirit seedspirit commented May 15, 2026

Problem

When a request omits model_definition_path, the model service revision was persisted with the request's empty / None value instead of the model-definition file actually resolved from the model vfolder. The resolved path was used at runtime but never written back, so the stored revision did not reflect what was really mounted.

Fix

The vfolder scan now records the matched candidate path (model-definition.yaml / .yml, or an explicit override) back into the merged draft, so the resolved model_definition_path is persisted on the revision instead of the empty input value.

How (mechanism)

To do this cleanly, mount identity (model vfolder, definition path, destination, extra mounts, subpath) is folded into RevisionDraft and participates in the merge chain, instead of being threaded as a separate sidecar mounts argument through add_revision and the draft readers:

  • New FetchedModelDefinition / FetchedConfigFile types carry the matched filename out of the storage source so the resolved path can flow back into the draft.
  • _merge_mounts uses upper-priority semantics with None-fallback for model_definition_path / vfolder_subpath; every other mount field is sourced from the same request_draft.mounts, so the merge cannot tangle values.
  • ModelRevisionCreator.to_draftto_draft_with_extra_mount: the creator derives the full MountMetadata from self.mounts and only takes the permission-resolved extra_mounts.

Test plan

  • pants test tests/unit/manager/data/deployment:: tests/unit/manager/sokovan/deployment::
  • v2 add-revision with no model_definition_path: resolved model-definition.yml path is persisted on the revision
  • Explicit model_definition_path override on modify takes precedence over the resolved/stored path
  • Legacy ModifyEndpoint: untouched mount fields (extra mounts, destination, subpath) survive a replica-only modify

Resolves BA-6015

@github-actions github-actions Bot added size:L 100~500 LoC comp:manager Related to Manager component labels May 15, 2026
seedspirit added a commit that referenced this pull request May 15, 2026
@seedspirit seedspirit changed the title fix(BA-6015): carry mount metadata in RevisionDraft merge chain fix(BA-6015): persist resolved model-definition path when omitted from request May 15, 2026
@seedspirit seedspirit changed the title fix(BA-6015): persist resolved model-definition path when omitted from request fix(BA-6015): persist resolved model-definition path when set None from request May 18, 2026
@seedspirit seedspirit marked this pull request as ready for review May 18, 2026 04:13
@seedspirit seedspirit requested a review from a team as a code owner May 18, 2026 04:13
Copilot AI review requested due to automatic review settings May 18, 2026 04:13
@seedspirit seedspirit added this to the 26.4 milestone May 18, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes BA-6015 by ensuring the resolved model_definition_path (auto-detected from the model vfolder or explicitly overridden) is written back into the merged RevisionDraft, so the persisted deployment revision reflects the actual mounted model-definition file.

Changes:

  • Fold mount identity (MountMetadata) into RevisionDraft and make it participate in the merge chain (including persistence and spec projection).
  • Introduce FetchedModelDefinition / FetchedConfigFile to propagate the matched vfolder filename back into the draft.
  • Update legacy/v2 revision creation flows and add unit tests to verify resolved path persistence and merge semantics.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/unit/manager/sokovan/deployment/test_revision_draft_reader.py Adds coverage ensuring vfolder-resolved model-definition path is recorded into merged mounts.
tests/unit/manager/data/deployment/test_revision_draft_merge.py Adds coverage for model_definition_path “None means fallback” merge behavior.
src/ai/backend/manager/sokovan/deployment/revision_draft/reader.py Uses request_draft.mounts as the mount context and writes resolved definition path back into a draft layer.
src/ai/backend/manager/sokovan/deployment/deployment_controller.py Removes sidecar mounts arg and persists mounts from the merged draft, including resolved definition path.
src/ai/backend/manager/services/model_serving/services/model_serving.py Adapts legacy ModifyEndpoint flow to the new mounts-in-draft merge/persist behavior.
src/ai/backend/manager/repositories/deployment/storage_source/storage_source.py Returns matched config filename/payload wrapper and returns FetchedModelDefinition with matched path.
src/ai/backend/manager/repositories/deployment/repository.py Adjusts fetch-model-definition typing/docs to return FetchedModelDefinition.
src/ai/backend/manager/data/deployment/types.py Adds FetchedModelDefinition, adds mounts to RevisionDraft, adds _merge_mounts, and updates spec projection.
src/ai/backend/manager/data/deployment/creator.py Renames projection to to_draft_with_extra_mount to inject permission-resolved extra mounts into draft mounts.
changes/11638.fix.md Towncrier entry for the fix.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/ai/backend/manager/data/deployment/types.py Outdated
@github-actions github-actions Bot added the comp:common Related to Common component label May 18, 2026
preset_values: list[PresetValueData] = field(default_factory=list)

def to_draft(self) -> RevisionDraft:
def to_draft_with_extra_mount(self, extra_mounts: list[MountInfoEntry]) -> RevisionDraft:
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Used in DeploymentController. This has been updated to include mount information in RevisionDraft. Structural improvements are needed going forward.

seedspirit and others added 3 commits May 18, 2026 14:30
Mount identity (model vfolder, definition path, destination, extra
mounts, subpath) now travels inside RevisionDraft and participates in
the merge chain instead of being threaded as a sidecar argument through
add_revision and the draft readers. The vfolder scan records the
matched candidate path back into the merged draft, so the resolved
model-definition path is persisted on the revision instead of the
request's possibly-empty value. ModelRevisionCreator.to_draft is
renamed to to_draft_with_extra_mount and now derives the rest of the
mount metadata itself, taking only the permission-resolved extra mounts.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…missing in merge

Pydantic now rejects empty strings at the DTO boundary via min_length=1, and
_merge_mounts uses a truthy check so any empty string that bypasses the DTO
no longer clobbers a resolved lower-priority model_definition_path.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp:common Related to Common component comp:manager Related to Manager component size:L 100~500 LoC

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants