# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"). You # may not use this file except in compliance with the License. A copy of # the License is located at # # http://aws.amazon.com/apache2.0/ # # or in the "license" file accompanying this file. This file is # distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF # ANY KIND, either express or implied. See the License for the specific # language governing permissions and limitations under the License. from __future__ import absolute_import import boto3 from botocore.config import Config from sagemaker import Session CUSTOM_BUCKET_NAME = "this-bucket-should-not-exist" def test_sagemaker_session_does_not_create_bucket_on_init( sagemaker_client_config, sagemaker_runtime_config, boto_session ): sagemaker_client_config.setdefault("config", Config(retries=dict(max_attempts=10))) sagemaker_client = ( boto_session.client("sagemaker", **sagemaker_client_config) if sagemaker_client_config else None ) runtime_client = ( boto_session.client("sagemaker-runtime", **sagemaker_runtime_config) if sagemaker_runtime_config else None ) Session( boto_session=boto_session, sagemaker_client=sagemaker_client, sagemaker_runtime_client=runtime_client, default_bucket=CUSTOM_BUCKET_NAME, ) s3 = boto3.resource("s3", region_name=boto_session.region_name) assert s3.Bucket(CUSTOM_BUCKET_NAME).creation_date is None