@@ -2355,11 +2355,29 @@ def test_create_model_package_from_containers_incomplete_args(sagemaker_session)
23552355 containers = containers ,
23562356 )
23572357 assert (
2358- "content_types, response_types, inference_inferences and transform_instances "
2358+ "content_types and response_types "
23592359 "must be provided if containers is present." == str (error )
23602360 )
23612361
23622362
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+
23632381def test_create_model_package_from_containers_all_args (sagemaker_session ):
23642382 model_package_name = "sagemaker-model-package"
23652383 containers = ["dummy-container" ]
@@ -2437,7 +2455,7 @@ def test_create_model_package_from_containers_all_args(sagemaker_session):
24372455
24382456
24392457def 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 "
24412459 containers = ["dummy-container" ]
24422460 content_types = ["application/json" ]
24432461 response_types = ["application/json" ]
@@ -2470,7 +2488,7 @@ def test_create_model_package_from_containers_without_instance_types(sagemaker_s
24702488 containers = containers ,
24712489 content_types = content_types ,
24722490 response_types = response_types ,
2473- model_package_name = model_package_name ,
2491+ model_package_group_name = model_package_group_name ,
24742492 model_metrics = model_metrics ,
24752493 metadata_properties = metadata_properties ,
24762494 marketplace_cert = marketplace_cert ,
@@ -2480,13 +2498,75 @@ def test_create_model_package_from_containers_without_instance_types(sagemaker_s
24802498 customer_metadata_properties = customer_metadata_properties ,
24812499 )
24822500 expected_args = {
2483- "ModelPackageName " : model_package_name ,
2501+ "ModelPackageGroupName " : model_package_group_name ,
24842502 "InferenceSpecification" : {
24852503 "Containers" : containers ,
24862504 "SupportedContentTypes" : content_types ,
24872505 "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 ,
24902570 },
24912571 "ModelPackageDescription" : description ,
24922572 "ModelMetrics" : model_metrics ,
0 commit comments