From 7eda70f23b08854a341542839c43e831acc976d1 Mon Sep 17 00:00:00 2001 From: Michael Yang Date: Thu, 17 Aug 2023 21:52:11 -0700 Subject: [PATCH] copy metadata from source --- server/images.go | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/server/images.go b/server/images.go index 5c6aa4d4..8e9c1a13 100644 --- a/server/images.go +++ b/server/images.go @@ -325,7 +325,27 @@ func CreateModel(ctx context.Context, name string, path string, fn func(resp api } if mf != nil { - log.Printf("manifest = %#v", mf) + sourceBlobPath, err := GetBlobsPath(mf.Config.Digest) + if err != nil { + return err + } + + sourceBlob, err := os.Open(sourceBlobPath) + if err != nil { + return err + } + defer sourceBlob.Close() + + var source ConfigV2 + if err := json.NewDecoder(sourceBlob).Decode(&source); err != nil { + return err + } + + // copie the model metadata + config.ModelFamily = source.ModelFamily + config.ModelType = source.ModelType + config.FileType = source.FileType + for _, l := range mf.Layers { newLayer, err := GetLayerWithBufferFromLayer(l) if err != nil {