Skip to content

Commit cbed4cb

Browse files
patricklundquistsrikanthbachala20
authored andcommitted
[EAGLE-6460]: Add func to return both stub and channel. (#713)
* Add func to return both stub and channel. * tidy
1 parent 4f32151 commit cbed4cb

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

clarifai/client/auth/helper.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import urllib.request
33
from typing import Any, Dict
44

5+
import grpc
56
from clarifai_grpc.channel.clarifai_channel import ClarifaiChannel
67
from clarifai_grpc.grpc.api import resources_pb2, service_pb2_grpc
78

@@ -289,7 +290,11 @@ def metadata(self):
289290
)
290291

291292
def get_stub(self) -> service_pb2_grpc.V2Stub:
292-
"""Get the API gRPC stub using the right channel based on the API endpoint base.
293+
stub, channel = self.get_stub_and_channel()
294+
return stub
295+
296+
def get_stub_and_channel(self) -> tuple[service_pb2_grpc.V2Stub, grpc.Channel]:
297+
"""Get the API gRPC stub and channel based on the API endpoint base.
293298
294299
Returns:
295300
stub: The service_pb2_grpc.V2Stub stub for the API.
@@ -310,7 +315,7 @@ def get_stub(self) -> service_pb2_grpc.V2Stub:
310315
port = 80
311316
channel = ClarifaiChannel.get_insecure_grpc_channel(base=host, port=port)
312317
stub = service_pb2_grpc.V2Stub(channel)
313-
return stub
318+
return stub, channel
314319

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

0 commit comments

Comments
 (0)