@@ -94,35 +94,37 @@ def _get_s3_client(self) -> BaseClient:
94
94
"""Returns an S3 client used for creating a HubContentDocument."""
95
95
return boto3 .client ("s3" , region_name = self .region )
96
96
97
- def _fetch_hub_bucket_name (self ) -> str :
97
+ def _fetch_hub_storage_location (self ) -> S3ObjectLocation :
98
98
"""Retrieves hub bucket name from Hub config if exists"""
99
99
try :
100
100
hub_response = self ._sagemaker_session .describe_hub (hub_name = self .hub_name )
101
101
hub_output_location = hub_response ["S3StorageConfig" ].get ("S3OutputPath" )
102
+ print ("aaaaa" , hub_output_location )
102
103
if hub_output_location :
103
104
location = create_s3_object_reference_from_uri (hub_output_location )
104
- return location . bucket
105
+ return location
105
106
default_bucket_name = generate_default_hub_bucket_name (self ._sagemaker_session )
107
+ curr_timestamp = datetime .now ().timestamp ()
106
108
JUMPSTART_LOGGER .warning (
107
109
"There is not a Hub bucket associated with %s. Using %s" ,
108
110
self .hub_name ,
109
111
default_bucket_name ,
110
112
)
111
- return default_bucket_name
113
+ return S3ObjectLocation ( bucket = default_bucket_name , key = f" { self . hub_name } - { curr_timestamp } " )
112
114
except exceptions .ClientError :
113
115
hub_bucket_name = generate_default_hub_bucket_name (self ._sagemaker_session )
116
+ curr_timestamp = datetime .now ().timestamp ()
114
117
JUMPSTART_LOGGER .warning (
115
118
"There is not a Hub bucket associated with %s. Using %s" ,
116
119
self .hub_name ,
117
120
hub_bucket_name ,
118
121
)
119
- return hub_bucket_name
122
+ return S3ObjectLocation ( bucket = hub_bucket_name , key = f" { self . hub_name } - { curr_timestamp } " )
120
123
121
124
def _generate_hub_storage_location (self , bucket_name : Optional [str ] = None ) -> None :
122
125
"""Generates an ``S3ObjectLocation`` given a Hub name."""
123
- hub_bucket_name = bucket_name or self ._fetch_hub_bucket_name ()
124
126
curr_timestamp = datetime .now ().timestamp ()
125
- return S3ObjectLocation (bucket = hub_bucket_name , key = f"{ self .hub_name } -{ curr_timestamp } " )
127
+ return S3ObjectLocation (bucket = bucket_name , key = f"{ self .hub_name } -{ curr_timestamp } " ) if bucket_name else self . _fetch_hub_storage_location ( )
126
128
127
129
def create (
128
130
self ,
0 commit comments