in src/sagemaker/debugger/metrics_config.py [0:0]
def __init__(self, name, start_step, num_steps, start_unix_time, duration):
"""Validate the provided range fields and set the range to be profiled accordingly.
Args:
name (str): The name of the metrics config.
start_step (int): The step to start profiling.
num_steps (int): The number of steps to profile.
start_unix_time (int): The Unix time to start profiling.
duration (float): The duration in seconds to profile.
"""
self.name = name
assert (
start_step is None or isinstance(start_step, int) and start_step >= 0
), ErrorMessages.INVALID_START_STEP.value
assert (
num_steps is None or isinstance(num_steps, int) and num_steps > 0
), ErrorMessages.INVALID_NUM_STEPS.value
assert (
start_unix_time is None
or isinstance(start_unix_time, int)
and is_valid_unix_time(start_unix_time)
), ErrorMessages.INVALID_START_UNIX_TIME.value
assert (
duration is None or isinstance(duration, (float, int)) and duration > 0
), ErrorMessages.INVALID_DURATION.value
has_step_range = start_step is not None or num_steps is not None
has_time_range = start_unix_time is not None or duration is not None
assert not (
has_step_range and has_time_range
), ErrorMessages.FOUND_BOTH_STEP_AND_TIME_FIELDS.value
self.range = (
StepRange(start_step, num_steps)
if has_step_range
else TimeRange(start_unix_time, duration)
)