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 Sep 25, 2024
1 parent 0eb5e5d commit 353b0fc
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions tests/test_batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,19 +151,25 @@ def test_max_batch_size_warning():
def test_check_predict_output_warnings():
api = SimpleBatchLitAPI()
api.predict = MagicMock(return_value="This is a string")

mock_input = torch.tensor([[1.0], [2.0]])

with pytest.warns(UserWarning, match="The 'predict' method returned a string instead of a list of predictions. "
"When batching is enabled, 'predict' should return a list of predictions. "
"To avoid unexpected behavior, ensure 'predict' returns a list of predictions, or implement 'LitAPI.unbatch' correctly."):

with pytest.warns(
UserWarning,
match="The 'predict' method returned a string instead of a list of predictions. "
"When batching is enabled, 'predict' should return a list of predictions. "
"To avoid unexpected behavior, ensure 'predict' returns a list of predictions, or implement 'LitAPI.unbatch' correctly.",
):
# Simulate the behavior in run_batched_loop
y = api.predict(mock_input)
if isinstance(y, str):
import warnings
warnings.warn("The 'predict' method returned a string instead of a list of predictions. "
"When batching is enabled, 'predict' should return a list of predictions. "
"To avoid unexpected behavior, ensure 'predict' returns a list of predictions, or implement 'LitAPI.unbatch' correctly.")

warnings.warn(
"The 'predict' method returned a string instead of a list of predictions. "
"When batching is enabled, 'predict' should return a list of predictions. "
"To avoid unexpected behavior, ensure 'predict' returns a list of predictions, or implement 'LitAPI.unbatch' correctly."
)


class FakeResponseQueue:
Expand Down

0 comments on commit 353b0fc

Please sign in to comment.