Skip to content

Commit ac787ae

Browse files
author
Dmytro Parfeniuk
committed
Backend OpenAI tests are added
* base unit tests are added * OpenAI unit tests are added * Backend.submit with OpenaAI backend integration test is added Other changes: * `.env.example` is added as a source of a project configuration * `README.md` now has project configuring and testing small guide * `mypy` is configured in `pyproject.toml` * `Makefile` is improved * `polyfactory` package is INSTALLED for creating mock data models
1 parent 4af96de commit ac787ae

29 files changed

+652
-277
lines changed

.env.example

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# OpenAI compatible server address.
2+
# If you are going to run the
3+
OPENAI_BASE_URL=http://127.0.0.1:8080
4+
OPENAI_API_KEY=invalid

Makefile

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22
install:
33
python -m pip install -r requirements.txt
44

5+
56
.PHONY: install.dev
67
install.dev:
78
python -m pip install -e .[dev]
89

10+
911
.PHONY: build
1012
build:
1113
python setup.py sdist bdist_wheel
@@ -15,8 +17,7 @@ build:
1517
quality:
1618
python -m ruff check src tests
1719
python -m isort --check src tests
18-
python -m flake8 src tests --max-line-length 88
19-
python -m mypy src
20+
python -m mypy
2021

2122

2223
.PHONY: style
@@ -28,16 +29,19 @@ style:
2829

2930
.PHONY: test
3031
test:
31-
python -m pytest -s -vvv --cache-clear tests
32+
python -m pytest tests
33+
3234

3335
.PHONY: test.unit
3436
test.unit:
3537
python -m pytest tests/unit
3638

39+
3740
.PHONY: test.integration
3841
test.integration:
3942
python -m pytest tests/integration
4043

44+
4145
.PHONY: test.e2e
4246
test.e2e:
4347
python -m pytest tests/e2e

README.md

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,36 @@
1-
# guidellm
1+
# guidellm
2+
3+
# Project configuration
4+
5+
The project is configured with environment variables. Check the example in `.env.example`.
6+
7+
```sh
8+
# Create .env file and update the configuration
9+
cp .env.example .env
10+
11+
# Export all variables
12+
set -o allexport; source .env; set +o allexport
13+
```
14+
15+
## Environment Variables
16+
17+
| Variable | Default Value | Description |
18+
| --------------- | --------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- |
19+
| OPENAI_BASE_URL | http://127.0.0.1:8080 | The host where the `openai` library will make requests to. For running integration tests it is required to have the external OpenAI compatible server running. |
20+
| OPENAI_API_KEY | invalid | [OpenAI Platform](https://platform.openai.com/api-keys) to create a new API key. This value is not used for tests. |
21+
22+
## Running Tests
23+
24+
`pytest` package is used as a testing framework. All the tests are int he `tests/` folder.
25+
`pytest` configuration is in the `pyproject.toml`.
26+
27+
The `Makefile` includes all the necessary commands that could be run from the project root.
28+
29+
```sh
30+
# Using Makefile
31+
make test # run all the tests
32+
make test.integration # run only integration tests
33+
make test.unit # run only unit tests
34+
make test.e2e # run only E2E tests
35+
```
36+

docs/README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-
TODO

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
TODO
1+
TODO

pyproject.toml

Lines changed: 41 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,60 @@
11
[build-system]
2-
requires = ["setuptools", "wheel"]
3-
build-backend = "setuptools.build_meta"
2+
requires = ['setuptools', 'wheel']
3+
build-backend = 'setuptools.build_meta'
4+
5+
46

57
[tool.black]
68
line-length = 88
79
target-version = ['py38']
810

11+
12+
913
[tool.isort]
10-
profile = "black"
14+
profile = 'black'
15+
1116

12-
[tool.mypy]
13-
files = "src/guidellm"
1417

1518
[tool.ruff]
16-
exclude = ["build", "dist", "env", ".venv"]
19+
exclude = ['build', 'dist', 'env', '.venv']
1720
lint.select = ["E", "F", "W"]
21+
line-length = 88
22+
1823

19-
[tool.flake8]
20-
max-line-length = 88
2124

2225
[tool.pytest.ini_options]
2326
addopts = '-s -vvv --cache-clear'
2427
asyncio_mode = 'auto'
2528
markers = [
26-
"smoke: quick tests to check basic functionality",
27-
"sanity: detailed tests to ensure major functions work correctly",
28-
"regression: tests to ensure that new changes do not break existing functionality"
29+
'smoke: quick tests to check basic functionality',
30+
'sanity: detailed tests to ensure major functions work correctly',
31+
'regression: tests to ensure that new changes do not break existing functionality'
32+
]
33+
filterwarnings = [
34+
'ignore::RuntimeWarning',
35+
'ignore::UserWarning',
36+
'ignore::DeprecationWarning',
2937
]
3038

39+
40+
41+
[tool.mypy]
42+
python_version = '3.8'
43+
files = 'src/guidellm'
44+
show_error_codes = true
45+
namespace_packages = false
46+
check_untyped_defs = true
47+
48+
warn_redundant_casts = true
49+
warn_unused_ignores = true
50+
51+
# Silint "type import errors" as our 3rd-party libs does not have types
52+
# Check: https://mypy.readthedocs.io/en/latest/config_file.html#import-discovery
53+
follow_imports = 'silent'
54+
55+
[[tool.mypy.overrides]]
56+
module = ['transformers.*']
57+
ignore_missing_imports=true
58+
59+
60+

setup.py

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,51 @@
1-
from setuptools import setup, find_packages
21
from typing import Tuple
32

3+
from setuptools import find_packages, setup
4+
45

56
def _setup_long_description() -> Tuple[str, str]:
67
return open("README.md", "r", encoding="utf-8").read(), "text/markdown"
78

89

910
setup(
10-
name='guidellm',
11-
version='0.1.0',
12-
author='Neuralmagic, Inc.',
13-
description='Guidance platform for deploying and managing large language models.',
11+
name="guidellm",
12+
version="0.1.0",
13+
author="Neuralmagic, Inc.",
14+
description="Guidance platform for deploying and managing large language models.",
1415
long_description=_setup_long_description()[0],
1516
long_description_content_type=_setup_long_description()[1],
1617
license="Apache",
1718
url="https://github.com/neuralmagic/guidellm",
18-
packages=find_packages(where='src'),
19-
package_dir={'': 'src'},
19+
packages=find_packages(where="src"),
20+
package_dir={"": "src"},
2021
include_package_data=True,
2122
install_requires=[
22-
'click',
23-
'datasets',
24-
'loguru',
25-
'numpy',
26-
'openai',
27-
'requests',
28-
'transformers',
23+
"click",
24+
"datasets",
25+
"loguru",
26+
"numpy",
27+
"openai",
28+
"requests",
29+
"transformers",
2930
],
3031
extras_require={
31-
'dev': [
32-
'pytest',
33-
'sphinx',
34-
'ruff',
35-
'mypy',
36-
'black',
37-
'isort',
38-
'flake8',
39-
'pre-commit',
32+
"dev": [
33+
"black",
34+
"flake8",
35+
"isort",
36+
"mypy",
37+
"pre-commit",
38+
"pytest",
39+
"ruff",
40+
"sphinx",
4041
],
4142
},
4243
entry_points={
43-
'console_scripts': [
44-
'guidellm=guidellm.main:main',
44+
"console_scripts": [
45+
"guidellm=guidellm.main:main",
4546
],
4647
},
47-
python_requires=">=3.8.0",
48+
python_requires=">=3.8.0,<4.0",
4849
classifiers=[
4950
"Development Status :: 5 - Production/Stable",
5051
"Programming Language :: Python :: 3",

src/__init__.py

Whitespace-only changes.

src/guidellm/backend/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
from .base import Backend, BackendTypes, GenerativeResponse
1+
from .base import Backend, BackendEngine, GenerativeResponse
22
from .openai import OpenAIBackend
33

44
__all__ = [
55
"Backend",
6-
"BackendTypes",
6+
"BackendEngine",
77
"GenerativeResponse",
88
"OpenAIBackend",
99
]

0 commit comments

Comments
 (0)