-
Notifications
You must be signed in to change notification settings - Fork 155
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* threaded uvicorn run * update * clean * update * fixes * update * MP * format * single queue * fix tests * fix tests * remove uvloop import * auto loop * format * formatting * remove uvloop * fix test * wrap ls start * update * fixes * fix host * downgrade numpy * fix windows * Update test.txt Co-authored-by: Jirka Borovec <[email protected]> * Update src/litserve/server.py * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: Jirka Borovec <[email protected]> Co-authored-by: Luca Antiga <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
- Loading branch information
1 parent
4d5d146
commit ba1f692
Showing
15 changed files
with
396 additions
and
298 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,3 +11,4 @@ lightning >2.0.0 | |
torch >2.0.0 | ||
transformers | ||
openai>=1.12.0 | ||
numpy <2.0 |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,35 @@ | ||
import pytest | ||
from asgi_lifespan import LifespanManager | ||
from httpx import AsyncClient | ||
|
||
from tests.conftest import wrap_litserve_start | ||
import litserve as ls | ||
|
||
|
||
@pytest.mark.asyncio() | ||
async def test_simple_pytorch_api(): | ||
api = ls.examples.SimpleTorchAPI() | ||
server = ls.LitServer(api, accelerator="cpu") | ||
async with LifespanManager(server.app) as manager, AsyncClient(app=manager.app, base_url="http://test") as ac: | ||
response = await ac.post("/predict", json={"input": 4.0}) | ||
assert response.json() == {"output": 9.0} | ||
with wrap_litserve_start(server) as server: | ||
async with LifespanManager(server.app) as manager, AsyncClient(app=manager.app, base_url="http://test") as ac: | ||
response = await ac.post("/predict", json={"input": 4.0}) | ||
assert response.json() == {"output": 9.0} | ||
|
||
|
||
@pytest.mark.asyncio() | ||
async def test_simple_batched_api(): | ||
api = ls.examples.SimpleBatchedAPI() | ||
server = ls.LitServer(api, max_batch_size=4, batch_timeout=0.1) | ||
async with LifespanManager(server.app) as manager, AsyncClient(app=manager.app, base_url="http://test") as ac: | ||
response = await ac.post("/predict", json={"input": 4.0}) | ||
assert response.json() == {"output": 16.0} | ||
with wrap_litserve_start(server) as server: | ||
async with LifespanManager(server.app) as manager, AsyncClient(app=manager.app, base_url="http://test") as ac: | ||
response = await ac.post("/predict", json={"input": 4.0}) | ||
assert response.json() == {"output": 16.0} | ||
|
||
|
||
@pytest.mark.asyncio() | ||
async def test_simple_api(): | ||
api = ls.examples.SimpleLitAPI() | ||
server = ls.LitServer(api) | ||
async with LifespanManager(server.app) as manager, AsyncClient(app=manager.app, base_url="http://test") as ac: | ||
response = await ac.post("/predict", json={"input": 4.0}) | ||
assert response.json() == {"output": 16.0} | ||
with wrap_litserve_start(server) as server: | ||
async with LifespanManager(server.app) as manager, AsyncClient(app=manager.app, base_url="http://test") as ac: | ||
response = await ac.post("/predict", json={"input": 4.0}) | ||
assert response.json() == {"output": 16.0} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.