From b8692f46dc70259e2a4627811bec317c4a2a8404 Mon Sep 17 00:00:00 2001 From: Zhang ZeHua Date: Thu, 9 Jul 2026 14:33:41 +0800 Subject: [PATCH] Add model metadata to multi-sync data --- component/multi_sync.go | 19 +++++++++++++++++++ component/multi_sync_test.go | 3 +++ component/wireset.go | 1 + 3 files changed, 23 insertions(+) diff --git a/component/multi_sync.go b/component/multi_sync.go index e41a6e1a1..be4c1ac7d 100644 --- a/component/multi_sync.go +++ b/component/multi_sync.go @@ -36,6 +36,7 @@ type multiSyncComponentImpl struct { tagStore database.TagStore fileStore database.FileStore skillStore database.SkillStore + metadataStore database.MetadataStore gitServer gitserver.GitServer } @@ -64,6 +65,7 @@ func NewMultiSyncComponent(config *config.Config) (MultiSyncComponent, error) { promptStore: database.NewPromptStore(), mcpStore: database.NewMCPServerStore(), skillStore: database.NewSkillStore(), + metadataStore: database.NewMetadataStore(), gitServer: git, }, nil } @@ -559,6 +561,23 @@ func (c *multiSyncComponentImpl) createLocalModel(ctx context.Context, m *types. return fmt.Errorf("failed to create database model, cause: %w", err) } + // sync metadata + err = c.metadataStore.Upsert(ctx, &database.Metadata{ + RepositoryID: newDBRepo.ID, + ModelParams: m.Metadata.ModelParams, + TensorType: m.Metadata.TensorType, + MiniGPUMemoryGB: m.Metadata.MiniGPUMemoryGB, + MiniGPUFinetuneGB: m.Metadata.MiniGPUFinetuneGB, + Architecture: m.Metadata.Architecture, + ModelType: m.Metadata.ModelType, + ClassName: m.Metadata.ClassName, + Quantizations: m.Metadata.Quantizations, + PDRecommendation: m.Metadata.PDRecommendation, + }) + if err != nil { + slog.Error("failed to sync metadata", slog.Any("error", err), slog.Int64("repo_id", newDBRepo.ID)) + } + // create new trending scores related to repo if len(m.Scores) != 0 { err = c.createLocalRecom(ctx, newDBRepo.ID, m.Scores) diff --git a/component/multi_sync_test.go b/component/multi_sync_test.go index 993708dcd..29d418dc7 100644 --- a/component/multi_sync_test.go +++ b/component/multi_sync_test.go @@ -163,6 +163,9 @@ func TestMultiSyncComponent_SyncAsClient(t *testing.T) { RepositoryID: 1, Repository: dbrepo, }).Return(nil, nil) + mc.mocks.stores.MetadataMock().EXPECT().Upsert(ctx, &database.Metadata{ + RepositoryID: 1, + }).Return(nil) mc.mocks.stores.RecomMock().EXPECT().UpsertScore(ctx, []*database.RecomRepoScore{ {RepositoryID: 1, WeightName: database.RecomWeightOp, Score: 40}, {RepositoryID: 1, WeightName: database.RecomWeightQuality, Score: 50}, diff --git a/component/wireset.go b/component/wireset.go index 20a22fbc1..780fe3a50 100644 --- a/component/wireset.go +++ b/component/wireset.go @@ -459,6 +459,7 @@ func NewTestMultiSyncComponent(config *config.Config, stores *tests.MockStores, promptStore: stores.Prompt, mcpStore: stores.MCPServerStore, skillStore: stores.Skill, + metadataStore: stores.Metadata, gitServer: gitServer, } }