SageMakerClient CustomSession uses default values instead of passed user session
Los mantenedores suelen responder en 2 días
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 68/100
- Tipo de issue
- Error
- Claridad
- Bastante claro
- Estado de actividad
- Tranquilo
- Stack tecnológico
- aws, python
- Área
- cloud, machine-learning
Línea de trabajo
Comienza en sagemaker-core/src/sagemaker/core/utils/utils.py, alrededor de SageMakerClient.init (aproximadamente en las líneas 395–406), y después compara cómo los clientes de sagemaker-runtime, featurestore y metrics usan la sesión proporcionada. Ejecuta la reproducción proporcionada con varios perfiles y verifica que CreateTrainingJob use la cuenta y la región especificadas en lugar del perfil predeterminado.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- Python
- Estrellas
- 2.3k
- Forks
- 1.3k
- Merge medio
- 3 d 7 h
- PR fusionados (30 d)
- 87
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de aws/sagemaker-python-sdk
-
Cannot use spark_event_logs_s3_uri in PySparkProcessor jobPosiblemente ocupada @rsareddy0329 la tomó hace 8 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
aws/sagemaker-python-sdk#6253 ·
Los mantenedores suelen responder en 2 días
-
[Bug] V3 Hyperparameter Tuning Pipeline page labelled "Download Data" in navigation due to missing title cellPosiblemente ocupada @admivsn la tomó hace 36 días. Abierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 93/100
aws/sagemaker-python-sdk#6232 ·
Los mantenedores suelen responder en 2 días
-
[Bug] ModelTrainer with no input channels emits InputDataConfig: [], which CreatePipeline rejects (min=1) — v2 omitted the keyPosiblemente ocupada @sagemaker-bot la tomó hace 8 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
aws/sagemaker-python-sdk#6156 · 2 comentarios ·
Los mantenedores suelen responder en 2 días
-
sagemaker-train should depend on mlflow-skinny, following sagemaker-mlflow 0.5.0Posiblemente ocupada @mohamedzeidan2021 la tomó hace 9 días. Abierto
Dificultad 2/5 Medio día Aptitud para principiantes 72/100
aws/sagemaker-python-sdk#6152 ·
Los mantenedores suelen responder en 2 días
-
ModelTrainer generates sm_train.sh with CRLF line endings on Windows causing training job failurePosiblemente ocupada @MohammedAlkindi la tomó hace 27 días. Abierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 88/100
aws/sagemaker-python-sdk#5904 · 1 reacción ·
Los mantenedores suelen responder en 2 días
Todos los issues de aws/sagemaker-python-sdk
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
RedHatQE/mtv-api-tests#721 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 1-3 horas Aptitud para principiantes 85/100
pytest-dev/pluggy#757 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 1-3 horas Aptitud para principiantes 85/100
NousResearch/hermes-agent#134960 ·
Los mantenedores suelen responder en 1 día
-
HTML backend: `<br>` leaks the internal sentinel U+E000 into list items, headings and captionsPosiblemente ocupada @morten-lagabote la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 67/100
docling-project/docling#4671 ·
Los mantenedores suelen responder en 1 día