【问题标题】:_InactiveRpcError while using workflow_InactiveRpcError 使用工作流时
【发布时间】:2021-04-19 19:10:05
【问题描述】:

您好,我尝试复制 clarifai 文档以创建工作流程

下面是我的错误代码

  ---------------------------------------------------------------------------
_InactiveRpcError                         Traceback (most recent call last)
<ipython-input-23-3e79233b3dd8> in <module>
     11       resources_pb2.Input(data=resources_pb2.Data(image=resources_pb2.Image(url='YOUR_IMAGE_URL')))
     12     ])
---> 13 response = stub.PostModelOutputs(request, metadata=metadata)
     14 
     15 if response.status.code != status_code_pb2.SUCCESS:

~\Anaconda3\lib\site-packages\grpc\_channel.py in __call__(self, request, timeout, metadata, credentials, wait_for_ready, compression)
    824                     raise StopIteration()
    825                 elif self._state.code is not None:
--> 826                     raise self
    827 
    828 

~\Anaconda3\lib\site-packages\grpc\_channel.py in _end_unary_response_blocking(state, call, with_call, deadline)
    727     def result(self, timeout=None):
    728         """Returns the result of the computation or raises its exception.
--> 729 
    730         See grpc.Future.result for the full API contract.
    731         """

_InactiveRpcError: <_InactiveRpcError of RPC that terminated with:
    status = StatusCode.UNAVAILABLE
    details = "failed to connect to all addresses"
    debug_error_string = "{"created":"@1618805454.368000000","description":"Failed to pick subchannel","file":"src/core/ext/filters/client_channel/client_channel.cc","file_line":4134,"referenced_errors":[{"created":"@1618805454.368000000","description":"failed to connect to all addresses","file":"src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc","file_line":398,"grpc_status":14}]}"
>

要创建错误,API 密钥是示例密钥

from clarifai_grpc.channel.clarifai_channel import ClarifaiChannel
from clarifai_grpc.grpc.api import service_pb2_grpc

stub = service_pb2_grpc.V2Stub(ClarifaiChannel.get_grpc_channel())

    from clarifai_grpc.grpc.api import service_pb2, resources_pb2
from clarifai_grpc.grpc.api.status import status_code_pb2

# This is how you authenticate.
metadata = (('authorization', 'Key b66dddddddddddddddddddddddddd'),)

request = service_pb2.PostModelOutputsRequest(
    # This is the model ID of a publicly available General model. You may use any other public or custom model ID.
    model_id='aaa03c23b3724a16a56b629203edc62c',
    inputs=[
      resources_pb2.Input(data=resources_pb2.Data(image=resources_pb2.Image(url='YOUR_IMAGE_URL')))
    ])
response = stub.PostModelOutputs(request, metadata=metadata)

if response.status.code != status_code_pb2.SUCCESS:
    raise Exception("Request failed, status code: " + str(response.status.code))

for concept in response.outputs[0].data.concepts:
    print('%12s: %.2f' % (concept.name, concept.value))

我求助于 grpc 来解决问题,但找不到答案 https://grpc.io/docs/languages/python/quickstart/ 任何建议表示赞赏

【问题讨论】:

  • 确保在创建 PostModelOutputsRequest 对象时填充 url - 目前它只是说“YOUR_IMAGE_URL”而不是实际的 URL(也许你已经为帖子清理了它)。

标签: python grpc clarifai


【解决方案1】:

您是否尝试过再次运行代码并在几分钟或几小时后再次调用相同的端点? inactive RPC 错误通常意味着该服务暂时不可用。

【讨论】:

    猜你喜欢
    • 2021-05-19
    • 2021-10-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-07-24
    • 2020-09-18
    相关资源
    最近更新 更多