Clarifai / clarifai-python-grpc

Clarifai gRPC Python API client
https://docs.clarifai.com
Other
56 stars 20 forks source link

Stub is not defined #145

Open rperdon opened 1 year ago

rperdon commented 1 year ago

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

excaliburne commented 1 year ago

Hey,

What code are you trying to run? Could you past the snippet here?

It simply looks like you haven't defined "stub" in a variable as outlined in the docs, e.g:

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_code_pb2

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

metadata = (('authorization', 'Key ' + PAT),)

userDataObject = resources_pb2.UserAppIDSet(user_id=USER_ID, app_id=APP_ID)

post_inputs_response = stub.PostInputs(