From 94b6b8e3d865335e9cc1393d5445142e2ba6e3d1 Mon Sep 17 00:00:00 2001 From: Hossein Jazayeri Date: Wed, 15 Jun 2022 12:09:13 +0200 Subject: [PATCH 1/2] fix: pass `default_bucket` to `Session` object in `LocalSession` class construct --- src/sagemaker/local/local_session.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/sagemaker/local/local_session.py b/src/sagemaker/local/local_session.py index f5f86f59d5..6bfaa2fc34 100644 --- a/src/sagemaker/local/local_session.py +++ b/src/sagemaker/local/local_session.py @@ -491,7 +491,7 @@ class LocalSession(Session): :class:`~sagemaker.session.Session`. """ - def __init__(self, boto_session=None, s3_endpoint_url=None, disable_local_code=False): + def __init__(self, boto_session=None, s3_endpoint_url=None, disable_local_code=False, default_bucket=None): """Create a Local SageMaker Session. Args: @@ -503,6 +503,12 @@ def __init__(self, boto_session=None, s3_endpoint_url=None, disable_local_code=F disable_local_code (bool): Set ``True`` to override the default AWS configuration chain to disable the ``local.local_code`` setting, which may not be supported for some SDK features (default: False). + default_bucket (str): The default Amazon S3 bucket to be used by this session. + This will be created the next time an Amazon S3 bucket is needed (by calling + :func:`default_bucket`). + If not provided, a default bucket will be created based on the following format: + "sagemaker-{region}-{aws-account-id}". + Example: "sagemaker-my-custom-bucket". """ self.s3_endpoint_url = s3_endpoint_url # We use this local variable to avoid disrupting the __init__->_initialize API of the @@ -510,7 +516,7 @@ def __init__(self, boto_session=None, s3_endpoint_url=None, disable_local_code=F # discourage external use: self._disable_local_code = disable_local_code - super(LocalSession, self).__init__(boto_session) + super(LocalSession, self).__init__(boto_session, default_bucket=default_bucket) if platform.system() == "Windows": logger.warning("Windows Support for Local Mode is Experimental") From 658da8a069f6c4f24c7564ce13664b1f8d25f347 Mon Sep 17 00:00:00 2001 From: Hossein Jazayeri Date: Tue, 21 Jun 2022 11:31:05 +0200 Subject: [PATCH 2/2] fix code format --- src/sagemaker/local/local_session.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/sagemaker/local/local_session.py b/src/sagemaker/local/local_session.py index 6bfaa2fc34..5984a5185c 100644 --- a/src/sagemaker/local/local_session.py +++ b/src/sagemaker/local/local_session.py @@ -491,7 +491,9 @@ class LocalSession(Session): :class:`~sagemaker.session.Session`. """ - def __init__(self, boto_session=None, s3_endpoint_url=None, disable_local_code=False, default_bucket=None): + def __init__( + self, boto_session=None, s3_endpoint_url=None, disable_local_code=False, default_bucket=None + ): """Create a Local SageMaker Session. Args: