如何解决AttributeError:“ ClientCreatorContext”对象没有属性“ invoke_endpoint”
我正在尝试使用aioboto3库异步调用SageMaker上的端点。 下面是用于此的简单python代码
import asyncio
import aioboto3
async def entry():
sagemaker_client = aioboto3.session.Session(profile_name='mlbeta').client('sagemaker-runtime')
request_body = "...<some-payload>..."
response = await sagemaker_client.invoke_endpoint(
EndpointName='ASMSummaryGenerator',Body=request_body,ContentType='application/json'
)
response_json = response['Body'].read().decode('utf-8')
print(response_json)
if __name__ == "__main__":
loop = asyncio.get_event_loop()
loop.run_until_complete(entry())
运行此代码时出现以下错误
/Users/rppatwa/anaconda3/bin/python /Volumes/Unix/workplace/RPPythonTestsWS/src/RPPythonTests/src/PythonPlayground/AsyncBoto3SpeakableTest.py
Traceback (most recent call last):
File "/Volumes/Unix/workplace/RPPythonTestsWS/src/RPPythonTests/src/PythonPlayground/AsyncBoto3SpeakableTest.py",line 43,in <module>
loop.run_until_complete(entry())
File "/Users/rppatwa/anaconda3/lib/python3.7/asyncio/base_events.py",line 584,in run_until_complete
return future.result()
File "/Volumes/Unix/workplace/RPPythonTestsWS/src/RPPythonTests/src/PythonPlayground/AsyncBoto3SpeakableTest.py",line 30,in entry
response = await sagemaker_client.invoke_endpoint(
AttributeError: 'ClientCreatorContext' object has no attribute 'invoke_endpoint'
sys:1: RuntimeWarning: coroutine 'AioSession._create_client' was never awaited
aiboto3库是否支持等待invoke_endpoint()api?如果没有,如何通过其他方式实现异步执行。感谢您的回应。预先感谢!
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。