Skip to content

Commit 1755377

Browse files
committed
Fix List Associations integ tests
1 parent c6effe5 commit 1755377

File tree

3 files changed

+35
-8
lines changed

3 files changed

+35
-8
lines changed

tests/integ/sagemaker/lineage/test_association.py

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,14 @@
1515

1616
import datetime
1717

18-
import pytest
1918
from sagemaker.lineage import association
2019

2120

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

2725

28-
@pytest.mark.skip(reason="Not in CMH yet")
2926
def test_list(association_objs, sagemaker_session):
3027
slack = datetime.timedelta(minutes=1)
3128
now = datetime.datetime.now(datetime.timezone.utc)
@@ -35,27 +32,51 @@ def test_list(association_objs, sagemaker_session):
3532

3633
for sort_order in ["Ascending", "Descending"]:
3734
association_keys_listed = []
35+
source_arn = [assoc_obj.source_arn for assoc_obj in association_objs][0]
3836
listed = association.Association.list(
37+
source_arn=source_arn,
3938
created_after=now - slack,
4039
created_before=now + slack,
4140
sort_by="CreationTime",
4241
sort_order=sort_order,
4342
sagemaker_session=sagemaker_session,
4443
)
44+
4545
for assoc in listed:
4646
key = assoc.source_arn + ":" + assoc.destination_arn
4747
if key in association_keys:
4848
association_keys_listed.append(key)
4949

5050
if sort_order == "Descending":
5151
association_names_listed = association_keys_listed[::-1]
52-
assert association_keys == association_names_listed
52+
assert association_keys[::-1] == association_names_listed
5353
# sanity check
5454
assert association_keys_listed
5555

5656

57-
@pytest.mark.skip(reason="Not in CMH yet")
5857
def test_set_tag(association_obj, sagemaker_session):
5958
tag = {"Key": "foo", "Value": "bar"}
6059
association_obj.set_tag(tag)
61-
assert association_obj.get_tag() == tag
60+
61+
while True:
62+
actual_tags = sagemaker_session.sagemaker_client.list_tags(
63+
ResourceArn=association_obj.source_arn
64+
)["Tags"]
65+
if actual_tags:
66+
break
67+
assert len(actual_tags) == 1
68+
assert actual_tags[0] == tag
69+
70+
71+
def test_tags(association_obj, sagemaker_session):
72+
tags = [{"Key": "foo1", "Value": "bar1"}]
73+
association_obj.set_tags(tags)
74+
75+
while True:
76+
actual_tags = sagemaker_session.sagemaker_client.list_tags(
77+
ResourceArn=association_obj.source_arn
78+
)["Tags"]
79+
if actual_tags:
80+
break
81+
assert len(actual_tags) == 1
82+
assert actual_tags == tags

tests/integ/sagemaker/lineage/test_dataset_artifact.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@
1515

1616

1717
def test_trained_models(
18-
sagemaker_session, dataset_artifact_associated_models, trial_component_obj, model_artifact_obj1
18+
sagemaker_session,
19+
dataset_artifact_associated_models,
20+
trial_component_obj,
21+
model_artifact_obj1,
1922
):
2023

2124
model_list = dataset_artifact_associated_models.trained_models()

tests/integ/sagemaker/lineage/test_endpoint_context.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@
1515

1616

1717
def test_model(
18-
endpoint_context_associate_with_model, model_obj, endpoint_action_obj, sagemaker_session
18+
endpoint_context_associate_with_model,
19+
model_obj,
20+
endpoint_action_obj,
21+
sagemaker_session,
1922
):
2023
model_list = endpoint_context_associate_with_model.models()
2124
for model in model_list:

0 commit comments

Comments
 (0)