sagemaker.core.jumpstart.accessors#

This module contains accessors related to SageMaker JumpStart.

Classes

JumpStartModelsAccessor()

Static class for storing the JumpStart models cache.

JumpStartS3PayloadAccessor()

Static class for storing and retrieving S3 payload artifacts.

SageMakerSettings()

Static class for storing the SageMaker settings.

class sagemaker.core.jumpstart.accessors.JumpStartModelsAccessor[source]#

Bases: object

Static class for storing the JumpStart models cache.

static get_jumpstart_content_bucket() str | None[source]#

Returns JumpStart content bucket.

static get_jumpstart_gated_content_bucket() str | None[source]#

Returns JumpStart gated content bucket.

static get_manifest(*args, **kwargs)#
static get_model_header(region: str, model_id: str, version: str, model_type: JumpStartModelType = JumpStartModelType.OPEN_WEIGHTS) JumpStartModelHeader[source]#

Returns model header from JumpStart models cache.

Parameters:
  • region (str) – region for which to retrieve header.

  • model_id (str) – model ID to retrieve.

  • version (str) – semantic version to retrieve for the model ID.

static get_model_specs(region: str, model_id: str, version: str, hub_arn: str | None = None, s3_client: ~boto3.client | None = None, model_type=JumpStartModelType.OPEN_WEIGHTS, sagemaker_session: ~sagemaker.core.helper.session_helper.Session = <sagemaker.core.helper.session_helper.Session object>) JumpStartModelSpecs[source]#

Returns model specs from JumpStart models cache.

Parameters:
  • region (str) – region for which to retrieve header.

  • model_id (str) – model ID to retrieve.

  • version (str) – semantic version to retrieve for the model ID.

  • s3_client (boto3.client) – boto3 client to use for accessing JumpStart models s3 cache. If not set, a default client will be made.

static reset_cache(cache_kwargs: Dict[str, Any] | None = None, region: str | None = None) None[source]#

Resets cache, optionally allowing cache kwargs to be passed to the new cache.

Raises:

ValueError – If region in cache_kwargs is inconsistent with region argument.

Parameters:
  • cache_kwargs (str) – cache kwargs to validate.

  • region (str) – The region to validate along with the kwargs.

static set_cache_kwargs(cache_kwargs: Dict[str, Any], region: str | None = None) None[source]#

Sets cache kwargs, clears the cache.

Raises:

ValueError – If region in cache_kwargs is inconsistent with region argument.

Parameters:
  • cache_kwargs (str) – cache kwargs to validate.

  • region (str) – Optional. The region to validate along with the kwargs.

static set_jumpstart_content_bucket(content_bucket: str) None[source]#

Sets JumpStart content bucket.

static set_jumpstart_gated_content_bucket(gated_content_bucket: str) None[source]#

Sets JumpStart gated content bucket.

class sagemaker.core.jumpstart.accessors.JumpStartS3PayloadAccessor[source]#

Bases: object

Static class for storing and retrieving S3 payload artifacts.

CACHE_SIZE = 16#
MAX_CACHE_SIZE_BYTES = 100000000#
MAX_PAYLOAD_SIZE_BYTES = 6000000#
static clear_cache() None[source]#

Clears LRU caches associated with S3 client and retrieved objects.

static get_object(bucket: str, key: str, region: str = 'us-west-2', s3_client: client | None = None) bytes[source]#

Returns S3 object located at the bucket and key.

Raises:

ValueError – The object size is too large.

static get_object_cached(bucket: str, key: str, region: str = 'us-west-2', s3_client: client | None = None) bytes[source]#

Returns S3 object located at the bucket and key.

Requests are cached so that the same S3 request is never made more than once, unless a different region or client is used.

class sagemaker.core.jumpstart.accessors.SageMakerSettings[source]#

Bases: object

Static class for storing the SageMaker settings.

static get_sagemaker_version() str[source]#

Return SageMaker version.

static set_sagemaker_version(version: str) None[source]#

Set SageMaker version.