Skip to content

Fix List Associations integ tests #2126

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 30 additions & 6 deletions tests/integ/sagemaker/lineage/test_association.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,16 @@
from __future__ import absolute_import

import datetime
import time

import pytest
from sagemaker.lineage import association


@pytest.mark.skip(reason="Not in CMH yet")
def test_create_delete(association_obj):
# fixture does create and then delete, this test ensures it happens at least once
assert association_obj.source_arn


@pytest.mark.skip(reason="Not in CMH yet")
def test_list(association_objs, sagemaker_session):
slack = datetime.timedelta(minutes=1)
now = datetime.datetime.now(datetime.timezone.utc)
Expand All @@ -35,27 +33,53 @@ def test_list(association_objs, sagemaker_session):

for sort_order in ["Ascending", "Descending"]:
association_keys_listed = []
source_arn = [assoc_obj.source_arn for assoc_obj in association_objs][0]
listed = association.Association.list(
source_arn=source_arn,
created_after=now - slack,
created_before=now + slack,
sort_by="CreationTime",
sort_order=sort_order,
sagemaker_session=sagemaker_session,
)

for assoc in listed:
key = assoc.source_arn + ":" + assoc.destination_arn
if key in association_keys:
association_keys_listed.append(key)

if sort_order == "Descending":
association_names_listed = association_keys_listed[::-1]
assert association_keys == association_names_listed
assert association_keys[::-1] == association_names_listed
# sanity check
assert association_keys_listed


@pytest.mark.skip(reason="Not in CMH yet")
def test_set_tag(association_obj, sagemaker_session):
tag = {"Key": "foo", "Value": "bar"}
association_obj.set_tag(tag)
assert association_obj.get_tag() == tag

while True:
actual_tags = sagemaker_session.sagemaker_client.list_tags(
ResourceArn=association_obj.source_arn
)["Tags"]
if actual_tags:
break
Comment on lines +63 to +67
Copy link
Member

Choose a reason for hiding this comment

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

lets put a sleep in here - don't want to spam list_tags from a test

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added, Thank you

time.sleep(1)
assert len(actual_tags) == 1
assert actual_tags[0] == tag


def test_tags(association_obj, sagemaker_session):
tags = [{"Key": "foo1", "Value": "bar1"}]
association_obj.set_tags(tags)

while True:
actual_tags = sagemaker_session.sagemaker_client.list_tags(
ResourceArn=association_obj.source_arn
)["Tags"]
if actual_tags:
break
Comment on lines +78 to +82
Copy link
Member

Choose a reason for hiding this comment

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

add sleep

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added Thank you

time.sleep(1)
assert len(actual_tags) == 1
assert actual_tags == tags
5 changes: 4 additions & 1 deletion tests/integ/sagemaker/lineage/test_dataset_artifact.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@


def test_trained_models(
sagemaker_session, dataset_artifact_associated_models, trial_component_obj, model_artifact_obj1
sagemaker_session,
dataset_artifact_associated_models,
trial_component_obj,
model_artifact_obj1,
):

model_list = dataset_artifact_associated_models.trained_models()
Expand Down
5 changes: 4 additions & 1 deletion tests/integ/sagemaker/lineage/test_endpoint_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@


def test_model(
endpoint_context_associate_with_model, model_obj, endpoint_action_obj, sagemaker_session
endpoint_context_associate_with_model,
model_obj,
endpoint_action_obj,
sagemaker_session,
):
model_list = endpoint_context_associate_with_model.models()
for model in model_list:
Expand Down