Skip to content
This repository was archived by the owner on Jul 24, 2025. It is now read-only.

Commit ab7fc4d

Browse files
committed
expose LoadFormat in TemplateVars to enable runai-streamer templates
Adds a LoadFormat field to TemplateVars and populates it from .Spec.ModelArtifacts.LoadFormat, letting the controller render ConfigMap templates for --load-format. Signed-off-by: Brent Salisbury <bsalisbu@redhat.com>
1 parent 82603a9 commit ab7fc4d

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

internal/controller/child_resources.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,21 @@ func sanitizeModelName(msvc *msv1alpha1.ModelService) string {
392392
return sanitizedModelName
393393
}
394394

395+
// pickLoadFormat returns the arg following "--load-format"
396+
func pickLoadFormat(pd *msv1alpha1.PDSpec) string {
397+
if pd == nil {
398+
return ""
399+
}
400+
for _, c := range append(pd.Containers, pd.InitContainers...) {
401+
for i := 0; i+1 < len(c.Args); i++ {
402+
if c.Args[i] == "--load-format" {
403+
return c.Args[i+1]
404+
}
405+
}
406+
}
407+
return ""
408+
}
409+
395410
// mergePDService uses msvc fields to update childResource P/D Service
396411
func (childResource *BaseConfig) mergePDService(ctx context.Context, msvc *msv1alpha1.ModelService, role string, scheme *runtime.Scheme) *BaseConfig {
397412

internal/controller/modelservice_controller.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ type TemplateVars struct {
8686
DecodeServiceName string `json:"decodeServiceName,omitempty"`
8787
InferencePoolName string `json:"inferencePoolName,omitempty"`
8888
InferenceModelName string `json:"inferenceModelName,omitempty"`
89+
LoadFormat string `json:"loadFormat,omitempty"`
8990
}
9091

9192
// from populates the field values for TemplateVars from the model service
@@ -113,6 +114,10 @@ func (t *TemplateVars) from(ctx context.Context, msvc *msv1alpha1.ModelService)
113114
t.InferenceModelName = infModelName(msvc)
114115
t.ModelName = msvc.Spec.Routing.ModelName
115116
t.SanitizedModelName = sanitizeModelName(msvc)
117+
t.LoadFormat = pickLoadFormat(msvc.Spec.Decode)
118+
if t.LoadFormat == "" {
119+
t.LoadFormat = pickLoadFormat(msvc.Spec.Prefill)
120+
}
116121

117122
if msvc.Spec.ModelArtifacts.AuthSecretName != nil {
118123
t.AuthSecretName = *msvc.Spec.ModelArtifacts.AuthSecretName

0 commit comments

Comments
 (0)