sagemaker.core.utils.utils#
Functions
|
Add customizable indent spaces to a given text. |
|
|
|
Configure the logging configuration based on log level. |
|
Convert a string to snake_case. |
Reconfigure the global textual rich console with the customized theme |
|
|
Get a logger with textual rich handler. |
Get a textual rich theme with customized styling. |
|
|
|
|
|
|
|
|
|
|
Converts a PascalCase string to snake_case. |
|
|
|
|
|
Serialize an object recursively by converting all objects to JSON-serializable types |
|
Convert a snake_case string to PascalCase. |
Classes
|
ResourceIterator class to iterate over a list of resources. |
|
A singleton class for creating a SageMaker client. |
Singleton metaclass. |
|
A custom type used to signify an undefined optional argument. |
- class sagemaker.core.utils.utils.ResourceIterator(client: SageMakerClient, summaries_key: str, summary_name: str, resource_cls: Type[T], list_method: str, list_method_kwargs: dict = {}, custom_key_mapping: dict | None = None)[source]#
Bases:
Generic[T]ResourceIterator class to iterate over a list of resources.
- class sagemaker.core.utils.utils.SageMakerClient(*args, **kwargs)[source]#
Bases:
objectA singleton class for creating a SageMaker client.
- class sagemaker.core.utils.utils.SingletonMeta[source]#
Bases:
typeSingleton metaclass. Ensures that a single instance of a class using this metaclass is created.
- class sagemaker.core.utils.utils.Unassigned[source]#
Bases:
objectA custom type used to signify an undefined optional argument.
- sagemaker.core.utils.utils.add_indent(text, num_spaces=4)[source]#
Add customizable indent spaces to a given text. :param text: The text to which the indent spaces will be added. :type text: str :param num_spaces: Number of spaces to be added for each level of indentation. Default is 4. :type num_spaces: int
- Returns:
The text with added indent spaces.
- Return type:
str
- sagemaker.core.utils.utils.configure_logging(log_level=None)[source]#
Configure the logging configuration based on log level.
- Usage:
Set Environment Variable LOG_LEVEL to DEBUG to see debug logs configure_logging() configure_logging(“DEBUG”)
- Parameters:
log_level (str) – The log level to set. Accepted values are: “DEBUG”, “INFO”, “WARNING”, “ERROR”, “CRITICAL”. Defaults to the value of the LOG_LEVEL environment variable. If argument/environment variable is not set, defaults to “INFO”.
- Raises:
AttributeError – If the log level is invalid.
- sagemaker.core.utils.utils.convert_to_snake_case(entity_name)[source]#
Convert a string to snake_case. :param entity_name: The string to convert. :type entity_name: str
- Returns:
The converted string in snake_case.
- Return type:
str
- sagemaker.core.utils.utils.enable_textual_rich_console_and_traceback()[source]#
- Reconfigure the global textual rich console with the customized theme
and enable textual rich error traceback
- sagemaker.core.utils.utils.get_textual_rich_logger(name: str, log_level: str = 'INFO') Logger[source]#
Get a logger with textual rich handler.
- Parameters:
name (str) – The name of the logger
log_level (str) – The log level to set. Accepted values are: “DEBUG”, “INFO”, “WARNING”, “ERROR”, “CRITICAL”. Defaults to the value of “INFO”.
- Returns:
A textial rich logger.
- Return type:
logging.Logger
- sagemaker.core.utils.utils.get_textual_rich_theme() Theme[source]#
Get a textual rich theme with customized styling.
- Returns:
A textual rich theme
- Return type:
Theme
- sagemaker.core.utils.utils.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