Skip to content

Commit 3fe2774

Browse files
author
Malav Shastri
committed
revert: don't force automatic bucket creation if user don't specify it
1 parent 37a36c8 commit 3fe2774

File tree

1 file changed

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

1 file changed

+13
-11
lines changed

src/sagemaker/jumpstart/hub/hub.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@
3333
from sagemaker.jumpstart.hub.utils import (
3434
get_hub_model_version,
3535
get_info_from_hub_resource_arn,
36+
create_hub_bucket_if_it_does_not_exist,
37+
generate_default_hub_bucket_name,
3638
create_s3_object_reference_from_uri,
3739
construct_hub_arn_from_name,
3840
)
@@ -88,23 +90,25 @@ def _fetch_hub_bucket_name(self) -> str:
8890
if hub_output_location:
8991
location = create_s3_object_reference_from_uri(hub_output_location)
9092
return location.bucket
93+
default_bucket_name = generate_default_hub_bucket_name(self._sagemaker_session)
9194
JUMPSTART_LOGGER.warning(
92-
"There is not a Hub bucket associated with %s.",
95+
"There is not a Hub bucket associated with %s. Using %s",
9396
self.hub_name,
97+
default_bucket_name,
9498
)
95-
return None
99+
return default_bucket_name
96100
except exceptions.ClientError:
101+
hub_bucket_name = generate_default_hub_bucket_name(self._sagemaker_session)
97102
JUMPSTART_LOGGER.warning(
98-
"There is not a Hub bucket associated with %s.",
103+
"There is not a Hub bucket associated with %s. Using %s",
99104
self.hub_name,
105+
hub_bucket_name,
100106
)
101-
return None
107+
return hub_bucket_name
102108

103109
def _generate_hub_storage_location(self, bucket_name: Optional[str] = None) -> None:
104110
"""Generates an ``S3ObjectLocation`` given a Hub name."""
105111
hub_bucket_name = bucket_name or self._fetch_hub_bucket_name()
106-
if hub_bucket_name is None:
107-
return
108112
curr_timestamp = datetime.now().timestamp()
109113
return S3ObjectLocation(bucket=hub_bucket_name, key=f"{self.hub_name}-{curr_timestamp}")
110114

@@ -127,18 +131,16 @@ def create(
127131
) -> Dict[str, str]:
128132
"""Creates a hub with the given description"""
129133

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

136138
return self._sagemaker_session.create_hub(
137139
hub_name=self.hub_name,
138140
hub_description=description,
139141
hub_display_name=display_name,
140142
hub_search_keywords=search_keywords,
141-
s3_storage_config=s3_storage_config,
143+
s3_storage_config={"S3OutputPath": self.hub_storage_location.get_uri()},
142144
tags=tags,
143145
)
144146

0 commit comments

Comments
 (0)