Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support update --data in kserve serving job #1049

Merged
Merged
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
1 change: 1 addition & 0 deletions pkg/apis/types/update_serving.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ type CommonUpdateServingArgs struct {
Tolerations []TolerationArgs `yaml:"tolerations"` // --toleration
Shell string `yaml:"shell"` // --shell
Command string `yaml:"command"` // --command
ModelDirs map[string]string `yaml:"modelDirs"` // --data
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should other types (such as custom, triton, tensorflow) support update --data since it is a common argument?

}

type UpdateTensorFlowServingArgs struct {
Expand Down
33 changes: 32 additions & 1 deletion pkg/argsbuilder/update_serving.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package argsbuilder
import (
"fmt"
"github.com/kubeflow/arena/pkg/apis/types"
"github.com/kubeflow/arena/pkg/util"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"k8s.io/apimachinery/pkg/api/resource"
Expand Down Expand Up @@ -68,6 +69,7 @@ func (s *UpdateServingArgsBuilder) AddCommandFlags(command *cobra.Command) {
envs []string
selectors []string
tolerations []string
dataset []string
)

command.Flags().StringVar(&s.args.Name, "name", "", "the serving name")
Expand All @@ -85,11 +87,14 @@ func (s *UpdateServingArgsBuilder) AddCommandFlags(command *cobra.Command) {
command.Flags().StringVar(&s.args.Command, "command", "", "the command will inject to container's command.")
command.Flags().StringArrayVarP(&selectors, "selector", "", []string{}, `assigning jobs to some k8s particular nodes, usage: "--selector=key=value" or "--selector key=value" `)
command.Flags().StringArrayVarP(&tolerations, "toleration", "", []string{}, `tolerate some k8s nodes with taints,usage: "--toleration key=value:effect,operator" or "--toleration all" `)
command.Flags().StringArrayVarP(&dataset, "data", "d", []string{}, "specify the trained models datasource to mount for serving, like <name_of_datasource>:<mount_point_on_job>")

s.AddArgValue("env", &envs).
AddArgValue("annotation", &annotations).
AddArgValue("selector", &selectors).
AddArgValue("label", &labels).
AddArgValue("toleration", &tolerations)
AddArgValue("toleration", &tolerations).
AddArgValue("data", &dataset)
}

func (s *UpdateServingArgsBuilder) PreBuild() error {
Expand Down Expand Up @@ -130,6 +135,10 @@ func (s *UpdateServingArgsBuilder) PreBuild() error {
return err
}

if err := s.setDataSet(); err != nil {
return err
}

if err := s.check(); err != nil {
return err
}
Expand Down Expand Up @@ -260,6 +269,28 @@ func (s *UpdateServingArgsBuilder) setLabels() error {
return nil
}

// setDataSets is used to handle option --data
func (s *UpdateServingArgsBuilder) setDataSet() error {
s.args.ModelDirs = map[string]string{}
argKey := "data"
var dataSet *[]string
value, ok := s.argValues[argKey]
if !ok {
return nil
}
dataSet = value.(*[]string)
log.Debugf("dataset: %v", *dataSet)
if len(*dataSet) <= 0 {
return nil
}
err := util.ValidateDatasets(*dataSet)
if err != nil {
return err
}
s.args.ModelDirs = transformSliceToMap(*dataSet, ":")
return nil
}

func (s *UpdateServingArgsBuilder) checkNamespace() error {
if s.args.Namespace == "" {
return fmt.Errorf("namespace not set, please set it")
Expand Down
24 changes: 24 additions & 0 deletions pkg/serving/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,30 @@ func setInferenceServiceForCustomModel(args *types.UpdateKServeArgs, inferenceSe
inferenceService.Spec.Predictor.Containers[0].Image = args.Image
}

//set volume
if len(args.ModelDirs) != 0 {
log.Debugf("update modelDirs: [%+v]", args.ModelDirs)
var volumes []v1.Volume
var volumeMounts []v1.VolumeMount

for pvName, mountPath := range args.ModelDirs {
volumes = append(volumes, v1.Volume{
Name: pvName,
VolumeSource: v1.VolumeSource{
PersistentVolumeClaim: &v1.PersistentVolumeClaimVolumeSource{
ClaimName: pvName,
},
},
})
volumeMounts = append(volumeMounts, v1.VolumeMount{
Name: pvName,
MountPath: mountPath,
})
}
inferenceService.Spec.Predictor.Containers[0].VolumeMounts = volumeMounts
inferenceService.Spec.Predictor.Volumes = volumes
}

// set resources requests
resourceRequests := inferenceService.Spec.Predictor.Containers[0].Resources.Requests
if resourceRequests == nil {
Expand Down
Loading