Skip to content

Commit

Permalink
fix: remove unused import
Browse files Browse the repository at this point in the history
  • Loading branch information
ZiniuYu committed Jul 13, 2022
1 parent da89d09 commit ef7c9bd
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions client/clip_client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
from urllib.parse import urlparse
from functools import partial
from docarray import DocumentArray
from clip_client.helper import get_authorization

if TYPE_CHECKING:
import numpy as np
Expand Down Expand Up @@ -48,7 +47,7 @@ def __init__(self, server: str, credential: dict = {}, **kwargs):
self._scheme = 'websocket' # temp fix for the core
if credential:
raise ValueError(
'credential is not supported for websocket, please use grpc or http'
'Credential is not supported for websocket, please use grpc or http'
)

if self._scheme in ('grpc', 'http', 'websocket'):
Expand All @@ -61,7 +60,7 @@ def __init__(self, server: str, credential: dict = {}, **kwargs):
else:
raise ValueError(f'{server} is not a valid scheme')

self.authorization = credential.get('Authorization', None)
self._authorization = credential.get('Authorization', None)

@overload
def encode(
Expand Down Expand Up @@ -192,10 +191,10 @@ def _get_post_payload(self, content, kwargs):
request_size=kwargs.get('batch_size', 8),
total_docs=len(content) if hasattr(content, '__len__') else None,
)
if self._scheme == 'grpc' and self.authorization:
payload.update(metadata=('Authorization', self.authorization))
elif self._scheme == 'http' and self.authorization:
payload.update(headers={'Authorization': self.authorization})
if self._scheme == 'grpc' and self._authorization:
payload.update(metadata=('Authorization', self._authorization))
elif self._scheme == 'http' and self._authorization:
payload.update(headers={'Authorization': self._authorization})
return payload

def profile(self, content: Optional[str] = '') -> Dict[str, float]:
Expand Down Expand Up @@ -373,10 +372,10 @@ def _get_rank_payload(self, content, kwargs):
request_size=kwargs.get('batch_size', 8),
total_docs=len(content) if hasattr(content, '__len__') else None,
)
if self._scheme == 'grpc' and self.authorization:
payload.update(metadata=('Authorization', self.authorization))
elif self._scheme == 'http' and self.authorization:
payload.update(headers={'Authorization': self.authorization})
if self._scheme == 'grpc' and self._authorization:
payload.update(metadata=('Authorization', self._authorization))
elif self._scheme == 'http' and self._authorization:
payload.update(headers={'Authorization': self._authorization})
return payload

def rank(self, docs: Iterable['Document'], **kwargs) -> 'DocumentArray':
Expand Down

0 comments on commit ef7c9bd

Please sign in to comment.