Skip to content

feature: do not expand estimator role when it is pipeline parameter #3416

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/sagemaker/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def _load_config(inputs, estimator, expand_role=True, validate_uri=True):
input_config = _Job._format_inputs_to_input_config(inputs, validate_uri)
role = (
estimator.sagemaker_session.expand_role(estimator.role)
if expand_role
if (expand_role and not is_pipeline_variable(estimator.role))
else estimator.role
)
output_config = _Job._prepare_output_config(estimator.output_path, estimator.output_kms_key)
Expand Down
10 changes: 10 additions & 0 deletions tests/unit/test_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from sagemaker.instance_group import InstanceGroup
from sagemaker.job import _Job
from sagemaker.model import FrameworkModel
from sagemaker.workflow.parameters import ParameterString

BUCKET_NAME = "s3://mybucket/train"
S3_OUTPUT_PATH = "s3://bucket/prefix"
Expand Down Expand Up @@ -218,6 +219,15 @@ def test_load_config_with_code_channel_no_code_uri(framework):
assert config["resource_config"]["InstanceType"] == INSTANCE_TYPE


def test_load_config_with_role_as_pipeline_parameter(estimator):
inputs = TrainingInput(BUCKET_NAME)
estimator.role = ParameterString(name="Role")

config = _Job._load_config(inputs, estimator)

assert config["role"] == estimator.role


def test_format_inputs_none():
channels = _Job._format_inputs_to_input_config(inputs=None)

Expand Down