Skip to content

Commit

Permalink
chore: adjust model manager test sleep delay
Browse files Browse the repository at this point in the history
  • Loading branch information
Fedir Zadniprovskyi authored and fedirz committed Dec 21, 2024
1 parent e08453d commit 1a97aa0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/faster_whisper_server/api_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
10 changes: 5 additions & 5 deletions tests/model_manager_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand All @@ -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

Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 1a97aa0

Please sign in to comment.