2

I tried using the clarify-python-grpc client and it worked great. Here I just wanted to try the demographics model for testing. It worked 2 weeks ago but I think there was an update to grpc which leads to this bug.

from clarifai_grpc.channel.clarifai_channel import ClarifaiChannel
from clarifai_grpc.grpc import api
from clarifai_grpc.grpc.api import resources_pb2, service_pb2, service_pb2_grpc
from clarifai_grpc.grpc.api.status import status_pb2, status_code_pb2

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

api_key = 'sanitized'
metadata = (('authorization', f'Key {api_key}'),)

post_model_outputs_response = stub.PostModelOutputs(
    service_pb2.PostModelOutputsRequest(
        model_id="c0c0ac362b03416da06ab3fa36fb58e3",#demographics_model  
        inputs=[
            resources_pb2.Input(
                data=resources_pb2.Data(
                    image=resources_pb2.Image(
                        url="https://samples.clarifai.com/metro-north.jpg"
                    )
                )
            )
        ],
        model=resources_pb2.Model(
            output_info=resources_pb2.OutputInfo(
                output_config=resources_pb2.OutputConfig(
                    select_concepts=[
                        # When selecting concepts, value is ignored, so no need to specify it.
                        resources_pb2.Concept(name="train"),
                        resources_pb2.Concept(id="ai_6kTjGfF6")
                    ]
                )
            )
        )
    ),
    metadata=metadata
)
if post_model_outputs_response.status.code != status_code_pb2.SUCCESS:
    raise Exception("Post model outputs failed, status: " + post_model_outputs_response.status.description)

# Since we have one input, one output will exist here.
output = post_model_outputs_response.outputs[0]

print("Predicted concepts:")
for concept in output.data.concepts:
    print("%s %.2f" % (concept.name, concept.value))

Today I tried the same script and I get this error:

E1004 14:07:49.389861000 8636689920 ssl_transport_security.cc:1469]    Handshake failed with fatal error SSL_ERROR_SSL: error:1000007d:SSL routines:OPENSSL_internal:CERTIFICATE_VERIFY_FAILED.
E1004 14:07:49.629743000 8636689920 ssl_transport_security.cc:1469]    Handshake failed with fatal error SSL_ERROR_SSL: error:1000007d:SSL routines:OPENSSL_internal:CERTIFICATE_VERIFY_FAILED.
E1004 14:07:49.851189000 8636689920 ssl_transport_security.cc:1469]    Handshake failed with fatal error SSL_ERROR_SSL: error:1000007d:SSL routines:OPENSSL_internal:CERTIFICATE_VERIFY_FAILED.
Traceback (most recent call last):
  File "/Users/Test_Pys/211003_test.py", line 40, in <module>
    post_model_outputs_response = stub.PostModelOutputs(
  File "/Users/opt/anaconda3/envs/testing/lib/python3.9/site-packages/grpc/_channel.py", line 946, in __call__
    return _end_unary_response_blocking(state, call, False, None)
  File "/Users/opt/anaconda3/envs/testing/lib/python3.9/site-packages/grpc/_channel.py", line 849, in _end_unary_response_blocking
    raise _InactiveRpcError(state)
grpc._channel._InactiveRpcError: <_InactiveRpcError of RPC that terminated with:
        status = StatusCode.UNAVAILABLE
        details = "failed to connect to all addresses"
        debug_error_string = "{"created":"@1633349269.851731000","description":"Failed to pick subchannel","file":"src/core/ext/filters/client_channel/client_channel.cc","file_line":3159,"referenced_errors":[{"created":"@1633349269.851729000","description":"failed to connect to all addresses","file":"src/core/lib/transport/error_utils.cc","file_line":147,"grpc_status":14}]}"

What can I do to fix this?

Bernardo
  • 86
  • 7

2 Answers2

2

Deleting SHA1 Fingerprint: da:c9:02:4f:54:d8:f6:df:94:93:5f:b1:73:26:38:ca:6a:d7:7c:13 certificate in the roots.pem file solved it for me

Bernardo
  • 86
  • 7
0

New release 1.41.1 of gRPC Core fixes it https://github.com/grpc/grpc/pull/27539

Marsel Novy
  • 1,777
  • 16
  • 23