in src/sagemaker_core/tools/resources_codegen.py [0:0]
def _get_dict_with_default_configurable_attributes(self, class_attributes: dict) -> dict:
"""
Creates default attributes dict for a particular resource.
Iterates through all class attributes and filters by attributes that have particular substrings in their name
Args:
class_attributes: Dict that has all the attributes of a class
Returns:
Dict with attributes that can be configurable
"""
PYTHON_TYPES = ["str", "datetime.datetime", "bool", "int", "float"]
default_attributes = {}
for key, value in class_attributes.items():
if value in PYTHON_TYPES or value.startswith("List"):
for config_attribute_substring in CONFIGURABLE_ATTRIBUTE_SUBSTRINGS:
if config_attribute_substring in key:
if value.startswith("List"):
element = value.replace("List[", "")[:-1]
if element in PYTHON_TYPES:
default_attributes[key] = {
TYPE: "array",
"items": {
TYPE: self._get_json_schema_type_from_python_type(element)
},
}
else:
default_attributes[key] = {
TYPE: self._get_json_schema_type_from_python_type(value) or value
}
elif value.startswith("List") or value.startswith("Dict"):
log.debug("Script does not currently support list of objects as configurable")
continue
else:
class_attributes = self.shapes_extractor.generate_shape_members(value)
cleaned_class_attributes = self._cleanup_class_attributes_types(class_attributes)
if nested_default_attributes := self._get_dict_with_default_configurable_attributes(
cleaned_class_attributes
):
default_attributes[key] = nested_default_attributes
return default_attributes