-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_sagemaker_setup.py
More file actions
34 lines (27 loc) · 1009 Bytes
/
Copy pathtest_sagemaker_setup.py
File metadata and controls
34 lines (27 loc) · 1009 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/env python
import sagemaker
import boto3
print('Testing SageMaker setup...')
try:
# Test SageMaker session
session = sagemaker.Session()
print(f'Region: {session.boto_region_name}')
# Test execution role
try:
role = sagemaker.get_execution_role()
print(f'Execution role: {role}')
except Exception as e:
print(f'Execution role error: {e}')
# Try to get caller identity
try:
sts = boto3.client('sts')
identity = sts.get_caller_identity()
print(f'AWS Identity: {identity}')
# Suggest a role ARN format
account_id = identity['Account']
suggested_role = f"arn:aws:iam::{account_id}:role/SageMakerExecutionRole"
print(f'Suggested role ARN: {suggested_role}')
except Exception as sts_error:
print(f'STS error: {sts_error}')
except Exception as e:
print(f'SageMaker session error: {e}')