@@ -60,30 +60,30 @@ def test_mnist(sagemaker_session, instance_type):
60
60
61
61
def test_server_side_encryption (sagemaker_session ):
62
62
63
- bucket_with_kms , kms_key = kms_utils . get_or_create_bucket_with_encryption ( sagemaker_session .boto_session ,
64
- ROLE )
65
-
66
- output_path = os .path .join (bucket_with_kms , 'test-server-side-encryption' , time .strftime ('%y%m%d-%H%M' ))
67
-
68
- estimator = TensorFlow (entry_point = SCRIPT ,
69
- role = ROLE ,
70
- train_instance_count = 1 ,
71
- train_instance_type = 'ml.c5.xlarge' ,
72
- sagemaker_session = sagemaker_session ,
73
- py_version = 'py3' ,
74
- framework_version = '1.11' ,
75
- base_job_name = 'test-server-side-encryption' ,
76
- code_location = output_path ,
77
- output_path = output_path ,
78
- model_dir = '/opt/ml/model' ,
79
- output_kms_key = kms_key )
80
-
81
- inputs = estimator .sagemaker_session .upload_data (
82
- path = os .path .join (RESOURCE_PATH , 'data' ),
83
- key_prefix = 'scriptmode/mnist' )
84
-
85
- with timeout .timeout (minutes = integ .TRAINING_DEFAULT_TIMEOUT_MINUTES ):
86
- estimator .fit (inputs )
63
+ boto_session = sagemaker_session .boto_session
64
+ with kms_utils . bucket_with_encryption ( boto_session , ROLE ) as ( bucket_with_kms , kms_key ):
65
+
66
+ output_path = os .path .join (bucket_with_kms , 'test-server-side-encryption' , time .strftime ('%y%m%d-%H%M' ))
67
+
68
+ estimator = TensorFlow (entry_point = SCRIPT ,
69
+ role = ROLE ,
70
+ train_instance_count = 1 ,
71
+ train_instance_type = 'ml.c5.xlarge' ,
72
+ sagemaker_session = sagemaker_session ,
73
+ py_version = 'py3' ,
74
+ framework_version = '1.11' ,
75
+ base_job_name = 'test-server-side-encryption' ,
76
+ code_location = output_path ,
77
+ output_path = output_path ,
78
+ model_dir = '/opt/ml/model' ,
79
+ output_kms_key = kms_key )
80
+
81
+ inputs = estimator .sagemaker_session .upload_data (
82
+ path = os .path .join (RESOURCE_PATH , 'data' ),
83
+ key_prefix = 'scriptmode/mnist' )
84
+
85
+ with timeout .timeout (minutes = integ .TRAINING_DEFAULT_TIMEOUT_MINUTES ):
86
+ estimator .fit (inputs )
87
87
88
88
89
89
@pytest .mark .canary_quick
0 commit comments