@@ -219,43 +219,42 @@ def get_hub_model_version(
219
219
except Exception as ex :
220
220
raise Exception (f"Failed calling list_hub_content_versions: { str (ex )} " )
221
221
222
- < << << << HEAD
223
- < << << << HEAD
224
- == == == =
225
- marketplace_hub_content_version = _get_hub_model_version_for_marketplace_version (
226
- hub_content_summaries , hub_model_version
227
- )
228
222
229
- >> >> >> > ff3eae05 (feat : Adding Bedrock Store model support for HubService (#1539))
230
- == == == =
231
- >> >> >> > 42 acb4f4 (chore : Merge from main (#1600))
223
+ def get_hub_model_version (
224
+ hub_name : str ,
225
+ hub_model_name : str ,
226
+ hub_model_type : str ,
227
+ hub_model_version : Optional [str ] = None ,
228
+ sagemaker_session : Session = constants .DEFAULT_JUMPSTART_SAGEMAKER_SESSION ,
229
+ ) -> str :
230
+ """Returns available Jumpstart hub model version.
231
+
232
+ It will attempt both a semantic HubContent version search and Marketplace version search.
233
+ If the Marketplace version is also semantic, this function will default to HubContent version.
234
+
235
+ Raises:
236
+ ClientError: If the specified model is not found in the hub.
237
+ KeyError: If the specified model version is not found.
238
+ """
239
+
240
+ try :
241
+ hub_content_summaries = sagemaker_session .list_hub_content_versions (
242
+ hub_name = hub_name , hub_content_name = hub_model_name , hub_content_type = hub_model_type
243
+ ).get ("HubContentSummaries" )
244
+ except Exception as ex :
245
+ raise Exception (f"Failed calling list_hub_content_versions: { str (ex )} " )
246
+
232
247
try :
233
248
return _get_hub_model_version_for_open_weight_version (
234
249
hub_content_summaries , hub_model_version
235
250
)
236
- << < << << HEAD
237
- << < << << HEAD
238
- == == == =
239
- >> > >> > > 42 acb4f4 (chore : Merge from main (#1600))
240
251
except KeyError :
241
252
marketplace_hub_content_version = _get_hub_model_version_for_marketplace_version (
242
253
hub_content_summaries , hub_model_version
243
254
)
244
- << < << << HEAD
245
- if marketplace_hub_content_version :
246
- return marketplace_hub_content_version
247
- raise
248
- == == == =
249
- except KeyError as e :
250
- if marketplace_hub_content_version :
251
- return marketplace_hub_content_version
252
- raise e
253
- >> >> > >> ff3eae05 (feat : Adding Bedrock Store model support for HubService (#1539))
254
- == == == =
255
255
if marketplace_hub_content_version :
256
256
return marketplace_hub_content_version
257
257
raise
258
- >> > >> >> 42 acb4f4 (chore : Merge from main (#1600))
259
258
260
259
261
260
def _get_hub_model_version_for_open_weight_version (
0 commit comments