sagemaker.core.utils.code_injection.codec

sagemaker.core.utils.code_injection.codec#

Functions

deserialize(data, cls)

Deserialize the given data into an instance of the specified class.

pascal_to_snake(pascal_str)

Converts a PascalCase string to snake_case.

serialize(data)

Serializes the given data object into a dictionary.

snake_to_pascal(snake_str)

Convert a snake_case string to PascalCase.

transform(data, shape[, object_instance])

Transforms the given data based on the given shape.

sagemaker.core.utils.code_injection.codec.deserialize(data, cls) object[source]#

Deserialize the given data into an instance of the specified class.

Parameters:
  • data (dict) – The data to be deserialized.

  • cls (str or type) – The class or class name to deserialize into.

Returns:

An instance of the specified class with the deserialized data.

Return type:

object

sagemaker.core.utils.code_injection.codec.pascal_to_snake(pascal_str)[source]#

Converts a PascalCase string to snake_case.

Parameters:

pascal_str (str) – The PascalCase string to be converted.

Returns:

The converted snake_case string.

Return type:

str

sagemaker.core.utils.code_injection.codec.serialize(data) object[source]#

Serializes the given data object into a dictionary.

Parameters:

data – The data object to be serialized.

Returns:

A dictionary containing the serialized data.

sagemaker.core.utils.code_injection.codec.snake_to_pascal(snake_str)[source]#

Convert a snake_case string to PascalCase.

Parameters:

snake_str (str) – The snake_case string to be converted.

Returns:

The PascalCase string.

Return type:

str

sagemaker.core.utils.code_injection.codec.transform(data, shape, object_instance=None) dict[source]#

Transforms the given data based on the given shape.

Parameters:
  • data (dict) – The data to be transformed.

  • shape (str) – The shape of the data.

  • object_instance (object) – The object to be transformed. (Optional)

Returns:

The transformed data.

Return type:

dict

Raises:

ValueError – If an unhandled shape type is encountered.