Skip to content

Commit d0ae87a

Browse files
Raderpulltheflower
andauthored
Add model metadata to multi-sync data (#1259)
Co-authored-by: Zhang ZeHua <pulltheflower@163.com>
1 parent 28c6c6a commit d0ae87a

3 files changed

Lines changed: 23 additions & 0 deletions

File tree

component/multi_sync.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ type multiSyncComponentImpl struct {
3636
tagStore database.TagStore
3737
fileStore database.FileStore
3838
skillStore database.SkillStore
39+
metadataStore database.MetadataStore
3940
gitServer gitserver.GitServer
4041
}
4142

@@ -64,6 +65,7 @@ func NewMultiSyncComponent(config *config.Config) (MultiSyncComponent, error) {
6465
promptStore: database.NewPromptStore(),
6566
mcpStore: database.NewMCPServerStore(),
6667
skillStore: database.NewSkillStore(),
68+
metadataStore: database.NewMetadataStore(),
6769
gitServer: git,
6870
}, nil
6971
}
@@ -559,6 +561,23 @@ func (c *multiSyncComponentImpl) createLocalModel(ctx context.Context, m *types.
559561
return fmt.Errorf("failed to create database model, cause: %w", err)
560562
}
561563

564+
// sync metadata
565+
err = c.metadataStore.Upsert(ctx, &database.Metadata{
566+
RepositoryID: newDBRepo.ID,
567+
ModelParams: m.Metadata.ModelParams,
568+
TensorType: m.Metadata.TensorType,
569+
MiniGPUMemoryGB: m.Metadata.MiniGPUMemoryGB,
570+
MiniGPUFinetuneGB: m.Metadata.MiniGPUFinetuneGB,
571+
Architecture: m.Metadata.Architecture,
572+
ModelType: m.Metadata.ModelType,
573+
ClassName: m.Metadata.ClassName,
574+
Quantizations: m.Metadata.Quantizations,
575+
PDRecommendation: m.Metadata.PDRecommendation,
576+
})
577+
if err != nil {
578+
slog.Error("failed to sync metadata", slog.Any("error", err), slog.Int64("repo_id", newDBRepo.ID))
579+
}
580+
562581
// create new trending scores related to repo
563582
if len(m.Scores) != 0 {
564583
err = c.createLocalRecom(ctx, newDBRepo.ID, m.Scores)

component/multi_sync_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,9 @@ func TestMultiSyncComponent_SyncAsClient(t *testing.T) {
163163
RepositoryID: 1,
164164
Repository: dbrepo,
165165
}).Return(nil, nil)
166+
mc.mocks.stores.MetadataMock().EXPECT().Upsert(ctx, &database.Metadata{
167+
RepositoryID: 1,
168+
}).Return(nil)
166169
mc.mocks.stores.RecomMock().EXPECT().UpsertScore(ctx, []*database.RecomRepoScore{
167170
{RepositoryID: 1, WeightName: database.RecomWeightOp, Score: 40},
168171
{RepositoryID: 1, WeightName: database.RecomWeightQuality, Score: 50},

component/wireset.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,7 @@ func NewTestMultiSyncComponent(config *config.Config, stores *tests.MockStores,
459459
promptStore: stores.Prompt,
460460
mcpStore: stores.MCPServerStore,
461461
skillStore: stores.Skill,
462+
metadataStore: stores.Metadata,
462463
gitServer: gitServer,
463464
}
464465
}

0 commit comments

Comments
 (0)