@@ -2355,11 +2355,29 @@ def test_create_model_package_from_containers_incomplete_args(sagemaker_session)
2355
2355
containers = containers ,
2356
2356
)
2357
2357
assert (
2358
- "content_types, response_types, inference_inferences and transform_instances "
2358
+ "content_types and response_types "
2359
2359
"must be provided if containers is present." == str (error )
2360
2360
)
2361
2361
2362
2362
2363
+ def test_create_model_package_from_containers_without_model_package_group_name (sagemaker_session ):
2364
+ model_package_name = "sagemaker-model-package"
2365
+ containers = ["dummy-container" ]
2366
+ content_types = ["application/json" ]
2367
+ response_types = ["application/json" ]
2368
+ with pytest .raises (ValueError ) as error :
2369
+ sagemaker_session .create_model_package_from_containers (
2370
+ model_package_name = model_package_name ,
2371
+ containers = containers ,
2372
+ content_types = content_types ,
2373
+ response_types = response_types ,
2374
+ )
2375
+ assert (
2376
+ "inference_inferences and transform_instances "
2377
+ "must be provided if model_package_group_name is not present." == str (error )
2378
+ )
2379
+
2380
+
2363
2381
def test_create_model_package_from_containers_all_args (sagemaker_session ):
2364
2382
model_package_name = "sagemaker-model-package"
2365
2383
containers = ["dummy-container" ]
@@ -2437,7 +2455,7 @@ def test_create_model_package_from_containers_all_args(sagemaker_session):
2437
2455
2438
2456
2439
2457
def test_create_model_package_from_containers_without_instance_types (sagemaker_session ):
2440
- model_package_name = "sagemaker-model-package"
2458
+ model_package_group_name = "sagemaker-model-package-group-name-1.0 "
2441
2459
containers = ["dummy-container" ]
2442
2460
content_types = ["application/json" ]
2443
2461
response_types = ["application/json" ]
@@ -2470,7 +2488,7 @@ def test_create_model_package_from_containers_without_instance_types(sagemaker_s
2470
2488
containers = containers ,
2471
2489
content_types = content_types ,
2472
2490
response_types = response_types ,
2473
- model_package_name = model_package_name ,
2491
+ model_package_group_name = model_package_group_name ,
2474
2492
model_metrics = model_metrics ,
2475
2493
metadata_properties = metadata_properties ,
2476
2494
marketplace_cert = marketplace_cert ,
@@ -2480,13 +2498,75 @@ def test_create_model_package_from_containers_without_instance_types(sagemaker_s
2480
2498
customer_metadata_properties = customer_metadata_properties ,
2481
2499
)
2482
2500
expected_args = {
2483
- "ModelPackageName " : model_package_name ,
2501
+ "ModelPackageGroupName " : model_package_group_name ,
2484
2502
"InferenceSpecification" : {
2485
2503
"Containers" : containers ,
2486
2504
"SupportedContentTypes" : content_types ,
2487
2505
"SupportedResponseMIMETypes" : response_types ,
2488
- "SupportedRealtimeInferenceInstanceTypes" : None ,
2489
- "SupportedTransformInstanceTypes" : None ,
2506
+ },
2507
+ "ModelPackageDescription" : description ,
2508
+ "ModelMetrics" : model_metrics ,
2509
+ "MetadataProperties" : metadata_properties ,
2510
+ "CertifyForMarketplace" : marketplace_cert ,
2511
+ "ModelApprovalStatus" : approval_status ,
2512
+ "DriftCheckBaselines" : drift_check_baselines ,
2513
+ "CustomerMetadataProperties" : customer_metadata_properties ,
2514
+ }
2515
+ sagemaker_session .sagemaker_client .create_model_package .assert_called_with (** expected_args )
2516
+
2517
+
2518
+ def test_create_model_package_from_containers_with_one_instance_types (sagemaker_session ):
2519
+ model_package_group_name = "sagemaker-model-package-group-name-1.0"
2520
+ containers = ["dummy-container" ]
2521
+ content_types = ["application/json" ]
2522
+ response_types = ["application/json" ]
2523
+ transform_instances = ["ml.m5.xlarge" ]
2524
+ model_metrics = {
2525
+ "Bias" : {
2526
+ "ContentType" : "content-type" ,
2527
+ "S3Uri" : "s3://..." ,
2528
+ }
2529
+ }
2530
+ drift_check_baselines = {
2531
+ "Bias" : {
2532
+ "ConfigFile" : {
2533
+ "ContentType" : "content-type" ,
2534
+ "S3Uri" : "s3://..." ,
2535
+ }
2536
+ }
2537
+ }
2538
+
2539
+ metadata_properties = {
2540
+ "CommitId" : "test-commit-id" ,
2541
+ "Repository" : "test-repository" ,
2542
+ "GeneratedBy" : "sagemaker-python-sdk" ,
2543
+ "ProjectId" : "unit-test" ,
2544
+ }
2545
+ marketplace_cert = (True ,)
2546
+ approval_status = ("Approved" ,)
2547
+ description = "description"
2548
+ customer_metadata_properties = {"key1" : "value1" }
2549
+ sagemaker_session .create_model_package_from_containers (
2550
+ containers = containers ,
2551
+ content_types = content_types ,
2552
+ response_types = response_types ,
2553
+ transform_instances = transform_instances ,
2554
+ model_package_group_name = model_package_group_name ,
2555
+ model_metrics = model_metrics ,
2556
+ metadata_properties = metadata_properties ,
2557
+ marketplace_cert = marketplace_cert ,
2558
+ approval_status = approval_status ,
2559
+ description = description ,
2560
+ drift_check_baselines = drift_check_baselines ,
2561
+ customer_metadata_properties = customer_metadata_properties ,
2562
+ )
2563
+ expected_args = {
2564
+ "ModelPackageGroupName" : model_package_group_name ,
2565
+ "InferenceSpecification" : {
2566
+ "Containers" : containers ,
2567
+ "SupportedContentTypes" : content_types ,
2568
+ "SupportedResponseMIMETypes" : response_types ,
2569
+ "SupportedTransformInstanceTypes" : transform_instances ,
2490
2570
},
2491
2571
"ModelPackageDescription" : description ,
2492
2572
"ModelMetrics" : model_metrics ,
0 commit comments