diff --git a/aperturedb/ConnectorRest.py b/aperturedb/ConnectorRest.py index 803ab733..c3231234 100644 --- a/aperturedb/ConnectorRest.py +++ b/aperturedb/ConnectorRest.py @@ -33,6 +33,11 @@ from types import SimpleNamespace from typing import Optional +try: + import pybase64 as base64 +except ImportError: + import base64 + from aperturedb.Connector import Connector from aperturedb.Configuration import Configuration from requests.adapters import HTTPAdapter @@ -164,8 +169,10 @@ def _query(self, query, blob_array = [], try_resume=True): verify = self.config.use_ssl and self.config.verify_hostname) if response.status_code == 200: # Parse response: - json_response = json.loads(response.text) - import base64 + if hasattr(response, "json"): + json_response = response.json() + else: + json_response = json.loads(response.text) response_blob_array = [base64.b64decode( b) for b in json_response['blobs']] self.last_response = json_response["json"] diff --git a/pyproject.toml b/pyproject.toml index de914ca0..e6c8f2eb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -40,6 +40,9 @@ aperturedb = "aperturedb" "Bug Reports" = "https://github.com/aperture-data/aperturedb-python/issues" [project.optional-dependencies] +speedups = [ + "pybase64", +] # This is used when we build the docker image for notebook notebook = [ "torch",