sagemaker.core.jumpstart.cache#

This module defines the JumpStartModelsCache class.

Classes

JumpStartModelsCache(region, ...)

Class that implements a cache for JumpStart models manifests and specs.

class sagemaker.core.jumpstart.cache.JumpStartModelsCache(region: str | None = None, max_s3_cache_items: int = 20, s3_cache_expiration_horizon: ~datetime.timedelta = datetime.timedelta(seconds=21600), max_semantic_version_cache_items: int = 20, semantic_version_cache_expiration_horizon: ~datetime.timedelta = datetime.timedelta(seconds=21600), manifest_file_s3_key: str = 'models_manifest.json', proprietary_manifest_s3_key: str = 'proprietary-sdk-manifest.json', s3_bucket_name: str | None = None, s3_client_config: ~botocore.config.Config | None = None, s3_client: ~boto3.client | None = None, sagemaker_session: ~sagemaker.core.helper.session_helper.Session | None = <sagemaker.core.helper.session_helper.Session object>)[source]#

Bases: object

Class that implements a cache for JumpStart models manifests and specs.

The manifest and specs associated with JumpStart models provide the information necessary for launching JumpStart models from the SageMaker SDK.

clear() None[source]#

Clears the model ID/version and s3 cache.

get_bucket() str[source]#

Return bucket used for cache.

get_header(model_id: str, semantic_version_str: str, model_type: JumpStartModelType = JumpStartModelType.OPEN_WEIGHTS) JumpStartModelHeader[source]#

Return header for a given JumpStart model ID and semantic version.

Parameters:
  • model_id (str) – model ID for which to get a header.

  • semantic_version_str (str) – The semantic version for which to get a header.

get_hub_model(hub_model_arn: str) JumpStartModelSpecs[source]#

Return JumpStart-compatible specs for a given Hub model

Parameters:

hub_model_arn (str) – Arn for the Hub model to get specs for

get_hub_model_reference(hub_model_reference_arn: str) JumpStartModelSpecs[source]#

Return JumpStart-compatible specs for a given Hub model reference

Parameters:

hub_model_arn (str) – Arn for the Hub model to get specs for

get_manifest(model_type: JumpStartModelType = JumpStartModelType.OPEN_WEIGHTS) List[JumpStartModelHeader][source]#

Return entire JumpStart models manifest.

get_manifest_file_s3_key(file_type: JumpStartS3FileType = JumpStartS3FileType.OPEN_WEIGHT_MANIFEST) str[source]#

Return manifest file s3 key for cache.

get_region() str[source]#

Return region for cache.

get_specs(model_id: str, version_str: str, model_type: JumpStartModelType = JumpStartModelType.OPEN_WEIGHTS) JumpStartModelSpecs[source]#

Return specs for a given JumpStart model ID and semantic version.

Parameters:
  • model_id (str) – model ID for which to get specs.

  • semantic_version_str (str) – The semantic version for which to get specs.

  • model_type (JumpStartModelType) – The type of the model of interest.

set_manifest_file_s3_key(key: str, file_type: JumpStartS3FileType = JumpStartS3FileType.OPEN_WEIGHT_MANIFEST) None[source]#

Set manifest file s3 key, clear cache after new key is set.

Raises:

ValueError – if the file type is not recognized

set_region(region: str) None[source]#

Set region for cache. Clears cache after new region is set.

set_s3_bucket_name(s3_bucket_name: str) None[source]#

Set s3 bucket used for cache.