sagemaker.core.tools.shapes_extractor#

Extracts the shapes to DAG structure.

Classes

ShapesExtractor([combined_shapes])

Extracts the shapes to DAG structure.

class sagemaker.core.tools.shapes_extractor.ShapesExtractor(combined_shapes: dict | None = None)[source]#

Bases: object

Extracts the shapes to DAG structure.

fetch_shape_members_and_doc_strings(shape, required_override=())[source]#
generate_data_shape_members(shape, resource_plan, required_override=())[source]#
generate_data_shape_members_and_string_body(shape, resource_plan: Any | None = None, required_override=())[source]#
generate_data_shape_string_body(shape, resource_plan, required_override=())[source]#
generate_shape_members(shape, required_override=())[source]#
get_required_members(shape)[source]#
get_shapes_dag()[source]#

Parses the Service Json and generates the Shape DAG.

DAG is stored in a Dictionary data structure, and each key denotes a DAG Node. Nodes can be of composite types: structure, list, map. Basic types (Ex. str, int, etc) are omitted from compactness and can be inferred from composite type nodes.

The connections of Nodes are can be followed by using the shape.

Possible scenarios of nested associations:

  1. StructA → StructB → basic_type_member.

  2. StructA → list → basic_type_member

  3. StructA → list → StructB → basic_type_member

  4. StructA → map → basic_type_member

  5. StructA → map → StructBMapValue → basic_type_member

  6. StructA → map → map → basic_type_member

  7. StructA → map → list → basic_type_member

Example

“ContainerDefinition”: { # type: structure

“type”:”structure”, “members”:[

{“name”: “ModelName”, “shape”: “ModelName”, “type”: “string”}, {“name”: “ContainerDefinition”, “shape”: “ContainerDefinition”, “type”: “list”}, {“name”: “CustomerMetadata”, “shape”: “CustomerMetadataMap”, “type”: “map”},

],

}, “ContainerDefinitionList”: { # type: list

“type”:”list”, “member_shape”:”ContainerDefinition”, “member_type”:”ContainerDefinition”, # potential types: string, structure

}, “CustomerMetadataMap”: { # type: map

“type”:”map”, “key_shape”:”CustomerMetadataKey”, “key_type”:”string”, # allowed types: string “value_shape”:”CustomerMetadataValue”, “value_type”:”string”, # potential types: string, structure, list, map

},

Returns:

The generated Shape DAG.

Return type:

dict