Skip to content

Commit 058d855

Browse files
committed
adding low level hub api calls to sm session
1 parent 87d661a commit 058d855

File tree

1 file changed

+224
-0
lines changed

1 file changed

+224
-0
lines changed

src/sagemaker/session.py

+224
Original file line numberDiff line numberDiff line change
@@ -6463,6 +6463,230 @@ def wait_for_inference_recommendations_job(
64636463
_check_job_status(job_name, desc, "Status")
64646464
return desc
64656465

6466+
def create_hub(
6467+
self,
6468+
hub_name: str,
6469+
hub_description: str,
6470+
hub_display_name=None,
6471+
hub_search_keywords=None,
6472+
s3_storage_config=None,
6473+
tags=None
6474+
) -> Dict[str, str]:
6475+
"""Creates a SageMaker Hub
6476+
6477+
Args:
6478+
hub_name (str): The name of the Hub to create.
6479+
hub_description (str): A description of the Hub.
6480+
hub_display_name (str): The display name of the Hub.
6481+
hub_search_keywords (list): The searchable keywords for the Hub.
6482+
s3_storage_config (S3StorageConfig): The Amazon S3 storage configuration for the Hub.
6483+
tags (list): Any tags to associate with the Hub.
6484+
6485+
Returns:
6486+
(dict): Return value from the ``CreateHub`` API.
6487+
"""
6488+
return self.sagemaker_client.create_hub(
6489+
hub_name=hub_name,
6490+
hub_description=hub_description,
6491+
hub_display_name=hub_display_name,
6492+
hub_search_keywords=hub_search_keywords,
6493+
s3_storage_config=s3_storage_config,
6494+
tags=tags
6495+
)
6496+
6497+
def describe_hub(
6498+
self,
6499+
hub_name: str
6500+
) -> Dict[str, Any]:
6501+
"""Describes a SageMaker Hub
6502+
6503+
Args:
6504+
hub_name (str): The name of the hub to describe.
6505+
6506+
Returns:
6507+
(dict): Return value for ``DescribeHub`` API
6508+
"""
6509+
return self.sagemaker_client.describe_hub(
6510+
hub_name=hub_name
6511+
)
6512+
6513+
def list_hubs(
6514+
self,
6515+
creation_time_after=None,
6516+
creation_time_before=None,
6517+
max_results=None,
6518+
max_schema_version=None,
6519+
name_contains=None,
6520+
sort_by=None,
6521+
sort_order=None
6522+
) -> Dict[str, Any]:
6523+
"""Lists all existing SageMaker Hubs
6524+
6525+
Args:
6526+
creation_time_after (int): Only list HubContent that was created after the time specified.
6527+
creation_time_before (int): Only list HubContent that was created before the time specified.
6528+
max_results (int): The maximum amount of HubContent to list.
6529+
max_schema_version (str): The upper bound of the HubContentSchemaVersion.
6530+
name_contains (str): Only list HubContent if the name contains the specified string.
6531+
next_token (str): If the response to a previous ``ListHubContents`` request was truncated, the
6532+
response includes a ``NextToken``. To retrieve the next set of hub content, use the token in the next request.
6533+
sort_by (str): Sort HubContent versions by either name or creation time.
6534+
sort_order (str): Sort Hubs by ascending or descending order.
6535+
Returns:
6536+
(dict): Return value for ``ListHubs`` API
6537+
"""
6538+
return self.sagemaker_client.list_hubs(
6539+
creation_time_after=creation_time_after,
6540+
creation_time_before=creation_time_before,
6541+
max_results=max_results,
6542+
max_schema_version=max_schema_version,
6543+
name_contains=name_contains,
6544+
sort_by=sort_by,
6545+
sort_order=sort_order
6546+
)
6547+
6548+
def list_hub_contents(
6549+
self,
6550+
hub_name: str,
6551+
hub_content_type: str,
6552+
creation_time_after=None,
6553+
creation_time_before=None,
6554+
max_results=None,
6555+
max_schema_version=None,
6556+
name_contains=None,
6557+
sort_by=None,
6558+
sort_order=None
6559+
) -> Dict[str, Any]:
6560+
"""Lists the HubContents in a SageMaker Hub
6561+
6562+
Args:
6563+
hub_name (str): The name of the Hub to list the contents of.
6564+
hub_content_type (str): The type of the HubContent to list.
6565+
creation_time_after (int): Only list HubContent that was created after the time specified.
6566+
creation_time_before (int): Only list HubContent that was created before the time specified.
6567+
max_results (int): The maximum amount of HubContent to list.
6568+
max_schema_version (str): The upper bound of the HubContentSchemaVersion.
6569+
name_contains (str): Only list HubContent if the name contains the specified string.
6570+
next_token (str): If the response to a previous ``ListHubContents`` request was truncated, the
6571+
response includes a ``NextToken``. To retrieve the next set of hub content, use the token in the next request.
6572+
sort_by (str): Sort HubContent versions by either name or creation time.
6573+
sort_order (str): Sort Hubs by ascending or descending order.
6574+
Returns:
6575+
(dict): Return value for ``ListHubContents`` API
6576+
"""
6577+
return self.sagemaker_client.list_hub_contents(
6578+
hub_name=hub_name,
6579+
hub_content_type=hub_content_type,
6580+
creation_time_after=creation_time_after,
6581+
creation_time_before=creation_time_before,
6582+
max_results=max_results,
6583+
max_schema_version=max_schema_version,
6584+
name_contains=name_contains,
6585+
sort_by=sort_by,
6586+
sort_order=sort_order
6587+
)
6588+
6589+
def delete_hub(
6590+
self,
6591+
hub_name: str
6592+
) -> None:
6593+
"""Deletes a SageMaker Hub
6594+
6595+
Args:
6596+
hub_name (str): The name of the hub to delete.
6597+
"""
6598+
return self.sagemaker_client.delete_hub(hub_name=hub_name)
6599+
6600+
def import_hub_content(
6601+
self,
6602+
document_schema_version: str,
6603+
hub_content_name: str,
6604+
hub_content_type: str,
6605+
hub_name: str,
6606+
hub_content_display_name=None,
6607+
hub_content_description=None,
6608+
hub_content_version=None,
6609+
hub_content_markdown=None,
6610+
hub_content_search_keywords=None,
6611+
tags=None
6612+
) -> Dict[str, str]:
6613+
"""Imports a new HubContent into a SageMaker Hub
6614+
6615+
Args:
6616+
document_schema_version (str): The version of the HubContent schema to import.
6617+
hub_content_name (str): The name of the HubContent to import.
6618+
hub_content_version (str): The version of the HubContent to import.
6619+
hub_content_type (str): The type of HubContent to import.
6620+
hub_name (str): The name of the Hub to import content to.
6621+
hub_content_display_name (str): The display name of the HubContent to import.
6622+
hub_content_description (str): The description of the HubContent to import.
6623+
hub_content_markdown (str): A string that provides a description of the HubContent. This string can include links, tables,
6624+
and standard markdown formatting.
6625+
hub_content_search_keywords (list): The searchable keywords of the HubContent.
6626+
tags (list): Any tags associated with the HubContent.
6627+
Returns:
6628+
(dict): Return value for ``ImportHubContent`` API
6629+
"""
6630+
return self.sagemaker_client.import_hub_content(
6631+
document_schema_version=document_schema_version,
6632+
hub_content_name=hub_content_name,
6633+
hub_content_version=hub_content_version,
6634+
hub_content_type=hub_content_type,
6635+
hub_name=hub_name,
6636+
hub_content_display_name=hub_content_display_name,
6637+
hub_content_description=hub_content_description,
6638+
hub_content_markdown=hub_content_markdown,
6639+
hub_content_search_keywords=hub_content_search_keywords,
6640+
tags=tags
6641+
)
6642+
6643+
def describe_hub_content(
6644+
self,
6645+
hub_content_name: str,
6646+
hub_content_type: str,
6647+
hub_name: str,
6648+
hub_content_version=None
6649+
) -> Dict[str, Any]:
6650+
"""Describes a HubContent in a SageMaker Hub
6651+
6652+
Args:
6653+
hub_content_name (str): The name of the HubContent to describe.
6654+
hub_content_type (str): The type of HubContent in the Hub.
6655+
hub_name (str): The name of the Hub that contains the HubContent to describe.
6656+
hub_content_version (str): The version of the HubContent to describe
6657+
6658+
Returns:
6659+
(dict): Return value for ``DescribeHubContent`` API
6660+
"""
6661+
return self.sagemaker_client.describe_hub_content(
6662+
hub_content_name=hub_content_name,
6663+
hub_content_type=hub_content_type,
6664+
hub_name=hub_name,
6665+
hub_content_version=hub_content_version
6666+
)
6667+
6668+
def delete_hub_content(
6669+
self,
6670+
hub_content_name: str,
6671+
hub_content_version: str,
6672+
hub_content_type: str,
6673+
hub_name: str
6674+
) -> None:
6675+
"""Deletes a given HubContent in a SageMaker Hub
6676+
6677+
Args:
6678+
hub_content_name (str): The name of the content thatyou want to delete from a Hub.
6679+
hub_content_version (str): The version of the content that you want to delete from a Hub.
6680+
hub_content_type (str): The type of the content that you want to delete from a Hub.
6681+
hub_name (str): The name of the Hub that you want to delete content in.
6682+
"""
6683+
return self.sagemaker_client.delete_hub_content(
6684+
hub_content_name=hub_content_name,
6685+
hub_content_version=hub_content_version,
6686+
hub_content_type=hub_content_type,
6687+
hub_name=hub_name
6688+
)
6689+
64666690

64676691
def get_model_package_args(
64686692
content_types=None,

0 commit comments

Comments
 (0)