Skip to content

Commit a8a4d2a

Browse files
authored
Merge branch 'master' into change/dw_image_uri
2 parents 244ec93 + 1a5d9c9 commit a8a4d2a

File tree

4 files changed

+67
-5
lines changed

4 files changed

+67
-5
lines changed

src/sagemaker/image_uri_config/xgboost.json

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,35 @@
154154
"us-west-2": "246618743249"
155155
},
156156
"repository": "sagemaker-xgboost"
157+
},
158+
"1.2-2": {
159+
"registries": {
160+
"af-south-1": "510948584623",
161+
"ap-east-1": "651117190479",
162+
"ap-northeast-1": "354813040037",
163+
"ap-northeast-2": "366743142698",
164+
"ap-south-1": "720646828776",
165+
"ap-southeast-1": "121021644041",
166+
"ap-southeast-2": "783357654285",
167+
"ca-central-1": "341280168497",
168+
"cn-north-1": "450853457545",
169+
"cn-northwest-1": "451049120500",
170+
"eu-central-1": "492215442770",
171+
"eu-north-1": "662702820516",
172+
"eu-west-1": "141502667606",
173+
"eu-west-2": "764974769150",
174+
"eu-west-3": "659782779980",
175+
"eu-south-1": "978288397137",
176+
"me-south-1": "801668240914",
177+
"sa-east-1": "737474898029",
178+
"us-east-1": "683313688378",
179+
"us-east-2": "257758044811",
180+
"us-gov-west-1": "414596584902",
181+
"us-iso-east-1": "833128469047",
182+
"us-west-1": "746614075791",
183+
"us-west-2": "246618743249"
184+
},
185+
"repository": "sagemaker-xgboost"
157186
}
158187
}
159188
}

src/sagemaker/session.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3490,12 +3490,20 @@ def get_caller_identity_arn(self):
34903490
"""
34913491
if os.path.exists(NOTEBOOK_METADATA_FILE):
34923492
with open(NOTEBOOK_METADATA_FILE, "rb") as f:
3493-
instance_name = json.loads(f.read())["ResourceName"]
3493+
metadata = json.loads(f.read())
3494+
instance_name = metadata["ResourceName"]
3495+
domain_id = metadata.get("DomainId")
3496+
user_profile_name = metadata.get("UserProfileName")
34943497
try:
3495-
instance_desc = self.sagemaker_client.describe_notebook_instance(
3496-
NotebookInstanceName=instance_name
3498+
if domain_id is None:
3499+
instance_desc = self.sagemaker_client.describe_notebook_instance(
3500+
NotebookInstanceName=instance_name
3501+
)
3502+
return instance_desc["RoleArn"]
3503+
user_profile_desc = self.sagemaker_client.describe_user_profile(
3504+
DomainId=domain_id, UserProfileName=user_profile_name
34973505
)
3498-
return instance_desc["RoleArn"]
3506+
return user_profile_desc["UserSettings"]["ExecutionRole"]
34993507
except ClientError:
35003508
LOGGER.debug(
35013509
"Couldn't call 'describe_notebook_instance' to get the Role "

tests/unit/sagemaker/image_uris/test_xgboost.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
}
4646
ALGO_VERSIONS = ("1", "latest")
4747
XGBOOST_FRAMEWORK_CPU_ONLY_VERSIONS = ("0.90-2", "0.90-1", "1.0-1")
48-
XGBOOST_FRAMEWORK_CPU_GPU_VERSIONS = ("1.2-1",)
48+
XGBOOST_FRAMEWORK_CPU_GPU_VERSIONS = ("1.2-1", "1.2-2")
4949

5050
FRAMEWORK_REGISTRIES = {
5151
"af-south-1": "510948584623",

tests/unit/test_session.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,31 @@ def test_get_caller_identity_arn_from_describe_notebook_instance(boto_session):
315315
)
316316

317317

318+
@patch(
319+
"six.moves.builtins.open",
320+
mock_open(
321+
read_data='{"ResourceName": "SageMakerInstance", '
322+
'"DomainId": "d-kbnw5yk6tg8j", '
323+
'"UserProfileName": "default-1617915559064"}'
324+
),
325+
)
326+
@patch("os.path.exists", side_effect=mock_exists(NOTEBOOK_METADATA_FILE, True))
327+
def test_get_caller_identity_arn_from_describe_user_profile(boto_session):
328+
sess = Session(boto_session)
329+
expected_role = "arn:aws:iam::369233609183:role/service-role/SageMakerRole-20171129T072388"
330+
sess.sagemaker_client.describe_user_profile.return_value = {
331+
"UserSettings": {"ExecutionRole": expected_role}
332+
}
333+
334+
actual = sess.get_caller_identity_arn()
335+
336+
assert actual == expected_role
337+
sess.sagemaker_client.describe_user_profile.assert_called_once_with(
338+
DomainId="d-kbnw5yk6tg8j",
339+
UserProfileName="default-1617915559064",
340+
)
341+
342+
318343
@patch("six.moves.builtins.open", mock_open(read_data='{"ResourceName": "SageMakerInstance"}'))
319344
@patch("os.path.exists", side_effect=mock_exists(NOTEBOOK_METADATA_FILE, True))
320345
@patch("sagemaker.session.sts_regional_endpoint", return_value=STS_ENDPOINT)

0 commit comments

Comments
 (0)