sagemaker.core.jumpstart.payload_utils#
This module stores inference payload utilities for JumpStart models.
Classes
|
Utility class for serializing payloads associated with JumpStart models. |
- class sagemaker.core.jumpstart.payload_utils.PayloadSerializer(bucket: str | None = None, region: str | None = None, s3_client: client | None = None)[source]#
Bases:
objectUtility class for serializing payloads associated with JumpStart models.
Many JumpStart models embed byte-streams into payloads corresponding to images, sounds, and other content types which require downloading from S3.
- embed_s3_references_in_json_payload(payload_body: list | dict | str | int | float) list | dict | str | int | float[source]#
Finds all S3 references in payload and embeds serialized S3 data.
If no S3 references are found, the payload is returned un-modified.
- Raises:
ValueError – If the payload has an unrecognized type.
- embed_s3_references_in_str_payload(payload: str) str[source]#
Inserts serialized S3 content into string payload.
If no S3 content is embedded in payload, original string is returned.
- get_bytes_payload_with_s3_references(payload_str: str) bytes[source]#
Returns bytes object corresponding to referenced S3 object.
- Raises:
ValueError – If the raw bytes payload is not formatted correctly.
- serialize(payload: JumpStartSerializablePayload) str | bytes[source]#
Returns payload string or bytes that can be inputted to inference endpoint.
- Raises:
ValueError – If the payload has an unrecognized type.