python - 从 Glue Job 调用 AWS Sagemaker 终端节点
问题描述
如何从 Glue Job 调用 AWS Sagemaker Endpoint?
endpoint_name='I_created_EndPoint'
from sagemaker.predictor import csv_serializer, json_deserializer
predictor = sagemaker.predictor.RealTimePredictor(endpoint=endpoint_name)
但是, import sagemaker
给出了错误。试过了
import sys
import subprocess
# implement pip as a subprocess:
subprocess.check_call([sys.executable, '-m', 'pip', 'install',
'sagemaker'])
这也给出了一些错误
Traceback (most recent call last):
File "/tmp/DataToMl", line 6, in <module>
'sagemaker'])
File "/usr/lib64/python3.7/subprocess.py", line 363, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['/usr/bin/python3', '-m', 'pip', 'install', 'sagemaker']' returned non-zero exit status 2
解决方案
看起来问题出在安装 sagemaker 上。
您是否能够pip install
直接从您的环境中创建 sagemaker?如果不是,实际错误是什么?可能存在一些冲突依赖关系。
此外,您提供的 sagemaker 代码是 sagemaker v1 (RealTimePredictor),您可能希望将其更改为 sagemaker v2 (Predictor) 以pip install sagemaker
安装 sagemaker v2。有关 sagemaker 版本的更多信息:https ://pypi.org/project/sagemaker/#history