-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Sagemaker always try to create default bucket, even the custom default_bucket is already exists #1990
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hi @Basanti-xian, are you running your SageMaker job in If so, this is expected since create_bucket() returns a |
@ChuyangDeng why the if condition |
Hi @ChuyangDeng , the SageMaker job running in |
IMO, there should be an option (e.g. via an argument to |
@Basanti-xian @chuyang-deng This is causing me the same issue. The bucket exists but the creation_date is returning None even though I can see the creation date in the console. It then tries to create it. I am in eu-west-1. I agree with @jcmcken that the creation should be optional not auto by default. We don't have create bucket permissions, our buckets are created for us. So when it tries to create a bucket for us we get access denied. |
Another option is to use the s3 head_bucket api call. Signature: s3.head_bucket(*args, **kwargs) |
I'm facing the same issue and have consider three workarounds to this. 1. Rol has The
2. Code already exists in S3 If you provide an s3 location code_location where the code lives the attribute 3. Hardcode the value # Example with SKLearnModel
from sagemaker.sklearn.model import SKLearnModel
from sagemaker.session import Session
smk_session = Session(default_bucket='your-bucket')
model = SKLearnModel(
...,
sagemaker_session=smk_session
)
# Harcode bucket attribute
model.bucket = 'your_bucket' |
One feasible solution is to check access to In this way neither you would need to have permission If you accept PR, I'm open to develop this. import boto3
def _check_default_bucket_access(self):
default_bucket = self._default_bucket_name_override
if not default_bucket:
return False
client = self.boto_session.client('s3')
response = client.head_bucket(
Bucket=default_bucket,
)
status_code = response['ResponseMetaData']['HTTPStatusCode']
if status_code == 200:
return True
elif status_code in [400, 403]:
return False
def default_bucket(self):
"""Return the name of the default bucket to use in relevant Amazon SageMaker interactions.
This function will create the s3 bucket if it does not exist.
Returns:
str: The name of the default bucket, which is of the form:
``sagemaker-{region}-{AWS account ID}``.
"""
if self._default_bucket:
return self._default_bucket
default_bucket_access = self._check_default_bucket_access()
if default_bucket_access:
self._default_bucket = default_bucket
return self._default_bucket
...
return self._default_bucket |
@ahsan-z-khan @staubhp could you provide insight to the discussion or know anyone from aws who can? |
The issue should be fixed now. Please use recent sagemaker-python-sdk >= v2.96.0 |
I still get the same error despite upgrading sagemaker version to >=2.96.0. @mufaddal-rohawala. |
@mufaddal-rohawala should be fixed, is not |
this bug fix listed in the release was to change a required "s3:ListAllMyBuckets" to a required "s3:ListBucket". |
Looking at the source code: sagemaker-python-sdk/src/sagemaker/session.py Line 6151 in 300cd17
Can you override it with a session and declare the region there? |
Describe the bug
Sagemaker session always try to create default bucket, even though I already given an existing customised bucket when init Sagemaker session.
“errorMessage”: “Your previous request to create the named bucket succeeded and you already own it.“
Also, it happens continuously every few seconds.
To reproduce
Expected behavior
Sagemaker should check the provided bucket is already exist and stop creating new.

However,
bucket.creation_date
returns None even when the bucket exists, and trying to create it again.Screenshots or logs
Events from cloudtrail:
System information
The text was updated successfully, but these errors were encountered: