sagemaker.train.utils

sagemaker.train.utils#

Utils module.

Functions

convert_unassigned_to_none(instance)

Convert Unassigned values to None for any instance.

safe_serialize(data)

Serialize the data without wrapping strings in quotes.

sagemaker.train.utils.convert_unassigned_to_none(instance) Any[source]#

Convert Unassigned values to None for any instance.

sagemaker.train.utils.safe_serialize(data)[source]#

Serialize the data without wrapping strings in quotes.

This function handles the following cases: 1. If data is a string, it returns the string as-is without wrapping in quotes. 2. If data is of type PipelineVariable, it returns the json representation of the PipelineVariable 3. If data is serializable (e.g., a dictionary, list, int, float), it returns

the JSON-encoded string using json.dumps().

  1. If data cannot be serialized (e.g., a custom object), it returns the string representation of the data using str(data).

Parameters:

data (Any) – The data to serialize.

Returns:

The serialized JSON-compatible string or the string representation of the input.

Return type:

str