Skip to content

Commit 14f90bf

Browse files
authored
feat: store the modelfile to the manifest annotation (#146)
Signed-off-by: chlins <[email protected]>
1 parent 2f63044 commit 14f90bf

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

pkg/backend/attach.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ func (b *backend) Attach(ctx context.Context, filepath string, cfg *config.Attac
150150
}
151151

152152
// Build the model manifest.
153-
_, err = builder.BuildManifest(ctx, layers, configDesc, manifestAnnotation(), hooks.NewHooks(
153+
_, err = builder.BuildManifest(ctx, layers, configDesc, srcManifest.Annotations, hooks.NewHooks(
154154
hooks.WithOnStart(func(name string, size int64, reader io.Reader) io.Reader {
155155
return pb.Add(internalpb.NormalizePrompt("Building manifest"), name, size, reader)
156156
}),

pkg/backend/build.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ import (
3434
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
3535
)
3636

37+
const (
38+
// annotationModelfile is the annotation key for the Modelfile.
39+
annotationModelfile = "org.cnai.modctl.modelfile"
40+
)
41+
3742
// Build builds the user materials into the model artifact which follows the Model Spec.
3843
func (b *backend) Build(ctx context.Context, modelfilePath, workDir, target string, cfg *config.Build) error {
3944
// parse the repo name and tag name from target.
@@ -105,7 +110,7 @@ func (b *backend) Build(ctx context.Context, modelfilePath, workDir, target stri
105110
}
106111

107112
// Build the model manifest.
108-
_, err = builder.BuildManifest(ctx, layers, configDesc, manifestAnnotation(), hooks.NewHooks(
113+
_, err = builder.BuildManifest(ctx, layers, configDesc, manifestAnnotation(modelfile), hooks.NewHooks(
109114
hooks.WithOnStart(func(name string, size int64, reader io.Reader) io.Reader {
110115
return pb.Add(internalpb.NormalizePrompt("Building manifest"), name, size, reader)
111116
}),
@@ -161,8 +166,9 @@ func (b *backend) process(ctx context.Context, builder build.Builder, workDir st
161166
}
162167

163168
// manifestAnnotation returns the annotations for the manifest.
164-
func manifestAnnotation() map[string]string {
165-
// placeholder for future expansion of annotations.
166-
anno := map[string]string{}
169+
func manifestAnnotation(modelfile modelfile.Modelfile) map[string]string {
170+
anno := map[string]string{
171+
annotationModelfile: string(modelfile.Content()),
172+
}
167173
return anno
168174
}

0 commit comments

Comments
 (0)