Skip to content

[EAGLE-6460]: Add func to return both stub and channel. #713

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 22, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions clarifai/client/auth/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import urllib.request
from typing import Any, Dict

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

Expand Down Expand Up @@ -289,7 +290,11 @@ def metadata(self):
)

def get_stub(self) -> service_pb2_grpc.V2Stub:
"""Get the API gRPC stub using the right channel based on the API endpoint base.
stub, channel = self.get_stub_and_channel()
return stub

def get_stub_and_channel(self) -> tuple[service_pb2_grpc.V2Stub, grpc.Channel]:
"""Get the API gRPC stub and channel based on the API endpoint base.

Returns:
stub: The service_pb2_grpc.V2Stub stub for the API.
Expand All @@ -310,7 +315,7 @@ def get_stub(self) -> service_pb2_grpc.V2Stub:
port = 80
channel = ClarifaiChannel.get_insecure_grpc_channel(base=host, port=port)
stub = service_pb2_grpc.V2Stub(channel)
return stub
return stub, channel

def get_async_stub(self) -> service_pb2_grpc.V2Stub:
"""Get the API gRPC async stub using the right channel based on the API endpoint base.
Expand Down
Loading