SageMakerClient CustomSession uses default values instead of passed user session
Maintainer thường phản hồi trong vòng 2 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 68/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Ít trao đổi
- Công nghệ
- aws, python
- Lĩnh vực
- cloud, machine-learning
Hướng nghiên cứu
Bắt đầu trong sagemaker-core/src/sagemaker/core/utils/utils.py, xung quanh SageMakerClient.init (xấp xỉ các dòng 395–406), sau đó so sánh cách các client sagemaker-runtime, featurestore và metrics sử dụng session được cung cấp. Chạy bản tái hiện nhiều profile được cung cấp và xác minh rằng CreateTrainingJob sử dụng account và region được chỉ định thay vì profile mặc định.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
PySDK Version
- PySDK V2 (2.x)
- PySDK V3 (3.x)
Describe the bug
SageMakerClient builds the sagemaker client from botocore.session.get_session(), ignoring the provided user session resulting in cross-account CreateTrainingJob failures.
In sagemaker-core 2.16.0, SageMakerClient.init (sagemaker/core/utils/utils.py, ~L395–406) creates self.sagemaker_client from a fresh default botocore session (botocore.session.get_session() → custom_session) rather than the session argument, under a # TODO: Remove post-launch custom service-model loader. The sagemaker-runtime/featurestore/metrics clients correctly use session. Because the class is a SingletonMeta singleton, the first (default-credential) client is reused process-wide ignoring passed in user sessions.
Impact: callers that pass an explicit boto3 session (e.g. ModelTrainer(sagemaker_session=…) → TrainingJob.create(session=…)) have the control-plane call issued under the ambient default AWS profile instead. When the execution role is in a different account than the default profile, CreateTrainingJob fails with ValidationException: RoleArn: Cross-account pass role is not allowed.
To reproduce
If a user has multiple AWS profiles (all for different accounts) set up in ~/.aws/config and the default in ~/.aws/credentials is NOT the same account as the intended profile that is used to create the SageMaker Session then CreateTrainingJob will fail with ValidationException: RoleArn: Cross-account pass role is not allowed.
from sagemaker.core.helper.session_helper import Session
from sagemaker.train import ModelTrainer
from sagemaker.train.configs import SourceCode, Compute, InputData
import boto3
sess = Session(boto_session=boto3.Session(profile_name="acct-A", region_name="us-east-2"))
ModelTrainer(
sagemaker_session=sess, # account A
role="arn:aws:iam::<ACCOUNT_A>:role/<your-exec-role>", # account A
training_image="<ACCOUNT_A>.dkr.ecr.us-east-2.amazonaws.com/img:latest",
compute=Compute(instance_type="ml.m5.xlarge", instance_count=1),
source_code=SourceCode(source_dir="src", entry_script="train.py"),
).train(input_data_config=[InputData(channel_name="train", data_source="s3://bucket/train/")])
# -> ValidationException: RoleArn: Cross-account pass role is not allowed
# (only when your *default* AWS profile is a different account than A)
Expected behavior
A training job to be created and executed in the specified account. This is a migration from v2 to v3 and the v2 implementation of this works without issue creating training jobs in the targeted accounts based on the profile passed to the Session.
Screenshots or logs
If applicable, add screenshots or logs to help explain your problem.
System information
A description of your system. Please provide:
- SageMaker Python SDK version: 3.15.1
- Framework name (eg. PyTorch) or algorithm (eg. KMeans): SKLearn
- Framework version: 1.4-2
- Python version: py3
- CPU or GPU: CPU
- Custom Docker image (Y/N): N
Additional context
This issue also seems to persist to the latest version of 3.16 since the same custom_session is also used to initiate the sagemaker_client.
- Ngôn ngữ chính
- Python
- Star
- 2.3k
- Fork
- 1.3k
- Merge trung bình
- 3 ngày 10 giờ
- Pull request đã merge (30 ngày)
- 88
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của aws/sagemaker-python-sdk
-
Cannot use spark_event_logs_s3_uri in PySparkProcessor jobCó thể đã có người làm @rsareddy0329 đã nhận 8 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
aws/sagemaker-python-sdk#6253 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
[Bug] V3 Hyperparameter Tuning Pipeline page labelled "Download Data" in navigation due to missing title cellCó thể đã có người làm @admivsn đã nhận 37 ngày trước. Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 93/100
aws/sagemaker-python-sdk#6232 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
[Bug] ModelTrainer with no input channels emits InputDataConfig: [], which CreatePipeline rejects (min=1) — v2 omitted the keyCó thể đã có người làm @sagemaker-bot đã nhận 9 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
aws/sagemaker-python-sdk#6156 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
sagemaker-train should depend on mlflow-skinny, following sagemaker-mlflow 0.5.0Có thể đã có người làm @mohamedzeidan2021 đã nhận 10 ngày trước. Đang mở
Độ khó 2/5 Nửa ngày Mức phù hợp với người mới 72/100
aws/sagemaker-python-sdk#6152 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
ModelTrainer generates sm_train.sh with CRLF line endings on Windows causing training job failureCó thể đã có người làm @MohammedAlkindi đã nhận 28 ngày trước. Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
aws/sagemaker-python-sdk#5904 · 1 reaction ·
Maintainer thường phản hồi trong vòng 2 ngày
Tất cả issue của aws/sagemaker-python-sdk
Issue tương tự
-
first
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
AcademySoftwareFoundation/rmtc#54 · 1 bình luận ·
-
feature/cohorts feature/feature-flags team/feature-flags
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
Maintainer thường phản hồi trong vòng 1 ngày
-
License examples/ as MITCó thể đã có người làm @PGrayCS đã nhận hôm nay. Đang mởdocumentation enhancement example good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
speedyk-005/yasbd-lib#383 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
interactions-py/interactions.py#1827 ·
-
Managed start can fail when OpenVMM reads its control capability before NVX writes itCó thể đã có người làm @ppenna đã nhận hôm nay. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 1 ngày