Skip to content

Commit

Permalink
dont fail on init if fd unavailable
Browse files Browse the repository at this point in the history
Signed-off-by: Praneeth Bedapudi <[email protected]>
  • Loading branch information
bedapudi6788 committed Nov 4, 2024
1 parent 0092489 commit 106f33a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
25 changes: 16 additions & 9 deletions clients/python/fdclient/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,19 @@ def __init__(self, server_url, request_timeout, compression=True):
self.local_storage = threading.local()
self.requests_session = requests.Session()
self.compression = compression if zstandard is not None else False
self.input_type = (
"pickle"
if self.requests_session.get(
f"{self.server_url}/meta", params={"is_pickle_allowed": ""}
).json()["is_pickle_allowed"]
else "msgpack"
if msgpack is not None
else "json"
)
try:
self.input_type = (
"pickle"
if self.requests_session.get(
f"{self.server_url}/meta", params={"is_pickle_allowed": ""}
).json()["is_pickle_allowed"]
else "msgpack"
if msgpack is not None
else "json"
)
except Exception as e:
self.input_type = None

self.request_timeout = request_timeout

@property
Expand Down Expand Up @@ -74,6 +78,9 @@ def _decompressor(self):
return self.local_storage.decompressor

def infer(self, data, unique_id=None, is_async=False):
if self.input_type is None:
raise ValueError("Could not connect to server")

assert isinstance(data, (list, tuple)), "Data must be of type list or tuple"

unique_id = str(uuid.uuid4()) if not unique_id else unique_id
Expand Down
2 changes: 1 addition & 1 deletion clients/python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
EMAIL = "[email protected]"
AUTHOR = "BEDAPUDI PRANEETH"
REQUIRES_PYTHON = ">=3.6.0"
VERSION = "3.0.8"
VERSION = "3.0.9"

# What packages are required for this module to be executed?
REQUIRED = ["zstandard", "requests", "msgpack"]
Expand Down

0 comments on commit 106f33a

Please sign in to comment.