aws / aws/sagemaker-python-sdk
ModelTrainer (V3) does not support output_kms_key for source code uploads
- Ngôn ngữ chính
- Python
- Star
- 2.3k
- Fork
- 1.3k
- Merge trung bình
- 1 ngày 22 giờ
- Pull request đã merge (30 ngày)
- 35
Mô tả
## Describe the bug
In SageMaker SDK V2, the `Estimator` uses the `output_kms_key` when uploading user training scripts to S3 (see `_stage_user_code_in_s3`):
https://github.com/aws/sagemaker-python-sdk/blob/5b3b127a2d3d12a6ff0d877ddfd9ddf13527c27f/src/sagemaker/estimator.py#L1044-L1108
In SageMaker SDK V3, the new `ModelTrainer` does not apply any KMS key when uploading source code while creating the input data channel:
https://github.com/aws/sagemaker-python-sdk/blob/9101cef1a589cf2b44e73c5456dfa46c10e32691/sagemaker-train/src/sagemaker/train/model_trainer.py#L834-L953
Additionally, even when providing an S3 URI in the `SourceCode` object (instead of a local path), the `ModelTrainer` still uploads additional driver files whenever source code is specified:
https://github.com/aws/sagemaker-python-sdk/blob/9101cef1a589cf2b44e73c5456dfa46c10e32691/sagemaker-train/src/sagemaker/train/model_trainer.py#L684-L689
These uploads do not use a KMS key.
## Expected behavior
`ModelTrainer` should:
- either respect a user-provided KMS key (similar to `output_kms_key` in V2), OR
- allow configuration of a KMS key for all S3 uploads related to source code.
## Actual behavior
- Source code and driver files are uploaded to S3 without KMS encryption.
- There is no apparent way to configure a KMS key for these uploads.
## Impact
In restricted environments (like ours), S3 policies enforce server-side encryption with KMS.
As a result, `ModelTrainer` cannot be used with custom training scripts.
This blocks use cases that rely on custom code, such as MLflow serverless integration.
## Steps to reproduce
1. Create a `ModelTrainer` with a `SourceCode` object
2. Provide either:
- a local path, or
- an S3 URI
3. Observe that S3 uploads occur without KMS encryption
## Possible solution
Expose a parameter similar to `output_kms_key` in V2, or reuse existing encryption configuration mechanisms.
## Additional context
This is a regression compared to V2 `Estimator` behavior and impacts secure environments with strict S3 encryption policies.
Hướng dẫn đóng góp
Hướng nghiên cứu
Bắt đầu trong sagemaker-train/src/sagemaker/train/model_trainer.py, tại các đường dẫn upload của input-channel và driver-file được nêu trong issue, sau đó so sánh chúng với _stage_user_code_in_s3 trong src/sagemaker/estimator.py. Theo dõi cấu hình mã hóa hiện có và bổ sung coverage tập trung cho các upload SourceCode cục bộ và S3. Hoàn tất khi tất cả các upload liên quan đến mã nguồn đều có thể sử dụng KMS key đã cấu hình.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- aws, python
- Lĩnh vực
- cloud, machine-learning
- Loại issue
- Lỗi
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức độ hoạt động
- Ít trao đổi
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 68/100