Skip to content

Conversation

@benieric
Copy link
Contributor

@benieric benieric commented Sep 17, 2024

Issue #, if available:

Description of changes:

  • Add log stream handlers that will be used for streaming cloudwatch log events during wait

    • MultiLogStreamHandler - used for handling cases where we need to stream events from multiple streams in the same log group
    • LogStreamHandler - single log stream handler
  • Only adding support for a subset of job type: set(["TrainingJob", "ProcessingJob", "TransformJob"])

    • this is only that sagemaker v2 supports today, but is extensible for future job types
  • Both MultiLogStreamHandler and LogStreamHandler utilize a get_latest_log_event() method which returns a generator that yields:

str: stream_name,
dict: event dict in format
    { 
        "ingestionTime": number,
        "message": "string",
        "timestamp": number
    }

Testing

  • Unit tests
  • Testing in notebook
    image

@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@benieric benieric changed the title Add Log Stream Handlers Feature: Add wait with logs to subset of Job types Sep 26, 2024

class CloudWatchLogsClient(metaclass=SingletonMeta):
"""
A singleton class for creating a SageMaker client.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit : Not a sagemaker client

Comment on lines 18 to 22
self.client = session.client(
"logs",
session.region_name,
config=Config(retries={"max_attempts": 10, "mode": "standard"}),
)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it is really needed only once , we can create it during the first call and have a check

if not self.client: 
      session = Session()
      self.client = session.client(
          "logs",
          session.region_name,
          config=Config(retries={"max_attempts": 10, "mode": "standard"}),
      )

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, let me add this, good catch

nargokul
nargokul previously approved these changes Sep 26, 2024
nargokul
nargokul previously approved these changes Sep 26, 2024
@benieric benieric merged commit 0dd72ae into aws:main Sep 27, 2024
@benieric benieric deleted the wait-logs branch September 27, 2024 22:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants