Skip to content

Commit

Permalink
test: Add TorchServe FVT (#294)
Browse files Browse the repository at this point in the history
#### Motivation
Support for TorchServe was added in #250 and kserve/modelmesh-runtime-adapter#34. A test should be added for it as well.

#### Modifications
- Adds basic FVT for load/inference with a TorchServe MAR model using the native TorchServe gRPC API
- Disables OVMS runtime and tests to allow TorchServe to be tested due to resource constraints

#### Result
Closes #280 

Signed-off-by: Rafael Vasquez <[email protected]>
  • Loading branch information
rafvasq authored Feb 21, 2023
1 parent 346634f commit ff0d455
Show file tree
Hide file tree
Showing 8 changed files with 606 additions and 3 deletions.
15 changes: 14 additions & 1 deletion fvt/fvtclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
Expand Down Expand Up @@ -54,6 +54,7 @@ import (

inference "github.com/kserve/modelmesh-serving/fvt/generated"
tfsapi "github.com/kserve/modelmesh-serving/fvt/generated/tensorflow_serving/apis"
torchserveapi "github.com/kserve/modelmesh-serving/fvt/generated/torchserve/apis"
)

const predictorTimeout = time.Second * 120
Expand Down Expand Up @@ -480,6 +481,18 @@ func (fvt *FVTClient) RunTfsInference(req *tfsapi.PredictRequest) (*tfsapi.Predi
return grpcClient.Predict(ctx, req)
}

func (fvt *FVTClient) RunTorchserveInference(req *torchserveapi.PredictionsRequest) (*torchserveapi.PredictionResponse, error) {
if fvt.grpcConn == nil {
return nil, errors.New("you must connect to model mesh before running an inference")
}

grpcClient := torchserveapi.NewInferenceAPIsServiceClient(fvt.grpcConn)

ctx, cancel := context.WithTimeout(context.Background(), 20*time.Second)
defer cancel()
return grpcClient.Predictions(ctx, req)
}

func (fvt *FVTClient) ConnectToModelServing(connectionType ModelServingConnectionType) error {
if fvt.grpcPortForward == nil {
podName := fvt.GetRandomReadyRuntimePodNameFromEndpoints()
Expand Down
333 changes: 333 additions & 0 deletions fvt/generated/torchserve/apis/inference.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit ff0d455

Please sign in to comment.