Skip to content

Commit

Permalink
Add sagemaker example notebook
Browse files Browse the repository at this point in the history
  • Loading branch information
naddeoa committed Oct 12, 2023
1 parent 48c7c4f commit f21b2fc
Show file tree
Hide file tree
Showing 3 changed files with 544 additions and 0 deletions.
5 changes: 5 additions & 0 deletions python/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,8 @@
dist
output.ipynb
whylogs_data

# These are created during the sagemaker notebook example
examples/integrations/sagemaker_whylabs_example/model.tar.gz
examples/integrations/sagemaker_whylabs_example/resnet.pt
examples/integrations/sagemaker_whylabs_example/code

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,38 @@ def create_writers(self, dataset_id: str) -> List[Writer]:
assert_profile(cast(DatasetProfileView, writer1.last_writables[0]), ["a", "b", "c"])


def test_closing_works(actor: Tuple[DataLogger, FakeWriter]) -> None:
logger, writer = actor
ms = 1689881671000

logger.log(data={"a": 1}, sync=True, timestamp_ms=ms)
logger.log(data={"b": 2}, sync=True, timestamp_ms=add_days(ms, 1))
logger.log(data={"c": 3}, sync=True, timestamp_ms=add_days(ms, 2))
status = logger.status()
logger.close()

assert_status_single(
status,
LoggerStatus(dataset_profiles=3, dataset_timestamps=3, pending_writables=0, segment_caches=0, writers=1),
dataset_id,
)

assert writer.write_calls == 3
assert len(writer.last_writables) == 3

assert_profile(cast(DatasetProfileView, writer.last_writables[0]), ["a"])
assert_profile(cast(DatasetProfileView, writer.last_writables[1]), ["b"])
assert_profile(cast(DatasetProfileView, writer.last_writables[2]), ["c"])

# Further calls after close should throw
with pytest.raises(Exception, match="Actor is closed, can't send message."):
logger.log(data={"a": 1}, sync=True, timestamp_ms=ms)

# These shouldn't change
assert writer.write_calls == 3
assert len(writer.last_writables) == 3


def test_actor_multiple_days(actor: Tuple[DataLogger, FakeWriter]) -> None:
logger, writer = actor
ms = 1689881671000
Expand Down

0 comments on commit f21b2fc

Please sign in to comment.