英文:
Reading the "sensitive" results of AWS SageMaker InvokeEndpoint
问题
我正在尝试使用Go SDK调用SageMaker无服务器端点,但结果没有返回,而是标记为“敏感”。根据文档中的说明,它说不会返回正文,但没有说明如何检索它。
当我使用aws-cli调用时,它会正确地将结果JSON填充到输出文件中。
svc := sagemakerruntime.New(sess)
out, err := svc.InvokeEndpoint(&sagemakerruntime.InvokeEndpointInput{
Body: []byte(`xxx`),
ContentType: aws.String("application/json"),
EndpointName: aws.String("xxx"),
})
结果:
{
Body: <sensitive>,
ContentType: "application/json",
InvokedProductionVariant: "single-variant"
}
当我使用aws-cli调用时,它会正确地将结果JSON填充到输出文件中。
aws sagemaker-runtime invoke-endpoint --content-type 'application/json' --endpoint-name xxx --body xxx /tmp/sagemaker-output
英文:
I'm trying to invoke a sagemaker serverless endpoint using the Go SDK and the result is not returned, it's marked as "sensitive". From the docs it says that the body will not be returned but it doesn't say how to retrieve it.
svc := sagemakerruntime.New(sess)
out, err := svc.InvokeEndpoint(&sagemakerruntime.InvokeEndpointInput{
Body: []byte(`xxx`),
ContentType: aws.String("application/json"),
EndpointName: aws.String("xxx"),
})
Result:
{
Body: <sensitive>,
ContentType: "application/json",
InvokedProductionVariant: "single-variant"
}
When I invoke it using the aws-cli, it populates the output file correctly with the result json.
aws sagemaker-runtime invoke-endpoint --content-type 'application/json' --endpoint-name xxx --body xxx /tmp/sagemaker-output
答案1
得分: 0
根据文档所述,这只会影响String
和GoString
方法返回的字符串。你仍然可以直接访问Body
字段。
package main
import (
"fmt"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/sagemakerruntime"
)
func main() {
output := &sagemakerruntime.InvokeEndpointOutput{
Body: []byte("body data"),
ContentType: aws.String("application/json"),
InvokedProductionVariant: aws.String("single-variant"),
}
fmt.Println(output)
fmt.Printf("body: %s\n", output.Body)
}
输出:
{
Body: <sensitive>,
ContentType: "application/json",
InvokedProductionVariant: "single-variant"
}
body: body data
英文:
> Body is a sensitive parameter and its value will be replaced with "sensitive" in string returned by InvokeEndpointOutput's String and GoString methods.
As stated in the document, it only affects the string returned by the String
and GoString
methods. You still can access the Body
field directly.
package main
import (
"fmt"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/sagemakerruntime"
)
func main() {
output := &sagemakerruntime.InvokeEndpointOutput{
Body: []byte("body data"),
ContentType: aws.String("application/json"),
InvokedProductionVariant: aws.String("single-variant"),
}
fmt.Println(output)
fmt.Printf("body: %s\n", output.Body)
}
Output:
{
Body: <sensitive>,
ContentType: "application/json",
InvokedProductionVariant: "single-variant"
}
body: body data
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论