test_basic.py 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. from http import HTTPStatus
  2. import openai
  3. import pytest
  4. import requests
  5. from aphrodite.version import __version__ as APHRODITE_VERSION
  6. from ...utils import RemoteOpenAIServer
  7. MODEL_NAME = "HuggingFaceH4/zephyr-7b-beta"
  8. @pytest.fixture(scope="module")
  9. def server():
  10. args = [
  11. # use half precision for speed and memory savings in CI environment
  12. "--dtype",
  13. "bfloat16",
  14. "--max-model-len",
  15. "8192",
  16. "--enforce-eager",
  17. "--max-num-seqs",
  18. "128",
  19. ]
  20. with RemoteOpenAIServer(MODEL_NAME, args) as remote_server:
  21. yield remote_server
  22. @pytest.fixture(scope="module")
  23. def client(server):
  24. return server.get_async_client()
  25. @pytest.mark.asyncio
  26. async def test_show_version(client: openai.AsyncOpenAI):
  27. base_url = str(client.base_url)[:-3].strip("/")
  28. response = requests.get(base_url + "/version")
  29. response.raise_for_status()
  30. assert response.json() == {"version": APHRODITE_VERSION}
  31. @pytest.mark.asyncio
  32. async def test_check_health(client: openai.AsyncOpenAI):
  33. base_url = str(client.base_url)[:-3].strip("/")
  34. response = requests.get(base_url + "/health")
  35. assert response.status_code == HTTPStatus.OK