chore: using a database for keys
Browse files- play_with_endpoint.py +4 -3
play_with_endpoint.py
CHANGED
@@ -32,12 +32,10 @@ headers = {
|
|
32 |
|
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 |
|
43 |
|
@@ -59,7 +57,7 @@ payload = {
|
|
59 |
"method": "save_key",
|
60 |
}
|
61 |
|
62 |
-
uid = query(payload)
|
63 |
print(f"Storing the key in the database under {uid=}")
|
64 |
|
65 |
# Test the handler
|
@@ -82,6 +80,9 @@ for i in range(nb_samples):
|
|
82 |
"uid": uid,
|
83 |
}
|
84 |
|
|
|
|
|
|
|
85 |
# Run the inference on HF servers
|
86 |
duration -= time.time()
|
87 |
duration_inference = -time.time()
|
|
|
32 |
|
33 |
def query(payload):
|
34 |
response = requests.post(API_URL, headers=headers, json=payload)
|
|
|
35 |
|
36 |
if "error" in response:
|
37 |
assert False, f"Got an error: {response=}"
|
38 |
|
|
|
39 |
return response.json()
|
40 |
|
41 |
|
|
|
57 |
"method": "save_key",
|
58 |
}
|
59 |
|
60 |
+
uid = query(payload)["uid"]
|
61 |
print(f"Storing the key in the database under {uid=}")
|
62 |
|
63 |
# Test the handler
|
|
|
80 |
"uid": uid,
|
81 |
}
|
82 |
|
83 |
+
if verbose or True:
|
84 |
+
print(f"Size of the payload: {sys.getsizeof(payload) / 1024} kilobytes")
|
85 |
+
|
86 |
# Run the inference on HF servers
|
87 |
duration -= time.time()
|
88 |
duration_inference = -time.time()
|