From 655e4da403096fb9ef0426624130b281863aa505 Mon Sep 17 00:00:00 2001 From: Matteo Mortari Date: Fri, 26 Jan 2024 12:01:05 +0100 Subject: [PATCH] Decouple MLMD types setup from Go core library (#267) * implement Go core changes * add test coverage * refactoring * minor message change * nit: renamed function --- cmd/proxy.go | 5 + internal/apiutils/api_utils.go | 5 + internal/mlmdtypes/mlmdtypes.go | 144 ++++++++++++++++++++++++++ pkg/core/core.go | 172 ++++++++++---------------------- pkg/core/core_test.go | 61 ++++++----- 5 files changed, 243 insertions(+), 144 deletions(-) create mode 100644 internal/mlmdtypes/mlmdtypes.go diff --git a/cmd/proxy.go b/cmd/proxy.go index e9dea571..3bbc8adb 100644 --- a/cmd/proxy.go +++ b/cmd/proxy.go @@ -7,6 +7,7 @@ import ( "time" "github.com/golang/glog" + "github.com/opendatahub-io/model-registry/internal/mlmdtypes" "github.com/opendatahub-io/model-registry/internal/server/openapi" "github.com/opendatahub-io/model-registry/pkg/core" "github.com/spf13/cobra" @@ -48,6 +49,10 @@ func runProxyServer(cmd *cobra.Command, args []string) error { defer conn.Close() glog.Infof("connected to MLMD server") + _, err = mlmdtypes.CreateMLMDTypes(conn) + if err != nil { + return fmt.Errorf("error creating MLMD types: %v", err) + } service, err := core.NewModelRegistryService(conn) if err != nil { return fmt.Errorf("error creating core service: %v", err) diff --git a/internal/apiutils/api_utils.go b/internal/apiutils/api_utils.go index 8f5aaf49..ac28515c 100644 --- a/internal/apiutils/api_utils.go +++ b/internal/apiutils/api_utils.go @@ -46,6 +46,11 @@ func ZeroIfNil[T any](input *T) T { return *new(T) } +// of returns a pointer to the provided literal/const input +func Of[E any](e E) *E { + return &e +} + func BuildListOption(pageSize string, orderBy model.OrderByField, sortOrder model.SortOrder, nextPageToken string) (api.ListOptions, error) { var pageSizeInt32 *int32 if pageSize != "" { diff --git a/internal/mlmdtypes/mlmdtypes.go b/internal/mlmdtypes/mlmdtypes.go new file mode 100644 index 00000000..f8ab687d --- /dev/null +++ b/internal/mlmdtypes/mlmdtypes.go @@ -0,0 +1,144 @@ +package mlmdtypes + +import ( + "context" + "fmt" + + "github.com/opendatahub-io/model-registry/internal/apiutils" + "github.com/opendatahub-io/model-registry/internal/constants" + "github.com/opendatahub-io/model-registry/internal/ml_metadata/proto" + "google.golang.org/grpc" +) + +var ( + registeredModelTypeName = apiutils.Of(constants.RegisteredModelTypeName) + modelVersionTypeName = apiutils.Of(constants.ModelVersionTypeName) + modelArtifactTypeName = apiutils.Of(constants.ModelArtifactTypeName) + servingEnvironmentTypeName = apiutils.Of(constants.ServingEnvironmentTypeName) + inferenceServiceTypeName = apiutils.Of(constants.InferenceServiceTypeName) + serveModelTypeName = apiutils.Of(constants.ServeModelTypeName) + canAddFields = apiutils.Of(true) +) + +// Utility method that created the necessary Model Registry's logical-model types +// as the necessary MLMD's Context, Artifact, Execution types etc. in the underlying MLMD service +func CreateMLMDTypes(cc grpc.ClientConnInterface) (map[string]int64, error) { + client := proto.NewMetadataStoreServiceClient(cc) + + registeredModelReq := proto.PutContextTypeRequest{ + CanAddFields: canAddFields, + ContextType: &proto.ContextType{ + Name: registeredModelTypeName, + Properties: map[string]proto.PropertyType{ + "description": proto.PropertyType_STRING, + "state": proto.PropertyType_STRING, + }, + }, + } + + modelVersionReq := proto.PutContextTypeRequest{ + CanAddFields: canAddFields, + ContextType: &proto.ContextType{ + Name: modelVersionTypeName, + Properties: map[string]proto.PropertyType{ + "description": proto.PropertyType_STRING, + "model_name": proto.PropertyType_STRING, + "version": proto.PropertyType_STRING, + "author": proto.PropertyType_STRING, + "state": proto.PropertyType_STRING, + }, + }, + } + + modelArtifactReq := proto.PutArtifactTypeRequest{ + CanAddFields: canAddFields, + ArtifactType: &proto.ArtifactType{ + Name: modelArtifactTypeName, + Properties: map[string]proto.PropertyType{ + "description": proto.PropertyType_STRING, + "model_format_name": proto.PropertyType_STRING, + "model_format_version": proto.PropertyType_STRING, + "storage_key": proto.PropertyType_STRING, + "storage_path": proto.PropertyType_STRING, + "service_account_name": proto.PropertyType_STRING, + }, + }, + } + + servingEnvironmentReq := proto.PutContextTypeRequest{ + CanAddFields: canAddFields, + ContextType: &proto.ContextType{ + Name: servingEnvironmentTypeName, + Properties: map[string]proto.PropertyType{ + "description": proto.PropertyType_STRING, + }, + }, + } + + inferenceServiceReq := proto.PutContextTypeRequest{ + CanAddFields: canAddFields, + ContextType: &proto.ContextType{ + Name: inferenceServiceTypeName, + Properties: map[string]proto.PropertyType{ + "description": proto.PropertyType_STRING, + "model_version_id": proto.PropertyType_INT, + "registered_model_id": proto.PropertyType_INT, + // same information tracked using ParentContext association + "serving_environment_id": proto.PropertyType_INT, + "runtime": proto.PropertyType_STRING, + "desired_state": proto.PropertyType_STRING, + }, + }, + } + + serveModelReq := proto.PutExecutionTypeRequest{ + CanAddFields: canAddFields, + ExecutionType: &proto.ExecutionType{ + Name: serveModelTypeName, + Properties: map[string]proto.PropertyType{ + "description": proto.PropertyType_STRING, + "model_version_id": proto.PropertyType_INT, + }, + }, + } + + registeredModelResp, err := client.PutContextType(context.Background(), ®isteredModelReq) + if err != nil { + return nil, fmt.Errorf("error setting up context type %s: %v", *registeredModelTypeName, err) + } + + modelVersionResp, err := client.PutContextType(context.Background(), &modelVersionReq) + if err != nil { + return nil, fmt.Errorf("error setting up context type %s: %v", *modelVersionTypeName, err) + } + + modelArtifactResp, err := client.PutArtifactType(context.Background(), &modelArtifactReq) + if err != nil { + return nil, fmt.Errorf("error setting up artifact type %s: %v", *modelArtifactTypeName, err) + } + + servingEnvironmentResp, err := client.PutContextType(context.Background(), &servingEnvironmentReq) + if err != nil { + return nil, fmt.Errorf("error setting up context type %s: %v", *servingEnvironmentTypeName, err) + } + + inferenceServiceResp, err := client.PutContextType(context.Background(), &inferenceServiceReq) + if err != nil { + return nil, fmt.Errorf("error setting up context type %s: %v", *inferenceServiceTypeName, err) + } + + serveModelResp, err := client.PutExecutionType(context.Background(), &serveModelReq) + if err != nil { + return nil, fmt.Errorf("error setting up execution type %s: %v", *serveModelTypeName, err) + } + + typesMap := map[string]int64{ + constants.RegisteredModelTypeName: registeredModelResp.GetTypeId(), + constants.ModelVersionTypeName: modelVersionResp.GetTypeId(), + constants.ModelArtifactTypeName: modelArtifactResp.GetTypeId(), + constants.ServingEnvironmentTypeName: servingEnvironmentResp.GetTypeId(), + constants.InferenceServiceTypeName: inferenceServiceResp.GetTypeId(), + constants.ServeModelTypeName: serveModelResp.GetTypeId(), + } + return typesMap, nil +} diff --git a/pkg/core/core.go b/pkg/core/core.go index cf53d851..e04a5dd5 100644 --- a/pkg/core/core.go +++ b/pkg/core/core.go @@ -18,13 +18,12 @@ import ( ) var ( - registeredModelTypeName = of(constants.RegisteredModelTypeName) - modelVersionTypeName = of(constants.ModelVersionTypeName) - modelArtifactTypeName = of(constants.ModelArtifactTypeName) - servingEnvironmentTypeName = of(constants.ServingEnvironmentTypeName) - inferenceServiceTypeName = of(constants.InferenceServiceTypeName) - serveModelTypeName = of(constants.ServeModelTypeName) - canAddFields = of(true) + registeredModelTypeName = apiutils.Of(constants.RegisteredModelTypeName) + modelVersionTypeName = apiutils.Of(constants.ModelVersionTypeName) + modelArtifactTypeName = apiutils.Of(constants.ModelArtifactTypeName) + servingEnvironmentTypeName = apiutils.Of(constants.ServingEnvironmentTypeName) + inferenceServiceTypeName = apiutils.Of(constants.InferenceServiceTypeName) + serveModelTypeName = apiutils.Of(constants.ServeModelTypeName) ) // ModelRegistryService is the core library of the model registry @@ -36,137 +35,81 @@ type ModelRegistryService struct { } // NewModelRegistryService creates a new instance of the ModelRegistryService, initializing it with the provided gRPC client connection. -// It sets up the necessary context and artifact types in the MLMD service. +// It _assumes_ the necessary MLMD's Context, Artifact, Execution types etc. are already setup in the underlying MLMD service. // // Parameters: // - cc: A gRPC client connection to the underlying MLMD service func NewModelRegistryService(cc grpc.ClientConnInterface) (api.ModelRegistryApi, error) { + typesMap, err := BuildTypesMap(cc) + if err != nil { // early return in case type Ids cannot be retrieved + return nil, err + } client := proto.NewMetadataStoreServiceClient(cc) - // Setup the needed Type instances if not existing already + return &ModelRegistryService{ + mlmdClient: client, + typesMap: typesMap, + openapiConv: &generated.OpenAPIConverterImpl{}, + mapper: mapper.NewMapper(typesMap), + }, nil +} - registeredModelReq := proto.PutContextTypeRequest{ - CanAddFields: canAddFields, - ContextType: &proto.ContextType{ - Name: registeredModelTypeName, - Properties: map[string]proto.PropertyType{ - "description": proto.PropertyType_STRING, - "state": proto.PropertyType_STRING, - }, - }, - } +func BuildTypesMap(cc grpc.ClientConnInterface) (map[string]int64, error) { + client := proto.NewMetadataStoreServiceClient(cc) - modelVersionReq := proto.PutContextTypeRequest{ - CanAddFields: canAddFields, - ContextType: &proto.ContextType{ - Name: modelVersionTypeName, - Properties: map[string]proto.PropertyType{ - "description": proto.PropertyType_STRING, - "model_name": proto.PropertyType_STRING, - "version": proto.PropertyType_STRING, - "author": proto.PropertyType_STRING, - "state": proto.PropertyType_STRING, - }, - }, + registeredModelContextTypeReq := proto.GetContextTypeRequest{ + TypeName: registeredModelTypeName, } - - modelArtifactReq := proto.PutArtifactTypeRequest{ - CanAddFields: canAddFields, - ArtifactType: &proto.ArtifactType{ - Name: modelArtifactTypeName, - Properties: map[string]proto.PropertyType{ - "description": proto.PropertyType_STRING, - "model_format_name": proto.PropertyType_STRING, - "model_format_version": proto.PropertyType_STRING, - "storage_key": proto.PropertyType_STRING, - "storage_path": proto.PropertyType_STRING, - "service_account_name": proto.PropertyType_STRING, - }, - }, + registeredModelResp, err := client.GetContextType(context.Background(), ®isteredModelContextTypeReq) + if err != nil { + return nil, fmt.Errorf("error getting context type %s: %v", *registeredModelTypeName, err) } - - servingEnvironmentReq := proto.PutContextTypeRequest{ - CanAddFields: canAddFields, - ContextType: &proto.ContextType{ - Name: servingEnvironmentTypeName, - Properties: map[string]proto.PropertyType{ - "description": proto.PropertyType_STRING, - }, - }, + modelVersionContextTypeReq := proto.GetContextTypeRequest{ + TypeName: modelVersionTypeName, } - - inferenceServiceReq := proto.PutContextTypeRequest{ - CanAddFields: canAddFields, - ContextType: &proto.ContextType{ - Name: inferenceServiceTypeName, - Properties: map[string]proto.PropertyType{ - "description": proto.PropertyType_STRING, - "model_version_id": proto.PropertyType_INT, - "registered_model_id": proto.PropertyType_INT, - // same information tracked using ParentContext association - "serving_environment_id": proto.PropertyType_INT, - "runtime": proto.PropertyType_STRING, - "desired_state": proto.PropertyType_STRING, - }, - }, + modelVersionResp, err := client.GetContextType(context.Background(), &modelVersionContextTypeReq) + if err != nil { + return nil, fmt.Errorf("error getting context type %s: %v", *modelVersionTypeName, err) } - - serveModelReq := proto.PutExecutionTypeRequest{ - CanAddFields: canAddFields, - ExecutionType: &proto.ExecutionType{ - Name: serveModelTypeName, - Properties: map[string]proto.PropertyType{ - "description": proto.PropertyType_STRING, - "model_version_id": proto.PropertyType_INT, - }, - }, + modelArtifactArtifactTypeReq := proto.GetArtifactTypeRequest{ + TypeName: modelArtifactTypeName, } - - registeredModelResp, err := client.PutContextType(context.Background(), ®isteredModelReq) + modelArtifactResp, err := client.GetArtifactType(context.Background(), &modelArtifactArtifactTypeReq) if err != nil { - return nil, fmt.Errorf("error setting up context type %s: %v", *registeredModelTypeName, err) + return nil, fmt.Errorf("error getting artifact type %s: %v", *modelArtifactTypeName, err) } - - modelVersionResp, err := client.PutContextType(context.Background(), &modelVersionReq) - if err != nil { - return nil, fmt.Errorf("error setting up context type %s: %v", *modelVersionTypeName, err) + servingEnvironmentContextTypeReq := proto.GetContextTypeRequest{ + TypeName: servingEnvironmentTypeName, } - - modelArtifactResp, err := client.PutArtifactType(context.Background(), &modelArtifactReq) + servingEnvironmentResp, err := client.GetContextType(context.Background(), &servingEnvironmentContextTypeReq) if err != nil { - return nil, fmt.Errorf("error setting up artifact type %s: %v", *modelArtifactTypeName, err) + return nil, fmt.Errorf("error getting context type %s: %v", *servingEnvironmentTypeName, err) } - - servingEnvironmentResp, err := client.PutContextType(context.Background(), &servingEnvironmentReq) - if err != nil { - return nil, fmt.Errorf("error setting up context type %s: %v", *servingEnvironmentTypeName, err) + inferenceServiceContextTypeReq := proto.GetContextTypeRequest{ + TypeName: inferenceServiceTypeName, } - - inferenceServiceResp, err := client.PutContextType(context.Background(), &inferenceServiceReq) + inferenceServiceResp, err := client.GetContextType(context.Background(), &inferenceServiceContextTypeReq) if err != nil { - return nil, fmt.Errorf("error setting up context type %s: %v", *inferenceServiceTypeName, err) + return nil, fmt.Errorf("error getting context type %s: %v", *inferenceServiceTypeName, err) } - - serveModelResp, err := client.PutExecutionType(context.Background(), &serveModelReq) + serveModelExecutionReq := proto.GetExecutionTypeRequest{ + TypeName: serveModelTypeName, + } + serveModelResp, err := client.GetExecutionType(context.Background(), &serveModelExecutionReq) if err != nil { - return nil, fmt.Errorf("error setting up execution type %s: %v", *serveModelTypeName, err) + return nil, fmt.Errorf("error getting execution type %s: %v", *serveModelTypeName, err) } typesMap := map[string]int64{ - constants.RegisteredModelTypeName: registeredModelResp.GetTypeId(), - constants.ModelVersionTypeName: modelVersionResp.GetTypeId(), - constants.ModelArtifactTypeName: modelArtifactResp.GetTypeId(), - constants.ServingEnvironmentTypeName: servingEnvironmentResp.GetTypeId(), - constants.InferenceServiceTypeName: inferenceServiceResp.GetTypeId(), - constants.ServeModelTypeName: serveModelResp.GetTypeId(), - } - return &ModelRegistryService{ - mlmdClient: client, - typesMap: typesMap, - openapiConv: &generated.OpenAPIConverterImpl{}, - mapper: mapper.NewMapper(typesMap), - }, nil + constants.RegisteredModelTypeName: registeredModelResp.ContextType.GetId(), + constants.ModelVersionTypeName: modelVersionResp.ContextType.GetId(), + constants.ModelArtifactTypeName: modelArtifactResp.ArtifactType.GetId(), + constants.ServingEnvironmentTypeName: servingEnvironmentResp.ContextType.GetId(), + constants.InferenceServiceTypeName: inferenceServiceResp.ContextType.GetId(), + constants.ServeModelTypeName: serveModelResp.ExecutionType.GetId(), + } + return typesMap, nil } // REGISTERED MODELS @@ -1420,8 +1363,3 @@ func (serv *ModelRegistryService) GetServeModels(listOptions api.ListOptions, in } return &toReturn, nil } - -// of returns a pointer to the provided literal/const input -func of[E any](e E) *E { - return &e -} diff --git a/pkg/core/core_test.go b/pkg/core/core_test.go index 3ce08194..e4473253 100644 --- a/pkg/core/core_test.go +++ b/pkg/core/core_test.go @@ -5,8 +5,10 @@ import ( "fmt" "testing" + "github.com/opendatahub-io/model-registry/internal/apiutils" "github.com/opendatahub-io/model-registry/internal/converter" "github.com/opendatahub-io/model-registry/internal/ml_metadata/proto" + "github.com/opendatahub-io/model-registry/internal/mlmdtypes" "github.com/opendatahub-io/model-registry/internal/testutils" "github.com/opendatahub-io/model-registry/pkg/api" "github.com/opendatahub-io/model-registry/pkg/openapi" @@ -51,6 +53,10 @@ type CoreTestSuite struct { mlmdClient proto.MetadataStoreServiceClient } +var ( + canAddFields = apiutils.Of(true) +) + func TestRunCoreTestSuite(t *testing.T) { // before all grpcConn, mlmdClient, teardown := testutils.SetupMLMetadataTestContainer(t) @@ -98,6 +104,8 @@ func (suite *CoreTestSuite) AfterTest(suiteName, testName string) { } func (suite *CoreTestSuite) setupModelRegistryService() *ModelRegistryService { + _, err := mlmdtypes.CreateMLMDTypes(suite.grpcConn) + suite.Nilf(err, "error creating MLMD types: %v", err) // setup model registry service service, err := NewModelRegistryService(suite.grpcConn) suite.Nilf(err, "error creating core service: %v", err) @@ -315,8 +323,7 @@ func (suite *CoreTestSuite) TestModelRegistryStartupWithExistingEmptyTypes() { suite.Equal(0, len(serveModelResp.ExecutionType.Properties)) // create model registry service - _, err = NewModelRegistryService(suite.grpcConn) - suite.Nil(err) + _ = suite.setupModelRegistryService() // assure the types have been correctly setup at startup // check NOT empty props @@ -420,8 +427,8 @@ func (suite *CoreTestSuite) TestModelRegistryFailureForOmittedFieldInRegisteredM _, err := suite.mlmdClient.PutContextType(context.Background(), ®isteredModelReq) suite.Nil(err) - // create model registry service - _, err = NewModelRegistryService(suite.grpcConn) + // steps to create model registry service + _, err = mlmdtypes.CreateMLMDTypes(suite.grpcConn) suite.NotNil(err) suite.Regexp("error setting up context type odh.RegisteredModel: rpc error: code = AlreadyExists.*", err.Error()) } @@ -440,8 +447,8 @@ func (suite *CoreTestSuite) TestModelRegistryFailureForOmittedFieldInModelVersio _, err := suite.mlmdClient.PutContextType(context.Background(), &modelVersionReq) suite.Nil(err) - // create model registry service - _, err = NewModelRegistryService(suite.grpcConn) + // steps to create model registry service + _, err = mlmdtypes.CreateMLMDTypes(suite.grpcConn) suite.NotNil(err) suite.Regexp("error setting up context type odh.ModelVersion: rpc error: code = AlreadyExists.*", err.Error()) } @@ -460,8 +467,8 @@ func (suite *CoreTestSuite) TestModelRegistryFailureForOmittedFieldInModelArtifa _, err := suite.mlmdClient.PutArtifactType(context.Background(), &modelArtifactReq) suite.Nil(err) - // create model registry service - _, err = NewModelRegistryService(suite.grpcConn) + // steps to create model registry service + _, err = mlmdtypes.CreateMLMDTypes(suite.grpcConn) suite.NotNil(err) suite.Regexp("error setting up artifact type odh.ModelArtifact: rpc error: code = AlreadyExists.*", err.Error()) } @@ -479,8 +486,8 @@ func (suite *CoreTestSuite) TestModelRegistryFailureForOmittedFieldInServingEnvi _, err := suite.mlmdClient.PutContextType(context.Background(), &servingEnvironmentReq) suite.Nil(err) - // create model registry service - _, err = NewModelRegistryService(suite.grpcConn) + // steps to create model registry service + _, err = mlmdtypes.CreateMLMDTypes(suite.grpcConn) suite.NotNil(err) suite.Regexp("error setting up context type odh.ServingEnvironment: rpc error: code = AlreadyExists.*", err.Error()) } @@ -499,8 +506,8 @@ func (suite *CoreTestSuite) TestModelRegistryFailureForOmittedFieldInInferenceSe _, err := suite.mlmdClient.PutContextType(context.Background(), &inferenceServiceReq) suite.Nil(err) - // create model registry service - _, err = NewModelRegistryService(suite.grpcConn) + // steps to create model registry service + _, err = mlmdtypes.CreateMLMDTypes(suite.grpcConn) suite.NotNil(err) suite.Regexp("error setting up context type odh.InferenceService: rpc error: code = AlreadyExists.*", err.Error()) } @@ -519,8 +526,8 @@ func (suite *CoreTestSuite) TestModelRegistryFailureForOmittedFieldInServeModel( _, err := suite.mlmdClient.PutExecutionType(context.Background(), &serveModelReq) suite.Nil(err) - // create model registry service - _, err = NewModelRegistryService(suite.grpcConn) + // steps to create model registry service + _, err = mlmdtypes.CreateMLMDTypes(suite.grpcConn) suite.NotNil(err) suite.Regexp("error setting up execution type odh.ServeModel: rpc error: code = AlreadyExists.*", err.Error()) } @@ -700,7 +707,7 @@ func (suite *CoreTestSuite) TestGetRegisteredModelByParamsWithNoResults() { // create mode registry service service := suite.setupModelRegistryService() - _, err := service.GetRegisteredModelByParams(of("not-present"), nil) + _, err := service.GetRegisteredModelByParams(apiutils.Of("not-present"), nil) suite.NotNil(err) suite.Equal("no registered models found for name=not-present, externalId=", err.Error()) } @@ -1145,7 +1152,7 @@ func (suite *CoreTestSuite) TestGetModelVersionByParamsWithNoResults() { registeredModelId := suite.registerModel(service, nil, nil) - _, err := service.GetModelVersionByParams(of("not-present"), ®isteredModelId, nil) + _, err := service.GetModelVersionByParams(apiutils.Of("not-present"), ®isteredModelId, nil) suite.NotNil(err) suite.Equal("no model versions found for versionName=not-present, registeredModelId=1, externalId=", err.Error()) } @@ -1351,10 +1358,10 @@ func (suite *CoreTestSuite) TestCreateModelArtifact() { State: (*openapi.ArtifactState)(&artifactState), Uri: &artifactUri, Description: &artifactDescription, - ModelFormatName: of("onnx"), - ModelFormatVersion: of("1"), - StorageKey: of("aws-connection-models"), - StoragePath: of("bucket"), + ModelFormatName: apiutils.Of("onnx"), + ModelFormatVersion: apiutils.Of("1"), + StorageKey: apiutils.Of("aws-connection-models"), + StoragePath: apiutils.Of("bucket"), CustomProperties: &map[string]openapi.MetadataValue{ "custom_string_prop": { MetadataStringValue: &openapi.MetadataStringValue{ @@ -1633,7 +1640,7 @@ func (suite *CoreTestSuite) TestGetModelArtifactByParamsWithNoResults() { modelVersionId := suite.registerModelVersion(service, nil, nil, nil, nil) - _, err := service.GetModelArtifactByParams(of("not-present"), &modelVersionId, nil) + _, err := service.GetModelArtifactByParams(apiutils.Of("not-present"), &modelVersionId, nil) suite.NotNil(err) suite.Equal("no model artifacts found for artifactName=not-present, modelVersionId=2, externalId=", err.Error()) } @@ -1893,7 +1900,7 @@ func (suite *CoreTestSuite) TestGetServingEnvironmentByParamsWithNoResults() { // create mode registry service service := suite.setupModelRegistryService() - _, err := service.GetServingEnvironmentByParams(of("not-present"), nil) + _, err := service.GetServingEnvironmentByParams(apiutils.Of("not-present"), nil) suite.NotNil(err) suite.Equal("no serving environments found for name=not-present, externalId=", err.Error()) } @@ -2533,7 +2540,7 @@ func (suite *CoreTestSuite) TestGetInferenceServiceByParamsWithNoResults() { parentResourceId := suite.registerServingEnvironment(service, nil, nil) - _, err := service.GetInferenceServiceByParams(of("not-present"), &parentResourceId, nil) + _, err := service.GetInferenceServiceByParams(apiutils.Of("not-present"), &parentResourceId, nil) suite.NotNil(err) suite.Equal("no inference services found for name=not-present, servingEnvironmentId=1, externalId=", err.Error()) } @@ -2672,7 +2679,7 @@ func (suite *CoreTestSuite) TestGetInferenceServices() { ExternalID: &entityExternalId2, ServingEnvironmentId: parentResourceId, RegisteredModelId: registeredModelId, - Runtime: of("model-server0"), + Runtime: apiutils.Of("model-server0"), } secondName := "v2" @@ -2682,7 +2689,7 @@ func (suite *CoreTestSuite) TestGetInferenceServices() { ExternalID: &secondExtId, ServingEnvironmentId: parentResourceId, RegisteredModelId: registeredModelId, - Runtime: of("model-server1"), + Runtime: apiutils.Of("model-server1"), } thirdName := "v3" @@ -2692,7 +2699,7 @@ func (suite *CoreTestSuite) TestGetInferenceServices() { ExternalID: &thirdExtId, ServingEnvironmentId: parentResourceId, RegisteredModelId: registeredModelId, - Runtime: of("model-server2"), + Runtime: apiutils.Of("model-server2"), } createdEntity1, err := service.UpsertInferenceService(eut1) @@ -2715,7 +2722,7 @@ func (suite *CoreTestSuite) TestGetInferenceServices() { ExternalID: &anotherExtId, ServingEnvironmentId: anotherParentResourceId, RegisteredModelId: registeredModelId, - Runtime: of("model-server3"), + Runtime: apiutils.Of("model-server3"), } _, err = service.UpsertInferenceService(eutAnother)