Skip to content

Unnecessary session call while generating pipeline definition #2676

@vinitsheth

Description

@vinitsheth

Describe the bug
Unnecessary session call to get account_id is made here which is not required. if self.lambda_func.function_arn is passed while creating Lambda, the account_id obtained from the call is ignored.

This limits the usage of Lambda Step and aws credentials are required to be able to use this.

To reproduce

import boto3
from sagemaker.lambda_helper import Lambda
from sagemaker.session import Session
from sagemaker.workflow.lambda_step import LambdaStep
from sagemaker.workflow.pipeline import Pipeline


region_name = "us-east-1"
boto_session = boto3.Session(region_name=region_name)
sagemaker_session = Session(boto_session=boto_session)
lambda_fun_arn = "arn:aws:lambda:us-east-1:123456789123:function:some-lambda-fun"

step_lambda = LambdaStep(
    name=f"Some-Lambda-Step",
    lambda_func=Lambda(function_arn=lambda_fun_arn, session=sagemaker_session)
)

model_pipeline = Pipeline(
    name=f"Some-ModelPipeline",
    steps=[step_lambda],
    sagemaker_session=sagemaker_session
)
print(model_pipeline.definition())

Expected behavior
It would be useful if this session call is moved inside of this if block.

Screenshots or logs

botocore.exceptions.NoCredentialsError: Unable to locate credentials

Additional context
In our use case we are only interested in generating pipeline definition. All other steps allow generating pipeline definition without making any calls which would require aws credentials.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions