From 196f56a92d473e17b393924e2d9d2f983dadac63 Mon Sep 17 00:00:00 2001 From: Fedir Zadniprovskyi Date: Sat, 21 Dec 2024 13:40:20 -0800 Subject: [PATCH] chore: adjust model manager test sleep delay --- src/faster_whisper_server/api_models.py | 2 +- tests/model_manager_test.py | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/faster_whisper_server/api_models.py b/src/faster_whisper_server/api_models.py index eed71ea7..1bd75e8d 100644 --- a/src/faster_whisper_server/api_models.py +++ b/src/faster_whisper_server/api_models.py @@ -69,7 +69,7 @@ def from_faster_whisper_segments( end=segment.end, text=segment.text, tokens=segment.tokens, - temperature=segment.temperature, + temperature=segment.temperature or 0, # FIX: hardcoded avg_logprob=segment.avg_logprob, compression_ratio=segment.compression_ratio, no_speech_prob=segment.no_speech_prob, diff --git a/tests/model_manager_test.py b/tests/model_manager_test.py index 52cb1468..e05b1f3b 100644 --- a/tests/model_manager_test.py +++ b/tests/model_manager_test.py @@ -20,7 +20,7 @@ async def test_model_unloaded_after_ttl() -> None: await aclient.post(f"/api/ps/{model}") res = (await aclient.get("/api/ps")).json() assert len(res["models"]) == 1 - await asyncio.sleep(ttl + 1) + await asyncio.sleep(ttl + 1) # wait for the model to be unloaded res = (await aclient.get("/api/ps")).json() assert len(res["models"]) == 0 @@ -35,7 +35,7 @@ async def test_ttl_resets_after_usage() -> None: await aclient.post(f"/api/ps/{model}") res = (await aclient.get("/api/ps")).json() assert len(res["models"]) == 1 - await asyncio.sleep(ttl - 2) + await asyncio.sleep(ttl - 2) # sleep for less than the ttl. The model should not be unloaded res = (await aclient.get("/api/ps")).json() assert len(res["models"]) == 1 @@ -48,11 +48,11 @@ async def test_ttl_resets_after_usage() -> None: ).json() res = (await aclient.get("/api/ps")).json() assert len(res["models"]) == 1 - await asyncio.sleep(ttl - 2) + await asyncio.sleep(ttl - 2) # sleep for less than the ttl. The model should not be unloaded res = (await aclient.get("/api/ps")).json() assert len(res["models"]) == 1 - await asyncio.sleep(3) + await asyncio.sleep(3) # sleep for a bit more. The model should be unloaded res = (await aclient.get("/api/ps")).json() assert len(res["models"]) == 0 @@ -80,7 +80,7 @@ async def test_model_cant_be_unloaded_when_used() -> None: "/v1/audio/transcriptions", files={"file": ("audio.wav", data, "audio/wav")}, data={"model": model} ) ) - await asyncio.sleep(0.01) + await asyncio.sleep(0.1) # wait for the server to start processing the request res = await aclient.delete(f"/api/ps/{model}") assert res.status_code == 409