binoua commited on
Commit
1977567
1 Parent(s): 4d2aaf9

chore: using a database for keys

Browse files
Files changed (2) hide show
  1. handler.py +6 -1
  2. play_with_endpoint.py +4 -0
handler.py CHANGED
@@ -1,3 +1,4 @@
 
1
  from typing import Dict, List, Any
2
  import numpy as np
3
  from concrete.ml.deployment import FHEModelServer
@@ -25,6 +26,8 @@ class EndpointHandler:
25
 
26
  self.key_database[43] = "benoit"
27
 
 
 
28
  def __call__(self, data: Dict[str, Any]) -> List[Dict[str, Any]]:
29
  """
30
  data args:
@@ -34,10 +37,12 @@ class EndpointHandler:
34
  A :obj:`list` | `dict`: will be serialized and returned
35
  """
36
 
 
 
37
  # Get method
38
  method = data.pop("method", data)
39
 
40
- if method is "save_key":
41
 
42
  # Get keys
43
  evaluation_keys = from_json(data.pop("evaluation_keys", data))
 
1
+ import time
2
  from typing import Dict, List, Any
3
  import numpy as np
4
  from concrete.ml.deployment import FHEModelServer
 
26
 
27
  self.key_database[43] = "benoit"
28
 
29
+ print(f"{time.time()}: enter in the init")
30
+
31
  def __call__(self, data: Dict[str, Any]) -> List[Dict[str, Any]]:
32
  """
33
  data args:
 
37
  A :obj:`list` | `dict`: will be serialized and returned
38
  """
39
 
40
+ print(f"{time.time()}: enter in the call")
41
+
42
  # Get method
43
  method = data.pop("method", data)
44
 
45
+ if method == "save_key":
46
 
47
  # Get keys
48
  evaluation_keys = from_json(data.pop("evaluation_keys", data))
play_with_endpoint.py CHANGED
@@ -33,6 +33,10 @@ headers = {
33
  def query(payload):
34
  response = requests.post(API_URL, headers=headers, json=payload)
35
  print(f"{response=}")
 
 
 
 
36
  print(f"{response.json()=}")
37
  return response.json()
38
 
 
33
  def query(payload):
34
  response = requests.post(API_URL, headers=headers, json=payload)
35
  print(f"{response=}")
36
+
37
+ if "error" in response:
38
+ assert False, f"Got an error: {response=}"
39
+
40
  print(f"{response.json()=}")
41
  return response.json()
42