Giter VIP home page Giter VIP logo

clarifai-python-grpc's People

Contributors

ackizilkale avatar aleksander-clarifai avatar aruex avatar cjkjvfnby avatar clarifai-prod avatar harmitminhas96 avatar iankelk avatar isaac-chung avatar jeffreytoffoli avatar johntorcivia avatar madisjanno avatar mansi-k avatar marco-clarifai avatar martinkask-clarifai avatar moldovan-clarifai avatar nick-clarifai avatar rok-clarifai avatar rok-povsic avatar sainivedh avatar tiit-clarifai avatar travertischio avatar wemoveon2 avatar xiv avatar yangshengbe avatar yvettez2017 avatar zeiler avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

clarifai-python-grpc's Issues

Handshake failed with fatal error SSL_ERROR_SSL

Hello,

I tried using the clarify-python-grpc client and it worked great. 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?

where can i get the model_id?

Hello, the model_id for general model is model_id='aaa03c23b3724a16a56b629203edc62c'
But my model is General_detection, what is the id for general_detection?
Thanks!

Error using grpc channel to PostInputs

Dear sir,

When I use grpc channel to post inputs (stub.PostInputs), with the following code:

uri = 'https://mobileimages.lowes.com/product/converted/883049/883049360881.jpg'
img_instance = Image(url=uri,allow_duplicate_url=False)
input_proto = Input(data=Data(image=img_instance, concepts=[], metadata={}))
post_res = server.stub.PostInputs(PostInputsRequest(user_app_id=user_app_id, inputs=[input_proto]), server.auth_metadata)

I got this error

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-30-154f9ce6f621> in <module>
----> 1 post_res = server.stub.PostInputs(
      2     PostInputsRequest(user_app_id=user_app_id, inputs=[input_proto]), server.auth_metadata)

~/anaconda3/envs/data_science_local/lib/python3.8/site-packages/grpc/_channel.py in __call__(self, request, timeout, metadata, credentials, wait_for_ready, compression)
    919                  wait_for_ready=None,
    920                  compression=None):
--> 921         state, call, = self._blocking(request, timeout, metadata, credentials,
    922                                       wait_for_ready, compression)
    923         return _end_unary_response_blocking(state, call, False, None)

~/anaconda3/envs/data_science_local/lib/python3.8/site-packages/grpc/_channel.py in _blocking(self, request, timeout, metadata, credentials, wait_for_ready, compression)
    896     def _blocking(self, request, timeout, metadata, credentials, wait_for_ready,
    897                   compression):
--> 898         state, operations, deadline, rendezvous = self._prepare(
    899             request, timeout, metadata, wait_for_ready, compression)
    900         if state is None:

~/anaconda3/envs/data_science_local/lib/python3.8/site-packages/grpc/_channel.py in _prepare(self, request, timeout, metadata, wait_for_ready, compression)
    873 
    874     def _prepare(self, request, timeout, metadata, wait_for_ready, compression):
--> 875         deadline, serialized_request, rendezvous = _start_unary_request(
    876             request, timeout, self._request_serializer)
    877         initial_metadata_flags = _InitialMetadataFlags().with_wait_for_ready(

~/anaconda3/envs/data_science_local/lib/python3.8/site-packages/grpc/_channel.py in _start_unary_request(request, timeout, request_serializer)
    805 
    806 def _start_unary_request(request, timeout, request_serializer):
--> 807     deadline = _deadline(timeout)
    808     serialized_request = _common.serialize(request, request_serializer)
    809     if serialized_request is None:

~/anaconda3/envs/data_science_local/lib/python3.8/site-packages/grpc/_channel.py in _deadline(timeout)
     83 
     84 def _deadline(timeout):
---> 85     return None if timeout is None else time.time() + timeout
     86 
     87 

TypeError: unsupported operand type(s) for +: 'float' and 'tuple'

And if I use json channel with the same code above this works; so there should be no error in the server end except this api call. Could you help resolve this issue?

Thanks,
Yeu-Chern

package upload error

the PyPI package is uploaded, however, showing an error on the command line.
below is the command output

1 ❯ twine upload dist/* --verbose

Uploading distributions to https://upload.pypi.org/legacy/
INFO     dist/clarifai-grpc-9.6.0.tar.gz (189.9 KB)
INFO     Querying keyring for username
Enter your username: clarifai
INFO     Querying keyring for password
WARNING  Error getting password from keyring
         Traceback (most recent call last):
           File "/mnt/nfsmount/asifmohammed/virtualenv/v1/lib/python3.9/site-packages/twine/auth.py", line 74, in
         get_password_from_keyring
             return cast(str, keyring.get_password(system, username))
           File "/mnt/nfsmount/asifmohammed/virtualenv/v1/lib/python3.9/site-packages/keyring/core.py", line 56, in
         get_password
             return get_keyring().get_password(service_name, username)
           File "/mnt/nfsmount/asifmohammed/virtualenv/v1/lib/python3.9/site-packages/keyring/backends/fail.py", line
         28, in get_password
             raise NoKeyringError(msg)
         keyring.errors.NoKeyringError: No recommended backend was available. Install a recommended 3rd party backend
         package; or, install the keyrings.alt package if you want to use the non-recommended backends. See
         https://pypi.org/project/keyring for details.
Enter your password:
INFO     username: clarifai
INFO     password: <hidden>
Uploading clarifai-grpc-9.6.0.tar.gz
100% ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 201.1/201.1 kB • 00:00 • 5.6 MB/s
INFO     Response from https://upload.pypi.org/legacy/:
         400 File already exists. See https://pypi.org/help/#file-name-reuse for more information.
INFO     <html>
          <head>
           <title>400 File already exists. See https://pypi.org/help/#file-name-reuse for more information.</title>
          </head>
          <body>
           <h1>400 File already exists. See https://pypi.org/help/#file-name-reuse for more information.</h1>
           The server could not comply with the request since it is either malformed or otherwise incorrect.<br/><br/>
         File already exists. See https://pypi.org/help/#file-name-reuse for more information.


          </body>
         </html>
ERROR    HTTPError: 400 Bad Request from https://upload.pypi.org/legacy/
         File already exists. See https://pypi.org/help/#file-name-reuse for more information.

How can I get coordinates of bounding box?

Hi,
I am currently using Apparel Detection model. I was able to obtain the prediction and their scores. However, I could not find a way to see get the bounding box coordinates. Can you help me with this? Thanks for your time.

Best,
Işık

Empty or malformed authorization header. Please provide an API key or session token.

Hey I was starting on clarifai API in python according to the docs I used the gRPC channel but I am getting Invalid request error even though I submitted my api key

Error I am getting is
status {
  code: CONN_INVALID_REQUEST
  description: "Invalid request"
  details: "Empty or malformed authorization header. Please provide an API key or session token."
  req_id: "cc62bbb57e044d87a57d0d879a65c2d6"
}

I am sure that my api key is valid

here's my code

from clarifai_grpc.channel.clarifai_channel import ClarifaiChannel
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)

metadata = (('authorization', 'key <my api key here>'),)
post_inputs_response = stub.PostModelOutputs(
    service_pb2.PostModelOutputsRequest(
        model_id="9f54c0342741574068ec696ddbebd699",
        inputs=[
            resources_pb2.Input(
                data=resources_pb2.Data(
                    image=resources_pb2.Image(
                        url="https://samples.clarifai.com/metro-north.jpg",
                        allow_duplicate_url=True
                    )
                )
            )
        ]
    ),
    metadata=metadata
)

print(post_inputs_response)

`IndentationError` in Version 9.7.2

Version 9.7.2 has an IndentationError:

    from clarifai_grpc.channel.clarifai_channel import ClarifaiChannel
  File "/opt/hostedtoolcache/Python/3.10.12/x64/lib/python3.10/site-packages/clarifai_grpc/channel/clarifai_channel.py", line 7, in <module>
    from clarifai_grpc.grpc.api import service_pb2_grpc
  File "/opt/hostedtoolcache/Python/3.10.12/x64/lib/python3.10/site-packages/clarifai_grpc/grpc/api/service_pb2_grpc.py", line 31
    from clarifai_grpc.channel.clarifai_channel import wrap_response_deserializer
IndentationError: expected an indented block after function definition on line 30

which can be seen in https://github.com/Harmon758/Harmonbot/actions/runs/5870663524/job/15918160487#step:8:24.

This version also doesn't seem to have a respective release, tag, or even commit here, with Version 9.7.1 only having a commit as well.

Failed building wheel for grpcio

windows 10 machine
python 3.7.0
Current version of setuptools was 68.0.0

Tried installing recommended version 40.7.1 as per readme
pip --upgrade setuptools==47.1.0

Same error

The error out message is long, but seems to be an issue with the VC tools version?

  "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\HostX86\x86\cl.exe" /c /nologo /O2 /W3 /GL /DNDEBUG /MD -D_WIN32_WINNT=1536 -DGRPC_XDS_USER_AGENT_NAME_SUFFIX=\"\\\"Python\\\"\" -DGRPC_XDS_USER_AGENT_VERSION_SUFFIX=\"\\\"1.56.0\\\"\" -DOPENSSL_NO_ASM=1 -DGPR_BACKWARDS_COMPATIBILITY_MODE=1 -DWIN32_LEAN_AND_MEAN=1 -DCARES_STATICLIB=1 -DGRPC_ARES=0 -DNTDDI_VERSION=100663296 -DNOMINMAX=1 -DNTDDI_VERSION=100663296 -DGRPC_DO_NOT_INSTANTIATE_POSIX_POLLER=1 -Isrc\python\grpcio -Iinclude -I. -Ithird_party\abseil-cpp -Ithird_party\address_sorting\include -Ithird_party\cares\cares\include -Ithird_party\cares -Ithird_party\cares\cares -Ithird_party\re2 -Ithird_party\boringssl-with-bazel\src\include -Ithird_party\upb -Isrc\core\ext\upb-generated -Isrc\core\ext\upbdefs-generated -Ithird_party\utf8_range -Ithird_party\xxhash -Ithird_party\zlib -IC:\Python\Python37\include -IC:\Python\Python37\Include "-IC:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\ATLMFC\include" "-IC:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\include\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\cppwinrt" /EHsc /Tcsrc/core/ext/upb-generated/envoy/config/bootstrap/v3/bootstrap.upb.c /Fopython_build\temp.win32-cpython-37\Release\src/core/ext/upb-generated/envoy/config/bootstrap/v3/bootstrap.upb.obj -std=c++14 /MT
  cl : Command line warning D9025 : overriding '/MD' with '/MT'
  cl : Command line warning D9002 : ignoring unknown option '-std=c++14'

calls to Demographics workflow fail with protobuf version 3.20.0 due to missing positional argument in ConvertMessage

protobuf package updated on april 1, and ever since our calls to the Demographics workflow have been failing.

we are invoking the workflow roughly as follows:

response = stub.PostWorkflowResults(
    service_pb2.PostWorkflowResultsRequest(
      workflow_id="Demographics",
      inputs=[resources_pb2.Input(id=row.id,
                                  data=resources_pb2.Data(image=resources_pb2.Image(url=row.url)))
              for (_, row) in df.iterrows()]
    ),
    metadata=(('authorization', f'Key {token value here}'),)
)

when we run that code in an environment with protobuf==3.20.0, we receive the following error (some lines redacted):

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
REDACTED

REDACTED

<[command-2822161639541355]()> in getClarifaiResponseBatched(df)
     35                 for (_, row) in df.iterrows()]
     36       ),
---> 37       metadata=(('authorization', f'Key {TOKEN}'),)
     38   )
     39 

/databricks/python/lib/python3.7/site-packages/clarifai_grpc/channel/grpc_json_channel.py in __call__(self, request, metadata)
    183         # Get the actual message object to construct
    184         message = self.response_deserializer
--> 185         result = dict_to_protobuf(message, response_json, ignore_unknown_fields=True)
    186 
    187         return result

/databricks/python/lib/python3.7/site-packages/clarifai_grpc/channel/custom_converters/custom_dict_to_message.py in dict_to_protobuf(protobuf_class, js_dict, ignore_unknown_fields)
     23     parser = _CustomParser(ignore_unknown_fields, *none_args)
     24 
---> 25     parser.ConvertMessage(js_dict, message)
     26     return message
     27 

TypeError: ConvertMessage() missing 1 required positional argument: 'path'

we have confirmed that no error results in environments where protobuf==3.19.4

Changelog or Release Notes

Providing a changelog or release notes of any sort would be helpful in determining what each update added or changed.
For example, version 7.0.0 seems to only be a single commit that just bumps the version number?

Stub is not defined

Running the sample code and it gets to line 21 and indicates stub is not defined. Clarifai application is a standalone on premise solution. It is not the most recent version of the web application.

Traceback (most recent call last):
File "clarifai.py", line 21, in
response = stub.PostModelOutputs(request, metadata=metadata)
NameError: name 'stub' is not defined

Windows 10
Python 3.7
Setuptools40.7.1

Using cached clarifai_grpc-9.1.1-py3-none-any.whl (198 kB)
Requirement already satisfied: grpcio>=1.44.0 in c:\python\python37\lib\site-packages (from clarifai-grpc) (1.51.0)
Requirement already satisfied: protobuf>=3.12 in c:\python\python37\lib\site-packages (from clarifai-grpc) (3.20.3)
Requirement already satisfied: googleapis-common-protos>=1.53.0 in c:\python\python37\lib\site-packages (from clarifai-grpc) (1.57.0)
Requirement already satisfied: requests>=2.25.1 in c:\python\python37\lib\site-packages (from clarifai-grpc) (2.28.1)
Requirement already satisfied: charset-normalizer<3,>=2 in c:\python\python37\lib\site-packages (from requests>=2.25.1->clarifai-grpc) (2.1.1)
Requirement already satisfied: idna<4,>=2.5 in c:\users\adminrp\appdata\roaming\python\python37\site-packages (from requests>=2.25.1->clarifai-grpc) (2.8)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in c:\users\adminrp\appdata\roaming\python\python37\site-packages (from requests>=2.25.1->clarifai-grpc) (1.25.3)
Requirement already satisfied: certifi>=2017.4.17 in c:\users\adminrp\appdata\roaming\python\python37\site-packages (from requests>=2.25.1->clarifai-grpc) (2019.3.9)
Installing collected packages: clarifai-grpc
Successfully installed clarifai-grpc-9.1.1

ListCollaborators get Exception: You must set one case of the following fields in your request proto: ['user_app_id.user_id', 'user_app_id.app_id']

When I use API call ListCollaborators, given user_app_id.user_id', 'user_app_id.app_id', I still get the exception that these fields are not given.
Here is my code

res = stub.ListCollaborators(
    ListCollaboratorsRequest(user_app_id=UserAppIDSet(user_id=USER_ID, app_id=APP_ID)), 
    metadata=auth_metadata)

The error I got is:

---------------------------------------------------------------------------
Exception                                 Traceback (most recent call last)
<ipython-input-20-6bdd86034aee> in <module>
----> 1 stub.ListCollaborators(ListCollaboratorsRequest(user_app_id=UserAppIDSet(user_id=user_id, app_id='labeling-Windows-and-Doors')), metadata=auth_metadata)

~/anaconda3/envs/data_science_local/lib/python3.8/site-packages/clarifai_grpc/channel/grpc_json_channel.py in __call__(self, request, metadata)
    169         params = protobuf_to_dict(request, use_integers_for_enums=False, ignore_show_empty=True)
    170 
--> 171         url, method, url_fields = _pick_proper_endpoint(self.resources, params)
    172 
    173         for url_field in url_fields:

~/anaconda3/envs/data_science_local/lib/python3.8/site-packages/clarifai_grpc/channel/grpc_json_channel.py in _pick_proper_endpoint(resources, request_dict)
    298 
    299     if not best_match_url:
--> 300         raise Exception(
    301             "You must set one case of the following fields in your request proto: "
    302             "%s" % all_fields

Exception: You must set one case of the following fields in your request proto: ['user_app_id.user_id', 'user_app_id.app_id']

The auth_metadata and user_id, and app_id works on other operation, e.g. GetInputCountRequest. So I am wondering if there a bug in this function, instead of my setting of metadata error.

Thanks,
Yeu-Chern

Increase (or remove) upper bound for protobuf requirement version

The upper bound for the protobuf dependency/requirement version is set to <=3.19.3:

"protobuf>= 3.15.6, <=3.19.3",

That release is over 10 months old now though, and the latest version is 4.21.9:
https://pypi.org/project/protobuf/#history

There are packages that have a lower bound for protobuf higher than 3.19.3 now, e.g. google-cloud-translate:
https://github.com/googleapis/python-translate/blob/998eaeeb8beabc1dd31fd017a742a890c16d5c75/setup.py#L35
causing dependency resolution conflicts when attempting to install those packages with clarifai-grpc.

I'm also not sure why this upper bound was set with #84 (and later increased with 34318b9), as the error in that PR's description should not have been due to clarifai-grpc. googleapis-common-protos 1.56.2 had the requirement protobuf<4.0.0dev,>=3.15.0 in the error, and clarifai-grpc had protobuf>=3.15.6 in its setup.py, so there shouldn't have been any conflict. It's likely that some other package was requiring a v4 of protobuf and installing v4.21.1 to cause that error. Regardless, googleapis-common-protos now allows protobuf < 5.0.0 since v1.56.3, which was released in June.

Post workflow results failed

I'm using the demographics workflow. I labeled approximately 500 images with the API before getting an error message for one image:

Exception: Post workflow results failed, status: Failure

Now, I get the error message for every image, even when trying one of the images that worked previously.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.