从不同区域的端点创建预测器

Create a predictor from an endpoint in a different region

我在 us-east-1 上创建了一个端点。尝试创建一个预测器:

In [106]: sagemaker.predictor.RealTimePredictor(<endpoint name>)

并获得

ClientError: An error occurred (ValidationException) when calling the DescribeEndpoint operation: 
Could not find endpoint "arn:aws:sagemaker:us-east-2:<account number>:endpoint/<endpoint name>".

完全正确,因为端点位于 us-east-1。也许我可以更改一些默认设置,但我宁愿不这样做 - 我 99% 的时间都在 us-east-2 上工作。

那么,如何在初始化预测器时设置不同的区域?

(python) Predictors documentation shows that you can pass a Session object. In turn, the Session can be initialized 带有 客户端 运行时客户端 - 前者做除端点调用之外的所有事情,后者做...端点调用。

这些客户与特定地区相关联。看起来你应该能够通过手动实例化它来设置运行时客户端区域以匹配你的端点,同时单独留下常规客户端(此处免责声明:我没有尝试过这个 - 如果你这样做,让 me/us知道怎么回事:)).

是的,您可以在创建客户端时指定地区,例如:

sm_runtime = boto3.client(service_name='sagemaker-runtime', region_name='us-east-1')