sagemaker.core.logs#

Placeholder docstring

Functions

argmin(arr, f)

Return the index, i, in arr that minimizes f(arr[i])

log_stream(client, log_group, stream_name[, ...])

A generator for log items in a single stream.

multi_stream_iter(client, log_group, streams)

Iterate over the available events coming from a set of log streams.

some(arr)

Return True iff there is an element, a, of arr such that a is not None.

Classes

ColorWrap([force])

A callable that will print text in a different color depending on the instance.

Position(timestamp, skip)

class sagemaker.core.logs.ColorWrap(force=False)[source]#

Bases: object

A callable that will print text in a different color depending on the instance.

Up to 6 if standard output is a terminal or a Jupyter notebook cell.

class sagemaker.core.logs.Position(timestamp, skip)#

Bases: tuple

skip#

Alias for field number 1

timestamp#

Alias for field number 0

sagemaker.core.logs.argmin(arr, f)[source]#

Return the index, i, in arr that minimizes f(arr[i])

Parameters:
  • arr

  • f

sagemaker.core.logs.log_stream(client, log_group, stream_name, start_time=0, skip=0)[source]#

A generator for log items in a single stream.

This will yield all the items that are available at the current moment.

Parameters:
  • client (boto3.CloudWatchLogs.Client) – The Boto client for CloudWatch logs.

  • log_group (str) – The name of the log group.

  • stream_name (str) – The name of the specific stream.

  • start_time (int) – The time stamp value to start reading the logs from (default: 0).

  • skip (int) – The number of log entries to skip at the start (default: 0). This is for

  • timestamp. (when there are multiple entries at the same)

Yields:

dict

A CloudWatch log event with the following key-value pairs:

‘timestamp’ (int): The time of the event. ‘message’ (str): The log event data. ‘ingestionTime’ (int): The time the event was ingested.

sagemaker.core.logs.multi_stream_iter(client, log_group, streams, positions=None)[source]#

Iterate over the available events coming from a set of log streams.

Log streams are in a single log group interleaving the events from each stream so they’re yielded in timestamp order.

Parameters:
  • client (boto3 client) – The boto client for logs.

  • log_group (str) – The name of the log group.

  • streams (list of str) – A list of the log stream names. The position of the stream in

  • number. (this list is the stream)

  • positions – (list of Positions): A list of pairs of (timestamp, skip) which represents

  • stream. (the last record read from each)

Yields:

A tuple of (stream number, cloudwatch log event).

sagemaker.core.logs.some(arr)[source]#

Return True iff there is an element, a, of arr such that a is not None.

Parameters:

arr