从Glue Job调用AWS Sagemaker终端节点

时间:2020-09-14 21:06:19

标签: python amazon-web-services aws-glue amazon-sagemaker

如何从Glue Job调用AWS Sagemaker端点?

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

1 个答案:

答案 0 :(得分:0)

看起来问题出在安装sagemaker。

您是否可以直接从您的环境pip install造智者?如果没有,实际错误是什么?可能存在一些冲突依赖性。

此外,您提供的sagemaker代码是sagemaker v1(RealTimePredictor),您可能想将其更改为sagemaker v2(Predictor),因为pip install sagemaker将安装sagemaker v2。有关sagemaker版本的更多信息:https://pypi.org/project/sagemaker/#history