Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Aug 30, 2024
1 parent 98f7655 commit d6ca0e3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
7 changes: 3 additions & 4 deletions tests/e2e/default_single_streaming.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
from litserve import LitServer, LitAPI
import time
import numpy as np


class SimpleStreamingAPI(LitAPI):
def setup(self, device) -> None:
self.model = lambda x,y: x*y
self.model = lambda x, y: x * y

def decode_request(self, request):
return request["input"]
Expand All @@ -21,4 +20,4 @@ def encode_response(self, output_stream):
if __name__ == "__main__":
api = SimpleStreamingAPI()
server = LitServer(api, stream=True)
server.run(port=8000)
server.run(port=8000)
5 changes: 2 additions & 3 deletions tests/e2e/test_e2e.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,6 @@ def test_openai_parity_with_response_format():
)



@e2e_from_file("tests/e2e/default_single_streaming.py")
def test_e2e_single_streaming():
resp = requests.post("http://127.0.0.1:8000/predict", json={"input": 4.0}, headers=None, stream=True)
Expand All @@ -306,11 +305,11 @@ def test_e2e_single_streaming():
outputs = []
for line in resp.iter_lines():
if line:
outputs.append(json.loads(line.decode('utf-8')))
outputs.append(json.loads(line.decode("utf-8")))

assert len(outputs) == 3, "Expected 3 streamed outputs"
assert outputs[-1] == {"output": 12.0}, "Final output doesn't match expected value"

expected_values = [4.0, 8.0, 12.0]
for i, output in enumerate(outputs):
assert output["output"] == expected_values[i], f"Intermediate output {i} is not expected value"
assert output["output"] == expected_values[i], f"Intermediate output {i} is not expected value"

0 comments on commit d6ca0e3

Please sign in to comment.