forked from kubeflow/model-registry
-
Notifications
You must be signed in to change notification settings - Fork 8
/
core_test.go
581 lines (511 loc) · 21.1 KB
/
core_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
package core
import (
"context"
"strings"
"testing"
"time"
"github.com/kubeflow/model-registry/internal/apiutils"
"github.com/kubeflow/model-registry/internal/converter"
"github.com/kubeflow/model-registry/internal/defaults"
"github.com/kubeflow/model-registry/internal/ml_metadata/proto"
"github.com/kubeflow/model-registry/internal/mlmdtypes"
"github.com/kubeflow/model-registry/internal/testutils"
"github.com/kubeflow/model-registry/pkg/api"
"github.com/kubeflow/model-registry/pkg/openapi"
"github.com/stretchr/testify/suite"
"google.golang.org/grpc"
)
// common utility test variables
var (
// generic
ascOrderDirection string
descOrderDirection string
customString string
// registered models
modelName string
modelDescription string
modelOwner string
modelExternalId string
myCustomProp string
// model version
modelVersionName string
modelVersionDescription string
versionExternalId string
author string
// model artifact
artifactName string
artifactDescription string
artifactExtId string
artifactState string
artifactUri string
// entity under test
entityName string
entityExternalId string
entityExternalId2 string
entityDescription string
// ServeModel
executionState string
)
type CoreTestSuite struct {
suite.Suite
grpcConn *grpc.ClientConn
mlmdClient proto.MetadataStoreServiceClient
}
// test defaults
var (
registeredModelTypeName = apiutils.Of(defaults.RegisteredModelTypeName)
modelVersionTypeName = apiutils.Of(defaults.ModelVersionTypeName)
modelArtifactTypeName = apiutils.Of(defaults.ModelArtifactTypeName)
docArtifactTypeName = apiutils.Of(defaults.DocArtifactTypeName)
servingEnvironmentTypeName = apiutils.Of(defaults.ServingEnvironmentTypeName)
inferenceServiceTypeName = apiutils.Of(defaults.InferenceServiceTypeName)
serveModelTypeName = apiutils.Of(defaults.ServeModelTypeName)
canAddFields = apiutils.Of(true)
)
func TestRunCoreTestSuite(t *testing.T) {
// before all
grpcConn, mlmdClient, teardown := testutils.SetupMLMetadataTestContainer(t)
defer teardown(t)
coreTestSuite := CoreTestSuite{
grpcConn: grpcConn,
mlmdClient: mlmdClient,
}
suite.Run(t, &coreTestSuite)
}
// before each test case
func (suite *CoreTestSuite) SetupTest() {
// initialize test variable before each test
ascOrderDirection = "ASC"
descOrderDirection = "DESC"
customString = "this is a customString value"
modelName = "MyAwesomeModel"
modelDescription = "reg model description"
modelOwner = "reg model owner"
modelExternalId = "org.myawesomemodel"
myCustomProp = "myCustomPropValue"
modelVersionName = "v1"
modelVersionDescription = "model version description"
versionExternalId = "org.myawesomemodel@v1"
author = "author1"
artifactName = "Pickle model"
artifactDescription = "artifact description"
artifactExtId = "org.myawesomemodel@v1:pickle"
artifactState = "LIVE"
artifactUri = "path/to/model/v1"
entityName = "MyAwesomeEntity"
entityExternalId = "entityExternalID"
entityExternalId2 = "entityExternalID2"
entityDescription = "lorem ipsum entity description"
executionState = "RUNNING"
// sanity check before each test: connect to MLMD directly, and dry-run any of the gRPC (read) operations;
// on newer Podman might delay in recognising volume mount files for sqlite3 db,
// hence in case of error "Cannot connect sqlite3 database: unable to open database file" make some retries.
maxRetries := 3
var err error
for attempt := 0; attempt < maxRetries; attempt++ {
_, err = suite.mlmdClient.GetContextTypes(context.Background(), &proto.GetContextTypesRequest{})
if err == nil {
break
} else if !strings.Contains(err.Error(), "Cannot connect sqlite3 database: unable to open database file") {
break // err is different than expected
}
time.Sleep(1 * time.Second)
}
suite.Nilf(err, "error connecting to MLMD and dry-run any of the gRPC operations: %v", err)
}
// after each test
// - remove the metadata sqlite file used by mlmd, this way mlmd will recreate it
func (suite *CoreTestSuite) AfterTest(suiteName, testName string) {
if err := testutils.ClearMetadataSqliteDB(); err != nil {
suite.Error(err)
}
}
func (suite *CoreTestSuite) setupModelRegistryService() *ModelRegistryService {
mlmdtypeNames := mlmdtypes.NewMLMDTypeNamesConfigFromDefaults()
_, err := mlmdtypes.CreateMLMDTypes(suite.grpcConn, mlmdtypeNames)
suite.Nilf(err, "error creating MLMD types: %v", err)
// setup model registry service
service, err := NewModelRegistryService(suite.grpcConn, mlmdtypeNames)
suite.Nilf(err, "error creating core service: %v", err)
mrService, ok := service.(*ModelRegistryService)
suite.True(ok)
return mrService
}
// utility function that register a new simple model and return its ID
func (suite *CoreTestSuite) registerModel(service api.ModelRegistryApi, overrideModelName *string, overrideExternalId *string) string {
registeredModel := &openapi.RegisteredModel{
Name: modelName,
ExternalId: &modelExternalId,
Description: &modelDescription,
CustomProperties: &map[string]openapi.MetadataValue{
"myCustomProp": {
MetadataStringValue: converter.NewMetadataStringValue(myCustomProp),
},
},
}
if overrideModelName != nil {
registeredModel.Name = *overrideModelName
}
if overrideExternalId != nil {
registeredModel.ExternalId = overrideExternalId
}
// test
createdModel, err := service.UpsertRegisteredModel(registeredModel)
suite.Nilf(err, "error creating registered model: %v", err)
return *createdModel.Id
}
// utility function that register a new simple ServingEnvironment and return its ID
func (suite *CoreTestSuite) registerServingEnvironment(service api.ModelRegistryApi, overrideName *string, overrideExternalId *string) string {
eutName := "Simple ServingEnvironment"
eutExtID := "Simple ServingEnvironment ExtID"
eut := &openapi.ServingEnvironment{
Name: &eutName,
ExternalId: &eutExtID,
Description: &entityDescription,
CustomProperties: &map[string]openapi.MetadataValue{
"myCustomProp": {
MetadataStringValue: converter.NewMetadataStringValue(myCustomProp),
},
},
}
if overrideName != nil {
eut.Name = overrideName
}
if overrideExternalId != nil {
eut.ExternalId = overrideExternalId
}
// test
createdEntity, err := service.UpsertServingEnvironment(eut)
suite.Nilf(err, "error creating ServingEnvironment: %v", err)
return *createdEntity.Id
}
// utility function that register a new simple model and return its ID
func (suite *CoreTestSuite) registerModelVersion(
service api.ModelRegistryApi,
overrideModelName *string,
overrideExternalId *string,
overrideVersionName *string,
overrideVersionExtId *string,
) string {
registeredModelId := suite.registerModel(service, overrideModelName, overrideExternalId)
modelVersion := &openapi.ModelVersion{
Name: modelVersionName,
ExternalId: &versionExternalId,
Description: &modelVersionDescription,
Author: &author,
}
if overrideVersionName != nil {
modelVersion.Name = *overrideVersionName
}
if overrideVersionExtId != nil {
modelVersion.ExternalId = overrideVersionExtId
}
createdVersion, err := service.UpsertModelVersion(modelVersion, ®isteredModelId)
suite.Nilf(err, "error creating model version: %v", err)
return *createdVersion.Id
}
// utility function that register a new simple ServingEnvironment and return its ID
func (suite *CoreTestSuite) registerInferenceService(service api.ModelRegistryApi, registerdModelId string, overrideParentResourceName *string, overrideParentResourceExternalId *string, overrideName *string, overrideExternalId *string) string {
servingEnvironmentId := suite.registerServingEnvironment(service, overrideParentResourceName, overrideParentResourceExternalId)
eutName := "simpleInferenceService"
eutExtID := "simpleInferenceService ExtID"
eut := &openapi.InferenceService{
Name: &eutName,
ExternalId: &eutExtID,
RegisteredModelId: registerdModelId,
ServingEnvironmentId: servingEnvironmentId,
CustomProperties: &map[string]openapi.MetadataValue{
"myCustomProp": {
MetadataStringValue: converter.NewMetadataStringValue(myCustomProp),
},
},
}
if overrideName != nil {
eut.Name = overrideName
}
if overrideExternalId != nil {
eut.ExternalId = overrideExternalId
}
// test
createdEntity, err := service.UpsertInferenceService(eut)
suite.Nilf(err, "error creating InferenceService: %v", err)
return *createdEntity.Id
}
func (suite *CoreTestSuite) TestModelRegistryStartupWithExistingEmptyTypes() {
ctx := context.Background()
// create all types without props
registeredModelReq := proto.PutContextTypeRequest{
CanAddFields: canAddFields,
ContextType: &proto.ContextType{
Name: registeredModelTypeName,
},
}
modelVersionReq := proto.PutContextTypeRequest{
CanAddFields: canAddFields,
ContextType: &proto.ContextType{
Name: modelVersionTypeName,
},
}
docArtifactReq := proto.PutArtifactTypeRequest{
CanAddFields: canAddFields,
ArtifactType: &proto.ArtifactType{
Name: docArtifactTypeName,
},
}
modelArtifactReq := proto.PutArtifactTypeRequest{
CanAddFields: canAddFields,
ArtifactType: &proto.ArtifactType{
Name: modelArtifactTypeName,
},
}
servingEnvironmentReq := proto.PutContextTypeRequest{
CanAddFields: canAddFields,
ContextType: &proto.ContextType{
Name: servingEnvironmentTypeName,
},
}
inferenceServiceReq := proto.PutContextTypeRequest{
CanAddFields: canAddFields,
ContextType: &proto.ContextType{
Name: inferenceServiceTypeName,
},
}
serveModelReq := proto.PutExecutionTypeRequest{
CanAddFields: canAddFields,
ExecutionType: &proto.ExecutionType{
Name: serveModelTypeName,
},
}
_, err := suite.mlmdClient.PutContextType(context.Background(), ®isteredModelReq)
suite.Nil(err)
_, err = suite.mlmdClient.PutContextType(context.Background(), &modelVersionReq)
suite.Nil(err)
_, err = suite.mlmdClient.PutArtifactType(context.Background(), &docArtifactReq)
suite.Nil(err)
_, err = suite.mlmdClient.PutArtifactType(context.Background(), &modelArtifactReq)
suite.Nil(err)
_, err = suite.mlmdClient.PutContextType(context.Background(), &servingEnvironmentReq)
suite.Nil(err)
_, err = suite.mlmdClient.PutContextType(context.Background(), &inferenceServiceReq)
suite.Nil(err)
_, err = suite.mlmdClient.PutExecutionType(context.Background(), &serveModelReq)
suite.Nil(err)
// check empty props
regModelResp, _ := suite.mlmdClient.GetContextType(ctx, &proto.GetContextTypeRequest{
TypeName: registeredModelTypeName,
})
modelVersionResp, _ := suite.mlmdClient.GetContextType(ctx, &proto.GetContextTypeRequest{
TypeName: modelVersionTypeName,
})
docArtifactResp, _ := suite.mlmdClient.GetArtifactType(ctx, &proto.GetArtifactTypeRequest{
TypeName: docArtifactTypeName,
})
modelArtifactResp, _ := suite.mlmdClient.GetArtifactType(ctx, &proto.GetArtifactTypeRequest{
TypeName: modelArtifactTypeName,
})
servingEnvResp, _ := suite.mlmdClient.GetContextType(ctx, &proto.GetContextTypeRequest{
TypeName: servingEnvironmentTypeName,
})
inferenceServiceResp, _ := suite.mlmdClient.GetContextType(ctx, &proto.GetContextTypeRequest{
TypeName: inferenceServiceTypeName,
})
serveModelResp, _ := suite.mlmdClient.GetExecutionType(ctx, &proto.GetExecutionTypeRequest{
TypeName: serveModelTypeName,
})
suite.Equal(0, len(regModelResp.ContextType.Properties))
suite.Equal(0, len(modelVersionResp.ContextType.Properties))
suite.Equal(0, len(docArtifactResp.ArtifactType.Properties))
suite.Equal(0, len(modelArtifactResp.ArtifactType.Properties))
suite.Equal(0, len(servingEnvResp.ContextType.Properties))
suite.Equal(0, len(inferenceServiceResp.ContextType.Properties))
suite.Equal(0, len(serveModelResp.ExecutionType.Properties))
// create model registry service
_ = suite.setupModelRegistryService()
// assure the types have been correctly setup at startup
// check NOT empty props
regModelResp, _ = suite.mlmdClient.GetContextType(ctx, &proto.GetContextTypeRequest{
TypeName: registeredModelTypeName,
})
suite.NotNilf(regModelResp.ContextType, "registered model type %s should exists", *registeredModelTypeName)
suite.Equal(*registeredModelTypeName, *regModelResp.ContextType.Name)
suite.Equal(3, len(regModelResp.ContextType.Properties))
modelVersionResp, _ = suite.mlmdClient.GetContextType(ctx, &proto.GetContextTypeRequest{
TypeName: modelVersionTypeName,
})
suite.NotNilf(modelVersionResp.ContextType, "model version type %s should exists", *modelVersionTypeName)
suite.Equal(*modelVersionTypeName, *modelVersionResp.ContextType.Name)
suite.Equal(5, len(modelVersionResp.ContextType.Properties))
docArtifactResp, _ = suite.mlmdClient.GetArtifactType(ctx, &proto.GetArtifactTypeRequest{
TypeName: docArtifactTypeName,
})
suite.NotNilf(docArtifactResp.ArtifactType, "doc artifact type %s should exists", *docArtifactTypeName)
suite.Equal(*docArtifactTypeName, *docArtifactResp.ArtifactType.Name)
suite.Equal(1, len(docArtifactResp.ArtifactType.Properties))
modelArtifactResp, _ = suite.mlmdClient.GetArtifactType(ctx, &proto.GetArtifactTypeRequest{
TypeName: modelArtifactTypeName,
})
suite.NotNilf(modelArtifactResp.ArtifactType, "model artifact type %s should exists", *modelArtifactTypeName)
suite.Equal(*modelArtifactTypeName, *modelArtifactResp.ArtifactType.Name)
suite.Equal(6, len(modelArtifactResp.ArtifactType.Properties))
servingEnvResp, _ = suite.mlmdClient.GetContextType(ctx, &proto.GetContextTypeRequest{
TypeName: servingEnvironmentTypeName,
})
suite.NotNilf(servingEnvResp.ContextType, "serving environment type %s should exists", *servingEnvironmentTypeName)
suite.Equal(*servingEnvironmentTypeName, *servingEnvResp.ContextType.Name)
suite.Equal(1, len(servingEnvResp.ContextType.Properties))
inferenceServiceResp, _ = suite.mlmdClient.GetContextType(ctx, &proto.GetContextTypeRequest{
TypeName: inferenceServiceTypeName,
})
suite.NotNilf(inferenceServiceResp.ContextType, "inference service type %s should exists", *inferenceServiceTypeName)
suite.Equal(*inferenceServiceTypeName, *inferenceServiceResp.ContextType.Name)
suite.Equal(6, len(inferenceServiceResp.ContextType.Properties))
serveModelResp, _ = suite.mlmdClient.GetExecutionType(ctx, &proto.GetExecutionTypeRequest{
TypeName: serveModelTypeName,
})
suite.NotNilf(serveModelResp.ExecutionType, "serve model type %s should exists", *serveModelTypeName)
suite.Equal(*serveModelTypeName, *serveModelResp.ExecutionType.Name)
suite.Equal(2, len(serveModelResp.ExecutionType.Properties))
}
func (suite *CoreTestSuite) TestModelRegistryTypes() {
// create model registry service
_ = suite.setupModelRegistryService()
// assure the types have been correctly setup at startup
ctx := context.Background()
regModelResp, _ := suite.mlmdClient.GetContextType(ctx, &proto.GetContextTypeRequest{
TypeName: registeredModelTypeName,
})
suite.NotNilf(regModelResp.ContextType, "registered model type %s should exists", *registeredModelTypeName)
suite.Equal(*registeredModelTypeName, *regModelResp.ContextType.Name)
modelVersionResp, _ := suite.mlmdClient.GetContextType(ctx, &proto.GetContextTypeRequest{
TypeName: modelVersionTypeName,
})
suite.NotNilf(modelVersionResp.ContextType, "model version type %s should exists", *modelVersionTypeName)
suite.Equal(*modelVersionTypeName, *modelVersionResp.ContextType.Name)
docArtifactResp, _ := suite.mlmdClient.GetArtifactType(ctx, &proto.GetArtifactTypeRequest{
TypeName: docArtifactTypeName,
})
suite.NotNilf(docArtifactResp.ArtifactType, "doc artifact type %s should exists", *docArtifactTypeName)
suite.Equal(*docArtifactTypeName, *docArtifactResp.ArtifactType.Name)
modelArtifactResp, _ := suite.mlmdClient.GetArtifactType(ctx, &proto.GetArtifactTypeRequest{
TypeName: modelArtifactTypeName,
})
suite.NotNilf(modelArtifactResp.ArtifactType, "model artifact type %s should exists", *modelArtifactTypeName)
suite.Equal(*modelArtifactTypeName, *modelArtifactResp.ArtifactType.Name)
servingEnvResp, _ := suite.mlmdClient.GetContextType(ctx, &proto.GetContextTypeRequest{
TypeName: servingEnvironmentTypeName,
})
suite.NotNilf(servingEnvResp.ContextType, "serving environment type %s should exists", *servingEnvironmentTypeName)
suite.Equal(*servingEnvironmentTypeName, *servingEnvResp.ContextType.Name)
inferenceServiceResp, _ := suite.mlmdClient.GetContextType(ctx, &proto.GetContextTypeRequest{
TypeName: inferenceServiceTypeName,
})
suite.NotNilf(inferenceServiceResp.ContextType, "inference service type %s should exists", *inferenceServiceTypeName)
suite.Equal(*inferenceServiceTypeName, *inferenceServiceResp.ContextType.Name)
serveModelResp, _ := suite.mlmdClient.GetExecutionType(ctx, &proto.GetExecutionTypeRequest{
TypeName: serveModelTypeName,
})
suite.NotNilf(serveModelResp.ExecutionType, "serve model type %s should exists", *serveModelTypeName)
suite.Equal(*serveModelTypeName, *serveModelResp.ExecutionType.Name)
}
func (suite *CoreTestSuite) TestModelRegistryFailureForOmittedFieldInRegisteredModel() {
registeredModelReq := proto.PutContextTypeRequest{
CanAddFields: canAddFields,
ContextType: &proto.ContextType{
Name: registeredModelTypeName,
Properties: map[string]proto.PropertyType{
"deprecated": proto.PropertyType_STRING,
},
},
}
_, err := suite.mlmdClient.PutContextType(context.Background(), ®isteredModelReq)
suite.Nil(err)
// steps to create model registry service
_, err = mlmdtypes.CreateMLMDTypes(suite.grpcConn, mlmdtypes.NewMLMDTypeNamesConfigFromDefaults())
suite.NotNil(err)
suite.Regexp("error setting up context type "+*registeredModelTypeName+": rpc error: code = AlreadyExists.*", err.Error())
}
func (suite *CoreTestSuite) TestModelRegistryFailureForOmittedFieldInModelVersion() {
modelVersionReq := proto.PutContextTypeRequest{
CanAddFields: canAddFields,
ContextType: &proto.ContextType{
Name: modelVersionTypeName,
Properties: map[string]proto.PropertyType{
"deprecated": proto.PropertyType_STRING,
},
},
}
_, err := suite.mlmdClient.PutContextType(context.Background(), &modelVersionReq)
suite.Nil(err)
// steps to create model registry service
_, err = mlmdtypes.CreateMLMDTypes(suite.grpcConn, mlmdtypes.NewMLMDTypeNamesConfigFromDefaults())
suite.NotNil(err)
suite.Regexp("error setting up context type "+*modelVersionTypeName+": rpc error: code = AlreadyExists.*", err.Error())
}
func (suite *CoreTestSuite) TestModelRegistryFailureForOmittedFieldInModelArtifact() {
modelArtifactReq := proto.PutArtifactTypeRequest{
CanAddFields: canAddFields,
ArtifactType: &proto.ArtifactType{
Name: modelArtifactTypeName,
Properties: map[string]proto.PropertyType{
"deprecated": proto.PropertyType_STRING,
},
},
}
_, err := suite.mlmdClient.PutArtifactType(context.Background(), &modelArtifactReq)
suite.Nil(err)
// steps to create model registry service
_, err = mlmdtypes.CreateMLMDTypes(suite.grpcConn, mlmdtypes.NewMLMDTypeNamesConfigFromDefaults())
suite.NotNil(err)
suite.Regexp("error setting up artifact type "+*modelArtifactTypeName+": rpc error: code = AlreadyExists.*", err.Error())
}
func (suite *CoreTestSuite) TestModelRegistryFailureForOmittedFieldInServingEnvironment() {
servingEnvironmentReq := proto.PutContextTypeRequest{
CanAddFields: canAddFields,
ContextType: &proto.ContextType{
Name: servingEnvironmentTypeName,
Properties: map[string]proto.PropertyType{
"deprecated": proto.PropertyType_STRING,
},
},
}
_, err := suite.mlmdClient.PutContextType(context.Background(), &servingEnvironmentReq)
suite.Nil(err)
// steps to create model registry service
_, err = mlmdtypes.CreateMLMDTypes(suite.grpcConn, mlmdtypes.NewMLMDTypeNamesConfigFromDefaults())
suite.NotNil(err)
suite.Regexp("error setting up context type "+*servingEnvironmentTypeName+": rpc error: code = AlreadyExists.*", err.Error())
}
func (suite *CoreTestSuite) TestModelRegistryFailureForOmittedFieldInInferenceService() {
inferenceServiceReq := proto.PutContextTypeRequest{
CanAddFields: canAddFields,
ContextType: &proto.ContextType{
Name: inferenceServiceTypeName,
Properties: map[string]proto.PropertyType{
"deprecated": proto.PropertyType_STRING,
},
},
}
_, err := suite.mlmdClient.PutContextType(context.Background(), &inferenceServiceReq)
suite.Nil(err)
// steps to create model registry service
_, err = mlmdtypes.CreateMLMDTypes(suite.grpcConn, mlmdtypes.NewMLMDTypeNamesConfigFromDefaults())
suite.NotNil(err)
suite.Regexp("error setting up context type "+*inferenceServiceTypeName+": rpc error: code = AlreadyExists.*", err.Error())
}
func (suite *CoreTestSuite) TestModelRegistryFailureForOmittedFieldInServeModel() {
serveModelReq := proto.PutExecutionTypeRequest{
CanAddFields: canAddFields,
ExecutionType: &proto.ExecutionType{
Name: serveModelTypeName,
Properties: map[string]proto.PropertyType{
"deprecated": proto.PropertyType_STRING,
},
},
}
_, err := suite.mlmdClient.PutExecutionType(context.Background(), &serveModelReq)
suite.Nil(err)
// steps to create model registry service
_, err = mlmdtypes.CreateMLMDTypes(suite.grpcConn, mlmdtypes.NewMLMDTypeNamesConfigFromDefaults())
suite.NotNil(err)
suite.Regexp("error setting up execution type "+*serveModelTypeName+": rpc error: code = AlreadyExists.*", err.Error())
}