Skip to content

Commit d10897e

Browse files
Merge pull request cri-o#9131 from saschagrunert/model-spec-name
Add support for CNAI models
2 parents 8b8a095 + ab9acb6 commit d10897e

File tree

8 files changed

+441
-2
lines changed

8 files changed

+441
-2
lines changed

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ module github.com/cri-o/cri-o
44

55
require (
66
github.com/BurntSushi/toml v1.5.0
7+
github.com/CloudNativeAI/model-spec v0.0.3
78
github.com/Microsoft/go-winio v0.6.2
89
github.com/blang/semver/v4 v4.0.0
910
github.com/checkpoint-restore/checkpointctl v1.3.0

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ github.com/Azure/go-ansiterm v0.0.0-20250102033503-faa5f7b0171c/go.mod h1:xomTg6
1010
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
1111
github.com/BurntSushi/toml v1.5.0 h1:W5quZX/G/csjUnuI8SUYlsHs9M38FC7znL0lIO+DvMg=
1212
github.com/BurntSushi/toml v1.5.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho=
13+
github.com/CloudNativeAI/model-spec v0.0.3 h1:5mvgFQ+3pyupzxYjtV5XAeg9zRe6+46pLPBFNHlOrqE=
14+
github.com/CloudNativeAI/model-spec v0.0.3/go.mod h1:3U/4zubBfbUkW59ATSg41HnkYyKrKUcKFH/cVdoPQnk=
1315
github.com/Microsoft/go-winio v0.5.2/go.mod h1:WpS1mjBmmwHBEWmogvA2mj8546UReBk4v8QkMxJ6pZY=
1416
github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY=
1517
github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU=

internal/ociartifact/store.go

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"slices"
1111
"strings"
1212

13+
modelSpec "github.com/CloudNativeAI/model-spec/specs-go/v1"
1314
"github.com/containers/common/libimage"
1415
"github.com/containers/image/v5/docker/reference"
1516
"github.com/containers/image/v5/manifest"
@@ -342,7 +343,7 @@ func (s *Store) artifactData(ctx context.Context, nameOrDigest string, maxArtifa
342343
layerInfos := s.impl.LayerInfos(artifact.manifest)
343344
for i := range layerInfos {
344345
layer := &layerInfos[i]
345-
title := layer.Annotations[specs.AnnotationTitle]
346+
title := artifactName(layer.Annotations)
346347

347348
layerBytes, err := s.readBlob(ctx, imageSource, layer, maxArtifactSize)
348349
if err != nil {
@@ -493,11 +494,30 @@ func (s *Store) BlobMountPaths(ctx context.Context, artifact *Artifact, sys *typ
493494
return nil, fmt.Errorf("failed to get a local blob path: %w", err)
494495
}
495496

497+
name := artifactName(l.Annotations)
498+
if name == "" {
499+
log.Warnf(ctx, "Unable to find name for artifact layer which makes it not mountable")
500+
501+
continue
502+
}
503+
496504
mountPaths = append(mountPaths, BlobMountPath{
497505
SourcePath: path,
498-
Name: l.Annotations[specs.AnnotationTitle],
506+
Name: name,
499507
})
500508
}
501509

502510
return mountPaths, nil
503511
}
512+
513+
func artifactName(annotations map[string]string) string {
514+
if name, ok := annotations[specs.AnnotationTitle]; ok {
515+
return name
516+
}
517+
518+
if name, ok := annotations[modelSpec.AnnotationFilepath]; ok {
519+
return name
520+
}
521+
522+
return ""
523+
}

vendor/github.com/CloudNativeAI/model-spec/LICENSE

Lines changed: 201 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/CloudNativeAI/model-spec/specs-go/v1/annotations.go

Lines changed: 22 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/CloudNativeAI/model-spec/specs-go/v1/config.go

Lines changed: 103 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)