From 106f33a9e904f25dd735ab55c0afdc43f4e1759e Mon Sep 17 00:00:00 2001 From: Praneeth Bedapudi Date: Mon, 4 Nov 2024 11:17:01 +0530 Subject: [PATCH] dont fail on init if fd unavailable Signed-off-by: Praneeth Bedapudi --- clients/python/fdclient/client.py | 25 ++++++++++++++++--------- clients/python/setup.py | 2 +- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/clients/python/fdclient/client.py b/clients/python/fdclient/client.py index aa3a833..967804b 100644 --- a/clients/python/fdclient/client.py +++ b/clients/python/fdclient/client.py @@ -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 @@ -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 diff --git a/clients/python/setup.py b/clients/python/setup.py index 020a3b5..fb0db2c 100644 --- a/clients/python/setup.py +++ b/clients/python/setup.py @@ -18,7 +18,7 @@ EMAIL = "praneeth@bpraneeth.com" 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"]