Skip to content

Commit

Permalink
cloudvision/cvlib: Remove test code
Browse files Browse the repository at this point in the history
Remove internal test code from the cvlib library, so users won't
accidentally enable it from their environment.

Change-Id: Icc8dea0ec25f4ac433ab1c89b764cf97c3de67d1
  • Loading branch information
gingerbus committed Nov 9, 2023
1 parent e0d86cb commit 0c0a3da
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 27 deletions.
2 changes: 1 addition & 1 deletion cloudvision/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@

__path__ = __import__('pkgutil').extend_path(__path__, __name__) # type: ignore # mypy issue #1422

__version__ = "1.14.1"
__version__ = "1.14.2"
2 changes: 1 addition & 1 deletion cloudvision/cvlib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@
from .user import User
from .workspace import Workspace

__version__ = "1.6.0"
__version__ = "1.6.1"
27 changes: 2 additions & 25 deletions cloudvision/cvlib/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,13 +167,6 @@ def getCvClient(self):
based on the current user auth token
:return: cloudvision Connector client
'''
# Use test api addresses for client if they were set
if self.connections.testAddresses:
testAddr = self.connections.testAddresses.get("apiServer")
if not testAddr:
return None
return GRPCClient(testAddr)

if self.__connector:
return self.__connector
if self.connections.apiserverAddr is None or self.user is None:
Expand All @@ -191,30 +184,14 @@ def getApiClient(self, stub):
:param: stub of the resource api to connect to
:return: resource api client to the passed stub
'''
def add_user_context(chann, default_org=False):
def add_user_context(chann):
# If provided, add the user context to the grpc metadata
# This allows the context to access services correctly
if self.user is not None:
username_interceptor = addHeaderInterceptor(USERNAME, self.user.username)
if default_org:
dataset_interceptor = addHeaderInterceptor(DATASET_TYPE, 'user')
org_interceptor = addHeaderInterceptor(ORGANIZATION, 'Default')
chann = grpc.intercept_channel(chann, username_interceptor,
dataset_interceptor, org_interceptor)
else:
chann = grpc.intercept_channel(chann, username_interceptor)
chann = grpc.intercept_channel(chann, username_interceptor)
return chann

# Use test api addresses for client if they were set
if self.connections.testAddresses:
testAddr = self.connections.testAddresses.get(stub.__name__)
if not testAddr:
return None
chann = grpc.insecure_channel(testAddr)
chann = add_user_context(chann, default_org=True)
stubChann = stub(chann)
return stubChann

if self.__serviceChann:
return stub(self.__serviceChann)
if self.connections.serviceAddr is None:
Expand Down

0 comments on commit 0c0a3da

Please sign in to comment.