[英]Accessing the return value of a Lambda Step in Sagemaker pipeline
I've added a Lambda Step as the first step in my Sagemaker Pipeline.我添加了一个 Lambda 步骤作为我的 Sagemaker 管道中的第一步。 It processes some data and creates 2 files as part of the output like so:
它处理一些数据并创建 2 个文件作为 output 的一部分,如下所示:
from sagemaker.workflow.lambda_step import LambdaStep, Lambda, LambdaOutput, LambdaOutputTypeEnum
# lamb_preprocess = LambdaStep(func_arn="")
output_param_1 = LambdaOutput(output_name="status", output_type=LambdaOutputTypeEnum.Integer)
output_param_2 = LambdaOutput(output_name="file_name_a_c_drop", output_type=LambdaOutputTypeEnum.String)
output_param_3 = LambdaOutput(output_name="file_name_q_c_drop", output_type=LambdaOutputTypeEnum.String)
step_lambda = LambdaStep(
name="ProcessingLambda",
lambda_func=Lambda(
function_arn="arn:aws:lambda:us-east-1:xxxxxxxx:function:xxxxx"
),
inputs={
"input_data": input_data,
"input_file": trigger_file,
"input_bucket": trigger_bucket
},
outputs = [
output_param_1, output_param_2, output_param_3
]
)
In my next step, I want to trigger a Processing Job for which I need to pass in the above Lambda function's outputs as it's inputs.在我的下一步中,我想触发一个处理作业,我需要将上面 Lambda 函数的输出作为输入传递给它。 I'm trying to do it like so:
我正在尝试这样做:
inputs = [
ProcessingInput(source=step_lambda.properties.Outputs["file_name_q_c_drop"], destination="/opt/ml/processing/input"),
ProcessingInput(source=step_lambda.properties.Outputs["file_name_a_c_drop"], destination="/opt/ml/processing/input"),
]
However, when the processing step is trying to get created, I get a validation message saying但是,当尝试创建处理步骤时,我收到一条验证消息说
Object of type Properties is not JSON serializable
I followed the data dependency docs here: https://sagemaker.readthedocs.io/en/stable/amazon_sagemaker_model_building_pipeline.html#lambdastep and tried accessing step_lambda.OutputParameters["file_name_a_c_drop"]
too but it errored out saying 'LambdaStep' object has no attribute 'OutputParameters'
我在这里遵循了数据依赖文档: https:https://sagemaker.readthedocs.io/en/stable/amazon_sagemaker_model_building_pipeline.html#lambdastep并尝试访问
step_lambda.OutputParameters["file_name_a_c_drop"]
但它出错说'LambdaStep' object has no attribute 'OutputParameters'
How do I properly access the return value of a LambdaStep in a Sagemaker pipeline?如何在 Sagemaker 管道中正确访问 LambdaStep 的返回值?
You can access the output as follows - step_lambda.OutputParameters["output1"]
.您可以按以下方式访问 output -
step_lambda.OutputParameters["output1"]
。 You don't need to add .properties
您不需要添加
.properties
To access a LambdaStep output in another step you can do this:要在另一个步骤中访问 LambdaStep output,您可以执行以下操作:
step_lambda.properties.Outputs["file_name_a_c_drop"]
Try this尝试这个
steplambda.properties.ProcessingOutputConfig.Outputs["file_name_q_c_drop"].S3Output.S3Uri
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.