From 0580ba95987908161b98903f4f7525b695037c3d Mon Sep 17 00:00:00 2001 From: Aaron Peddle Date: Wed, 25 Oct 2023 09:44:22 -0700 Subject: [PATCH 1/2] fix warmup deadlock in cherry --- potassium/potassium.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/potassium/potassium.py b/potassium/potassium.py index 92c3dc7..2b57e0b 100644 --- a/potassium/potassium.py +++ b/potassium/potassium.py @@ -225,6 +225,7 @@ def _create_flask_app(self): def handle(path): with self._sequence_number_lock: self._sequence_number += 1 + route = "/" + path if route not in self._endpoints: abort(404) @@ -234,6 +235,8 @@ def handle(path): @flask_app.route('/_k/warmup', methods=["POST"]) def warm(): + with self._sequence_number_lock: + self._sequence_number += 1 res = make_response({ "warm": True, }) From 75900447c43d961df3899dc5cc1d4c35aae6e355 Mon Sep 17 00:00:00 2001 From: Aaron Peddle Date: Wed, 25 Oct 2023 09:46:36 -0700 Subject: [PATCH 2/2] add tests --- setup.py | 2 +- tests/test_endpoints.py | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 1020912..9b49edd 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ setup( name='potassium', packages=['potassium'], - version='0.3.1', + version='0.3.2', license='Apache License 2.0', # Give a short description about your library description='The potassium package is a flask-like HTTP server for serving large AI models', diff --git a/tests/test_endpoints.py b/tests/test_endpoints.py index 7ac4418..f54b198 100644 --- a/tests/test_endpoints.py +++ b/tests/test_endpoints.py @@ -208,3 +208,9 @@ def handler(context: dict, request: potassium.Request) -> potassium.Response: res = client.post("/_k/warmup", json={}) assert res.status_code == 200 assert res.json == {"warm": True} + + res = client.get("/__status__", json={}) + assert res.status_code == 200 + assert res.json is not None + assert res.json["gpu_available"] == True + assert res.json["sequence_number"] == 1