Skip to content

Commit 0a146f6

Browse files
henrywang0192henrywa2
authored and
root
committed
fix: Remove space specific business logic from Python SDK function to fetch execution role (aws#4552)
Co-authored-by: Henry Wang <[email protected]>
1 parent 45b3e65 commit 0a146f6

File tree

2 files changed

+0
-28
lines changed

2 files changed

+0
-28
lines changed

src/sagemaker/session.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5668,7 +5668,6 @@ def get_caller_identity_arn(self):
56685668
instance_name = metadata.get("ResourceName")
56695669
domain_id = metadata.get("DomainId")
56705670
user_profile_name = metadata.get("UserProfileName")
5671-
space_name = metadata.get("SpaceName")
56725671
execution_role_arn = metadata.get("ExecutionRoleArn")
56735672
try:
56745673
if domain_id is None:
@@ -5681,11 +5680,6 @@ def get_caller_identity_arn(self):
56815680
if execution_role_arn is not None:
56825681
return execution_role_arn
56835682

5684-
# In Shared Space app, find execution role from DefaultSpaceSettings on domain level
5685-
if space_name is not None:
5686-
domain_desc = self.sagemaker_client.describe_domain(DomainId=domain_id)
5687-
return domain_desc["DefaultSpaceSettings"]["ExecutionRole"]
5688-
56895683
user_profile_desc = self.sagemaker_client.describe_user_profile(
56905684
DomainId=domain_id, UserProfileName=user_profile_name
56915685
)

tests/unit/test_session.py

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -723,28 +723,6 @@ def test_get_caller_identity_arn_from_metadata_file_for_space(boto_session):
723723
assert actual == expected_role
724724

725725

726-
@patch(
727-
"six.moves.builtins.open",
728-
mock_open(
729-
read_data='{"ResourceName": "SageMakerInstance", '
730-
'"DomainId": "d-kbnw5yk6tg8j", '
731-
'"SpaceName": "space_name"}'
732-
),
733-
)
734-
@patch("os.path.exists", side_effect=mock_exists(NOTEBOOK_METADATA_FILE, True))
735-
def test_get_caller_identity_arn_from_describe_domain_for_space(boto_session):
736-
sess = Session(boto_session)
737-
expected_role = "arn:aws:iam::369233609183:role/service-role/SageMakerRole-20171129T072388"
738-
sess.sagemaker_client.describe_domain.return_value = {
739-
"DefaultSpaceSettings": {"ExecutionRole": expected_role}
740-
}
741-
742-
actual = sess.get_caller_identity_arn()
743-
744-
assert actual == expected_role
745-
sess.sagemaker_client.describe_domain.assert_called_once_with(DomainId="d-kbnw5yk6tg8j")
746-
747-
748726
@patch(
749727
"six.moves.builtins.open",
750728
mock_open(read_data='{"ResourceName": "SageMakerInstance"}'),

0 commit comments

Comments
 (0)