Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 27 additions & 4 deletions pkg/constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,29 @@ var (

// Model agent Constants
const (
AgentConfigMapKeyName = "agent"
TensorRTLLM = "tensorrtllm"
AgentConfigMapKeyName = "agent"
TensorRTLLM = "tensorrtllm"
ArtifactCompleteMarkerFileName = ".ome-artifact-complete"
ArtifactCompleteMarkerBody = "complete\n"
ArtifactUploadLockFileName = ".ome-artifact-upload.lock"
ArtifactUploadLockBody = "uploading\n"

HuggingFaceArtifactConfigMapKeyPrefix = "artifact.huggingface."
HuggingFaceArtifactReadyMarkerFileName = ".ome-hf-artifact-ready"
)

func IsArtifactCompleteMarkerObjectName(objectName string) bool {
return objectName == ArtifactCompleteMarkerFileName || strings.HasSuffix(objectName, "/"+ArtifactCompleteMarkerFileName)
}

func IsArtifactUploadLockObjectName(objectName string) bool {
return objectName == ArtifactUploadLockFileName || strings.HasSuffix(objectName, "/"+ArtifactUploadLockFileName)
}

func IsInternalArtifactObjectName(objectName string) bool {
return IsArtifactCompleteMarkerObjectName(objectName) || IsArtifactUploadLockObjectName(objectName)
}

// InferenceService Annotations
var (
DeploymentMode = OMEAPIGroupName + "/deploymentMode"
Expand Down Expand Up @@ -402,8 +421,12 @@ const (
LLamaVllmFTServingServedModelNamePrefix = "/data"
)

// DefaultModelLocalMountPath is where models will be mounted by the storage-initializer
const DefaultModelLocalMountPath = "/mnt/models"
const (
// DefaultModelLocalMountPath is where models will be mounted by the storage-initializer.
DefaultModelLocalMountPath = "/mnt/models"
// ModelArtifactsDirectory is the node-local shared artifact directory under a model store.
ModelArtifactsDirectory = "_artifacts"
)

var (
ServiceAnnotationDisallowedList = []string{
Expand Down
79 changes: 79 additions & 0 deletions pkg/constants/constants_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,82 @@ func TestLWSNameTruncates(t *testing.T) {
})
}
}

func TestIsArtifactCompleteMarkerObjectName(t *testing.T) {
tests := []struct {
name string
objectName string
want bool
}{
{
name: "marker at root",
objectName: ArtifactCompleteMarkerFileName,
want: true,
},
{
name: "marker under model prefix",
objectName: "customer-imported-basemodels/deepseek-ai/DeepSeek-V4-Pro/abc123/" + ArtifactCompleteMarkerFileName,
want: true,
},
{
name: "regular model file",
objectName: "customer-imported-basemodels/deepseek-ai/DeepSeek-V4-Pro/abc123/config.json",
},
{
name: "similar suffix without path separator",
objectName: "customer-imported-basemodels/deepseek-ai/DeepSeek-V4-Pro/abc123/not-" + ArtifactCompleteMarkerFileName,
},
}

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := IsArtifactCompleteMarkerObjectName(tt.objectName); got != tt.want {
t.Fatalf("IsArtifactCompleteMarkerObjectName(%q) = %v, want %v", tt.objectName, got, tt.want)
}
})
}
}

func TestIsArtifactUploadLockObjectName(t *testing.T) {
tests := []struct {
name string
objectName string
want bool
}{
{
name: "lock at root",
objectName: ArtifactUploadLockFileName,
want: true,
},
{
name: "lock under model prefix",
objectName: "customer-imported-basemodels/deepseek-ai/DeepSeek-V4-Pro/abc123/" + ArtifactUploadLockFileName,
want: true,
},
{
name: "regular model file",
objectName: "customer-imported-basemodels/deepseek-ai/DeepSeek-V4-Pro/abc123/tokenizer.json",
},
{
name: "similar suffix without path separator",
objectName: "customer-imported-basemodels/deepseek-ai/DeepSeek-V4-Pro/abc123/not-" + ArtifactUploadLockFileName,
},
}

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := IsArtifactUploadLockObjectName(tt.objectName); got != tt.want {
t.Fatalf("IsArtifactUploadLockObjectName(%q) = %v, want %v", tt.objectName, got, tt.want)
}
})
}
}

func TestHuggingFaceArtifactConstants(t *testing.T) {
if HuggingFaceArtifactConfigMapKeyPrefix != "artifact.huggingface." {
t.Fatalf("HuggingFaceArtifactConfigMapKeyPrefix = %q", HuggingFaceArtifactConfigMapKeyPrefix)
}
if HuggingFaceArtifactReadyMarkerFileName != ".ome-hf-artifact-ready" {
t.Fatalf("HuggingFaceArtifactReadyMarkerFileName = %q", HuggingFaceArtifactReadyMarkerFileName)
}
}
22 changes: 22 additions & 0 deletions pkg/modelagent/artifact_object_filter.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package modelagent

import (
"github.com/oracle/oci-go-sdk/v65/objectstorage"

"sigs.k8s.io/ome/pkg/constants"
)

func filterInternalArtifactObjectSummaries(objects []objectstorage.ObjectSummary) []objectstorage.ObjectSummary {
filtered := make([]objectstorage.ObjectSummary, 0, len(objects))
for _, object := range objects {
if object.Name != nil && isInternalArtifactObjectName(*object.Name) {
continue
}
filtered = append(filtered, object)
}
return filtered
}

func isInternalArtifactObjectName(objectName string) bool {
return constants.IsInternalArtifactObjectName(objectName)
}
Loading
Loading