@@ -40,13 +40,18 @@ def _get_test_config():
4040 """Build test configuration lazily (only when tests actually run)."""
4141 boto_session = boto3 .Session (region_name = _REGION )
4242 account_id = boto_session .client ("sts" ).get_caller_identity ()["Account" ]
43+ from sagemaker .core .helper .session_helper import Session
44+ from sagemaker .train .defaults import TrainDefaults
45+ sagemaker_session = Session (boto_session = boto_session )
46+ role_arn = TrainDefaults .get_role (role = None , sagemaker_session = sagemaker_session )
4347 return {
4448 "base_model" : "mock-oss-test" ,
4549 "agent_arn" : f"arn:aws:bedrock-agentcore:{ _REGION } :{ account_id } :runtime/sagemaker_rft_prod_gsm8k_streaming-Yk6O377mUS" ,
4650 "dataset" : f"s3://sagemaker-rft-{ account_id } /prompts/gsm8k_small/prompts.parquet" ,
4751 "s3_output_path" : f"s3://sagemaker-{ _REGION } -{ account_id } /model-evaluation/output-artifacts/" ,
4852 "mlflow_resource_arn" : f"arn:aws:sagemaker:{ _REGION } :{ account_id } :mlflow-app/app-TTAUWUNMUHH6" ,
4953 "model_package_group" : f"arn:aws:sagemaker:{ _REGION } :{ account_id } :model-package-group/openai-reasoning-gpt-oss-20b-mtrl-mpg" ,
54+ "role" : role_arn ,
5055 "region" : _REGION ,
5156 "account_id" : account_id ,
5257 }
@@ -180,7 +185,7 @@ def test_bedrock_agent_config_fields(self, mtrl_trainer, test_config):
180185 evaluator ._resolve_agent_arn ()
181186
182187 ctx = evaluator ._build_template_context (
183- aws_context = {"region" : test_config ["region" ], "account_id" : test_config ["account_id" ]},
188+ aws_context = {"region" : test_config ["region" ], "account_id" : test_config ["account_id" ], "role_arn" : test_config [ "role" ] },
184189 artifacts = {},
185190 model_package_group_arn = test_config ["model_package_group" ],
186191 )
@@ -213,7 +218,7 @@ def test_lambda_agent_config_fields(self, mtrl_trainer, test_config):
213218 evaluator ._resolve_agent_arn ()
214219
215220 ctx = evaluator ._build_template_context (
216- aws_context = {"region" : test_config ["region" ], "account_id" : test_config ["account_id" ]},
221+ aws_context = {"region" : test_config ["region" ], "account_id" : test_config ["account_id" ], "role_arn" : test_config [ "role" ] },
217222 artifacts = {},
218223 model_package_group_arn = test_config ["model_package_group" ],
219224 )
@@ -242,7 +247,7 @@ def test_model_package_config_fields(self, mtrl_trainer, test_config):
242247 evaluator ._resolve_agent_arn ()
243248
244249 ctx = evaluator ._build_template_context (
245- aws_context = {"region" : test_config ["region" ], "account_id" : test_config ["account_id" ]},
250+ aws_context = {"region" : test_config ["region" ], "account_id" : test_config ["account_id" ], "role_arn" : test_config [ "role" ] },
246251 artifacts = {},
247252 model_package_group_arn = test_config ["model_package_group" ],
248253 )
0 commit comments