Skip to content

Commit 269dc08

Browse files
author
Malav Shastri
committed
fix: don't force automatic bucket creation if user don't specify it
1 parent 5392504 commit 269dc08

File tree

1 file changed

+10
-13
lines changed
  • src/sagemaker/jumpstart/hub

1 file changed

+10
-13
lines changed

src/sagemaker/jumpstart/hub/hub.py

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -90,25 +90,22 @@ def _fetch_hub_bucket_name(self) -> str:
9090
if hub_output_location:
9191
location = create_s3_object_reference_from_uri(hub_output_location)
9292
return location.bucket
93-
default_bucket_name = generate_default_hub_bucket_name(self._sagemaker_session)
9493
JUMPSTART_LOGGER.warning(
95-
"There is not a Hub bucket associated with %s. Using %s",
94+
"There is not a Hub bucket associated with %s.",
9695
self.hub_name,
97-
default_bucket_name,
9896
)
99-
return default_bucket_name
97+
return None
10098
except exceptions.ClientError:
101-
hub_bucket_name = generate_default_hub_bucket_name(self._sagemaker_session)
10299
JUMPSTART_LOGGER.warning(
103-
"There is not a Hub bucket associated with %s. Using %s",
100+
"There is not a Hub bucket associated with %s.",
104101
self.hub_name,
105-
hub_bucket_name,
106102
)
107-
return hub_bucket_name
108-
103+
return None
109104
def _generate_hub_storage_location(self, bucket_name: Optional[str] = None) -> None:
110105
"""Generates an ``S3ObjectLocation`` given a Hub name."""
111106
hub_bucket_name = bucket_name or self._fetch_hub_bucket_name()
107+
if hub_bucket_name is None:
108+
return
112109
curr_timestamp = datetime.now().timestamp()
113110
return S3ObjectLocation(bucket=hub_bucket_name, key=f"{self.hub_name}-{curr_timestamp}")
114111

@@ -131,16 +128,16 @@ def create(
131128
) -> Dict[str, str]:
132129
"""Creates a hub with the given description"""
133130

134-
create_hub_bucket_if_it_does_not_exist(
135-
self.hub_storage_location.bucket, self._sagemaker_session
136-
)
131+
s3_storage_config = {
132+
"S3OutputPath": self.hub_storage_location.get_uri()
133+
} if self.hub_storage_location else None
137134

138135
return self._sagemaker_session.create_hub(
139136
hub_name=self.hub_name,
140137
hub_description=description,
141138
hub_display_name=display_name,
142139
hub_search_keywords=search_keywords,
143-
s3_storage_config={"S3OutputPath": self.hub_storage_location.get_uri()},
140+
s3_storage_config=s3_storage_config,
144141
tags=tags,
145142
)
146143

0 commit comments

Comments
 (0)