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

Commit ffc0f66

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 ffc0f66

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

internal/controller/child_resources.go

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

395+
// pickLoadFormat walks through all container / init-container args inside a
396+
// PDSpec and returns the value that appears immediately after "--load-format".
397+
func pickLoadFormat(pd *msv1alpha1.PDSpec) string {
398+
if pd == nil {
399+
return ""
400+
}
401+
402+
search := func(conts []msv1alpha1.ContainerSpec) string {
403+
for _, c := range conts {
404+
for i, a := range c.Args {
405+
if a == "--load-format" && i+1 < len(c.Args) {
406+
return c.Args[i+1]
407+
}
408+
}
409+
}
410+
return ""
411+
}
412+
413+
if lf := search(pd.Containers); lf != "" {
414+
return lf
415+
}
416+
return search(pd.InitContainers)
417+
}
418+
395419
// mergePDService uses msvc fields to update childResource P/D Service
396420
func (childResource *BaseConfig) mergePDService(ctx context.Context, msvc *msv1alpha1.ModelService, role string, scheme *runtime.Scheme) *BaseConfig {
397421

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)