sagemaker.core.debugger.utils#

Utils file that contains util functions for the profiler.

Functions

convert_json_config_to_string(config)

Helper function to convert the dictionary config to a string.

is_valid_regex(regex)

Helper function to determine whether the provided regex is valid.

is_valid_unix_time(unix_time)

Helper function to determine whether the provided UNIX time is valid.

Classes

ErrorMessages(value)

Enum to store all possible messages during failures in validation of user arguments.

PythonProfiler(value)

Enum to list the Python profiler options for Python profiling.

cProfileTimer(value)

Enum to list the possible cProfile timers for Python profiling.

class sagemaker.core.debugger.utils.ErrorMessages(value)[source]#

Bases: Enum

Enum to store all possible messages during failures in validation of user arguments.

FOUND_BOTH_STEP_AND_TIME_FIELDS = 'Both step and time fields cannot be specified in the metrics config!'#
INVALID_CPROFILE_TIMER = 'cprofile_timer must be of type cProfileTimer'#
INVALID_DURATION = 'duration must be float greater than 0!'#
INVALID_FILE_CLOSE_INTERVAL = 'file_close_interval must be a float/integer greater than 0!'#
INVALID_FILE_MAX_SIZE = 'file_max_size must be an integer greater than 0!'#
INVALID_FILE_OPEN_FAIL_THRESHOLD = 'file_open_fail threshold must be an integer greater than 0!'#
INVALID_LOCAL_PATH = 'local_path must be a string!'#
INVALID_METRICS_REGEX = 'metrics_regex is invalid!'#
INVALID_NUM_STEPS = 'num_steps must be integer greater than 0!'#
INVALID_PROFILE_DEFAULT_STEPS = 'profile_default_steps must be a boolean!'#
INVALID_PYTHON_PROFILER = 'python_profiler must be of type PythonProfiler!'#
INVALID_START_STEP = 'start_step must be integer greater or equal to 0!'#
INVALID_START_UNIX_TIME = 'start_unix_time must be valid integer unix time!'#
class sagemaker.core.debugger.utils.PythonProfiler(value)[source]#

Bases: Enum

Enum to list the Python profiler options for Python profiling.

CPROFILE#

Use to choose "cProfile".

PYINSTRUMENT#

Use to choose "Pyinstrument".

CPROFILE = 'cprofile'#
PYINSTRUMENT = 'pyinstrument'#
class sagemaker.core.debugger.utils.cProfileTimer(value)[source]#

Bases: Enum

Enum to list the possible cProfile timers for Python profiling.

TOTAL_TIME#

Use to choose "total_time".

CPU_TIME#

Use to choose "cpu_time".

OFF_CPU_TIME#

Use to choose "off_cpu_time".

CPU_TIME = 'cpu_time'#
DEFAULT = 'default'#
OFF_CPU_TIME = 'off_cpu_time'#
TOTAL_TIME = 'total_time'#
sagemaker.core.debugger.utils.convert_json_config_to_string(config)[source]#

Helper function to convert the dictionary config to a string.

Calling eval on this string should result in the original dictionary.

Parameters:

config (dict) – The config to be converted to a string.

Returns:

The config dictionary formatted as a string.

Return type:

str

sagemaker.core.debugger.utils.is_valid_regex(regex)[source]#

Helper function to determine whether the provided regex is valid.

Parameters:

regex (str) – The user provided regex.

Returns:

Indicates whether the provided regex was valid or not.

Return type:

bool

sagemaker.core.debugger.utils.is_valid_unix_time(unix_time)[source]#

Helper function to determine whether the provided UNIX time is valid.

Parameters:

unix_time (int) – The user provided UNIX time.

Returns:

Indicates whether the provided UNIX time was valid or not.

Return type:

bool