Skip to content

feat(BA-5421): Make initial_revision optional and remove duplicate revision columns from endpoints table#10542

Draft
jopemachine wants to merge 14 commits intomainfrom
BA-5421
Draft

feat(BA-5421): Make initial_revision optional and remove duplicate revision columns from endpoints table#10542
jopemachine wants to merge 14 commits intomainfrom
BA-5421

Conversation

@jopemachine
Copy link
Copy Markdown
Member

@jopemachine jopemachine commented Mar 26, 2026

Resolves BA-5421.

Summary

  • Make initial_revision optional (None by default) in deployment creation DTOs (v2, REST v1, GraphQL)
  • Remove 15 duplicate revision columns from endpoints table — these were legacy leftovers already present in deployment_revisions table:
    • image, model, model_mount_destination, model_definition_path
    • resource_group, resource_slots, resource_opts
    • cluster_mode, cluster_size
    • startup_command, bootstrap_script, callback_url, environ, runtime_variant, extra_mounts
  • Add current_revision_row relationship to EndpointRow — all revision data is now accessed through DeploymentRevisionRow
  • Add model_row relationship to DeploymentRevisionRow
  • Move resource_group from endpoint metadata to revision level
  • Update all consumers (event_dispatcher, model_serving repository, gql_legacy, registry, sokovan) to read from current_revision_row
  • Alembic migration to drop columns, check constraint (ck_image_required_unless_destroyed), and FK constraints

Test plan

  • Verify deployment creation with initial_revision still works as before
  • Verify deployment creation without initial_revision is accepted
  • Verify legacy model serving flow reads revision data correctly via current_revision_row
  • Verify deployment lifecycle (sokovan) works with revision-based field access
  • Run alembic migration on test DB

🤖 Generated with Claude Code


📚 Documentation preview 📚: https://sorna--10542.org.readthedocs.build/en/10542/


📚 Documentation preview 📚: https://sorna-ko--10542.org.readthedocs.build/ko/10542/

Copilot AI review requested due to automatic review settings March 26, 2026 06:05
@github-actions github-actions bot added size:S 10~30 LoC comp:manager Related to Manager component comp:common Related to Common component labels Mar 26, 2026
@jopemachine jopemachine marked this pull request as draft March 26, 2026 06:06
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 aims to make the initial_revision field optional across deployment creation DTOs (v1 REST, v2 DTO used by GraphQL), enabling “create deployment first, add revisions later” workflows.

Changes:

  • Make initial_revision optional in GraphQL CreateDeploymentInput.
  • Make initial_revision optional in v2 CreateDeploymentInput DTO.
  • Make initial_revision optional in v1 CreateDeploymentRequest DTO.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

File Description
src/ai/backend/manager/api/gql/deployment/types/deployment.py Makes GraphQL create input accept initial_revision = null/omitted.
src/ai/backend/common/dto/manager/v2/deployment/request.py Makes v2 create DTO accept initial_revision = None.
src/ai/backend/common/dto/manager/deployment/request.py Makes v1 REST create DTO accept initial_revision = None.

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

@github-actions github-actions bot added the area:docs Documentations label Mar 26, 2026
@jopemachine jopemachine force-pushed the BA-5421 branch 3 times, most recently from 49702ff to a6ff914 Compare March 31, 2026 01:01
@jopemachine jopemachine added this to the 26.4 milestone Mar 31, 2026
@jopemachine jopemachine requested a review from a team March 31, 2026 01:38
@jopemachine jopemachine marked this pull request as ready for review March 31, 2026 01:38
@jopemachine jopemachine changed the title feat(BA-5421): Make initial_revision optional in deployment creation DTOs feat(BA-5421): Make initial_revision optional in deployment creation DTOs Mar 31, 2026
@jopemachine jopemachine marked this pull request as draft March 31, 2026 01:55
@jopemachine jopemachine changed the title feat(BA-5421): Make initial_revision optional in deployment creation DTOs feat(BA-5421): Make initial_revision optional and remove duplicate revision columns from endpoints table Mar 31, 2026
@jopemachine jopemachine force-pushed the BA-5421 branch 2 times, most recently from 47cdf25 to 25367dc Compare March 31, 2026 06:02
@github-actions github-actions bot added size:XL 500~ LoC require:db-migration Automatically set when alembic migrations are added or updated and removed size:S 10~30 LoC labels Mar 31, 2026
jopemachine and others added 6 commits April 2, 2026 10:08
…DTOs

Allow creating a deployment without specifying an initial revision
so that revisions can be added separately after deployment creation.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ment adapters

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…able

Remove 15 revision-related columns from endpoints table that were
already present in deployment_revisions. All revision data is now
accessed through current_revision_row relationship on EndpointRow.

- Make initial_revision optional in deployment creation DTOs
- Add current_revision_row relationship to EndpointRow
- Add model_row relationship to DeploymentRevisionRow
- Move resource_group from endpoint metadata to revision level
- Update all consumers (event_dispatcher, model_serving, gql_legacy,
  registry, sokovan) to read from DeploymentRevisionRow
- Add alembic migration to drop columns and constraints

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…_revision

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Use actual DB constraint names (ck_endpoints_ck_*, fk_endpoints_*)
instead of assumed names. Use raw SQL for check constraint
drop/create to avoid alembic auto-prefixing issues.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
jopemachine and others added 3 commits April 2, 2026 10:21
…olumns

Remove image, resource_group, resource_slots, cluster_mode, and other
revision-related keyword arguments from EndpointRow() constructor calls
across all test files. Add deployment_revisions stub table to scaling
group test conftest.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Replace ValueError with DeploymentRevisionNotFound (BackendAIError-based)
- Add resource_group to ModelRevisionCreator in _apply_preset
- Remove resource_group from DeploymentMetadataFields (moved to revision)
- Fix formatting in deployment adapter
- Remove unused yarl import

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@jopemachine jopemachine force-pushed the BA-5421 branch 2 times, most recently from abb8895 to fb700fd Compare April 2, 2026 02:16
- Add get_endpoint_info mock (service now re-fetches after creation)
- Patch add_model_revision in with_revision test (avoid deep async chain)
- Remove mark_lifecycle_needed assertions (no longer called in create_deployment)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
jopemachine and others added 3 commits April 2, 2026 13:17
Migration 8d01fe40664a (already on main) already drops 14 revision
columns from endpoints. This migration now only drops the remaining
resource_group column with its FK constraint and index.

Also revert unrelated blank line change in image/row.py.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Delete migration (resource_group stays on EndpointRow)
- Restore resource_group column and references in EndpointRow
- Restore DeploymentMetadata.resource_group as required str
- Restore DeploymentMetadataFields.resource_group
- Revert cosmetic renames (current_rev variable name kept)
- Revert sokovan resource_group null checks
- Revert scaling_group db_source query changes
- Revert test files to main (resource_group parameter restored)
- Keep functional changes: current_revision_row relationship,
  load_current_revision parameter, initial_revision optional

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions github-actions bot added size:L 100~500 LoC and removed size:XL 500~ LoC labels Apr 2, 2026
…ld_row()

The EndpointRow creation was missing the resource_group field assignment,
causing a NOT NULL constraint violation on the endpoints table during
deployment creation.

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

Labels

area:docs Documentations comp:common Related to Common component comp:manager Related to Manager component require:db-migration Automatically set when alembic migrations are added or updated size:L 100~500 LoC

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants