Skip to content

feat(BA-3209): Add artifact_storages common table#7057

Open
jopemachine wants to merge 10 commits intomainfrom
feat/BA-3209
Open

feat(BA-3209): Add artifact_storages common table#7057
jopemachine wants to merge 10 commits intomainfrom
feat/BA-3209

Conversation

@jopemachine
Copy link
Member

@jopemachine jopemachine commented Dec 2, 2025

resolves #7040 (BA-3209)

Checklist: (if applicable)

  • Mention to the original issue

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


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

@github-actions github-actions bot added size:L 100~500 LoC comp:manager Related to Manager component require:db-migration Automatically set when alembic migrations are added or updated labels Dec 2, 2025
@jopemachine jopemachine changed the title feat: Add artifact_storages common table feat(BA-3209): Add artifact_storages common table (WIP) Dec 2, 2025
@jopemachine jopemachine changed the title feat(BA-3209): Add artifact_storages common table (WIP) feat(BA-3209): Add artifact_storages common table Dec 3, 2025
@jopemachine jopemachine marked this pull request as ready for review December 3, 2025 05:15
Copilot AI review requested due to automatic review settings December 3, 2025 05:15
Copy link
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 introduces a new artifact_storages common table to centralize storage metadata management across object storage and VFS storage backends. The change refactors the storage architecture by extracting the name column from both object_storages and vfs_storages tables into a shared artifact_storages table.

Key changes:

  • Added new ArtifactStorageRow model to store common metadata (name, storage_id, type) for all storage backends
  • Migrated existing storage names to the new artifact_storages table via Alembic migration
  • Updated repository queries to use eager loading (selectinload) for the new meta relationship

Reviewed changes

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

Show a summary per file
File Description
src/ai/backend/manager/models/artifact_storages.py Introduces new ArtifactStorageRow model with bidirectional relationships to object and VFS storage tables
src/ai/backend/manager/models/alembic/versions/35dfab3b0662_add_artifact_storages_common_table.py Alembic migration that creates artifact_storages table and migrates existing data from both storage types
src/ai/backend/manager/models/vfs_storage.py Removes name column, adds meta relationship, updates to_dataclass() to retrieve name from relationship
src/ai/backend/manager/models/object_storage.py Removes name column, adds meta relationship, updates to_dataclass() to retrieve name from relationship
src/ai/backend/manager/repositories/vfs_storage/db_source/db_source.py Adds eager loading of meta relationship in all query methods to prevent N+1 queries
src/ai/backend/manager/repositories/object_storage/db_source/db_source.py Adds eager loading of meta relationship in all query methods to prevent N+1 queries
src/ai/backend/manager/models/__init__.py Registers the new artifact_storages module in the models package
changes/7057.feature.md Changelog entry describing the new feature

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

@jopemachine jopemachine added this to the 25.19 milestone Dec 16, 2025
@jopemachine jopemachine marked this pull request as draft December 16, 2025 07:33
@HyeockJinKim HyeockJinKim force-pushed the main branch 2 times, most recently from 9552aac to 4af738e Compare December 31, 2025 15:41
@jopemachine jopemachine modified the milestones: 25.19, 26.1 Jan 5, 2026
@jopemachine jopemachine marked this pull request as ready for review January 5, 2026 09:32
@jopemachine jopemachine marked this pull request as draft January 9, 2026 09:09
@jopemachine jopemachine removed this from the 26.1 milestone Jan 26, 2026
@jopemachine jopemachine added this to the 26.2 milestone Feb 4, 2026
@github-actions github-actions bot added size:XL 500~ LoC area:docs Documentations and removed size:L 100~500 LoC labels Feb 4, 2026
sa.Column("storage_id", GUID(), nullable=False),
sa.Column("type", sa.String(), nullable=False),
sa.PrimaryKeyConstraint("id", name=op.f("pk_artifact_storages")),
sa.UniqueConstraint("name", name=op.f("uq_artifact_storages_name")),
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it acceptable to apply a global unique constraint to the artifact storage name? Could there be cases where the storage type differs but the names are identical? (As this is a policy matter, please verify this for me.)

Copy link
Member Author

@jopemachine jopemachine Feb 20, 2026

Choose a reason for hiding this comment

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

I think since artifact storage management is an admin-only feature, it doesn’t look awkward so far.
If, in the future, artifact storage management becomes available to regular users as well, it would make more sense to adjust the constraints at that point.

Copy link
Member

@fregataa fregataa left a comment

Choose a reason for hiding this comment

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

I think that using SQLAlchemy Table inheritance would be great here.

@github-actions github-actions bot added size:M 30~100 LoC comp:agent Related to Agent component comp:client Related to Client component comp:cli Related to CLI component and removed size:XL 500~ LoC labels Feb 26, 2026
@github-actions github-actions bot added size:XL 500~ LoC and removed size:M 30~100 LoC labels Feb 26, 2026
@jopemachine jopemachine requested review from a team and fregataa March 4, 2026 03:44
jopemachine and others added 8 commits March 4, 2026 03:59
- Add artifact_storages table and migration script
- Move name column to artifact_storages
- Add proper selectinload in db_source
- Add ID type and update version
- Append admin prefix
- Fix rename types and error domain
- Add news fragment
Co-authored-by: octodog <mu001@lablup.com>
Copy link
Member

@fregataa fregataa left a comment

Choose a reason for hiding this comment

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

Are there storage insert/update unit tests? It would be good to have them.
Plus, how do you think of Single Table Inheritance? Update and insert execution got complicated because of joined table inheritance, so I guess single table one makes it easy

Comment on lines +65 to +66
Uses plain UPDATE + SELECT instead of execute_updater's RETURNING+from_statement,
which is incompatible with JTI (RETURNING only includes child table columns).
Copy link
Member

Choose a reason for hiding this comment

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

is it not allowed to update VFSStorageRow?

@jopemachine
Copy link
Member Author

Are there storage insert/update unit tests? It would be good to have them. Plus, how do you think of Single Table Inheritance? Update and insert execution got complicated because of joined table inheritance, so I guess single table one makes it easy

I believe STI would not good for extensibility because it will introduce many nullable columns.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:docs Documentations comp:agent Related to Agent component comp:cli Related to CLI component comp:client Related to Client component 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:XL 500~ LoC

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create common table across the artifact storage tables

4 participants