Skip to content

Commit 2287517

Browse files
committed
Fixes for pip install, rename classes to standardize for requests and responses, restructure tests and begin working to get them passing
1 parent 297d480 commit 2287517

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+1309
-1445
lines changed

Makefile

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
install:
2+
pip install -r requirements.txt
3+
4+
install-dev:
5+
pip install -e .[dev]
6+
7+
quality:
8+
ruff check src tests
9+
isort --check-only src tests
10+
flake8 src tests --max-line-length 88
11+
mypy src
12+
13+
style:
14+
ruff format src tests
15+
isort src tests
16+
flake8 src tests --max-line-length 88
17+
18+
# test:
19+
# pytest tests
20+
21+
build:
22+
python setup.py sdist bdist_wheel
23+
24+
clean:
25+
rm -rf __pycache__
26+
rm -rf build
27+
rm -rf dist
28+
rm -rf *.egg-info
29+
find . -type f -name "*.pyc" -delete
30+
find . -type d -name "__pycache__" -exec rm -r {} +
31+
rm -rf .mypy_cache
32+
rm -rf .pytest_cache
33+
34+
.PHONY: install install-dev quality style test test-unit test-integration test-e2e test-smoke test-sanity test-regression build clean

pyproject.toml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
[build-system]
2+
requires = ["setuptools", "wheel"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[tool.black]
6+
line-length = 88
7+
target-version = ['py38']
8+
9+
[tool.isort]
10+
profile = "black"
11+
12+
[tool.mypy]
13+
files = "src/guidellm"
14+
15+
[tool.ruff]
16+
exclude = ["build", "dist", "env", ".venv"]
17+
lint.select = ["E", "F", "W"]
18+
19+
[tool.flake8]
20+
max-line-length = 88
21+
22+
[tool.pytest.ini_options]
23+
markers = [
24+
"smoke: quick tests to check basic functionality",
25+
"sanity: detailed tests to ensure major functions work correctly",
26+
"regression: tests to ensure that new changes do not break existing functionality"
27+
]
28+

setup.py

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
from setuptools import setup, find_packages
2+
from typing import Tuple
3+
4+
5+
def _setup_long_description() -> Tuple[str, str]:
6+
return open("README.md", "r", encoding="utf-8").read(), "text/markdown"
7+
8+
9+
setup(
10+
name='guidellm',
11+
version='0.1.0',
12+
author='Neuralmagic, Inc.',
13+
description='Guidance platform for deploying and managing large language models.',
14+
long_description=_setup_long_description()[0],
15+
long_description_content_type=_setup_long_description()[1],
16+
license="Apache",
17+
url="https://github.com/neuralmagic/guidellm",
18+
packages=find_packages(where='src'),
19+
package_dir={'': 'src'},
20+
include_package_data=True,
21+
install_requires=[
22+
'datasets',
23+
'loguru',
24+
'numpy',
25+
'openai',
26+
'requests',
27+
'transformers',
28+
],
29+
extras_require={
30+
'dev': [
31+
'pytest',
32+
'sphinx',
33+
'ruff',
34+
'mypy',
35+
'black',
36+
'isort',
37+
'flake8',
38+
'pre-commit',
39+
],
40+
},
41+
entry_points={
42+
'console_scripts': [
43+
'guidellm=guidellm.main:main',
44+
],
45+
},
46+
python_requires=">=3.8.0",
47+
classifiers=[
48+
"Development Status :: 5 - Production/Stable",
49+
"Programming Language :: Python :: 3",
50+
"Programming Language :: Python :: 3 :: Only",
51+
"Intended Audience :: Developers",
52+
"Intended Audience :: Education",
53+
"Intended Audience :: Information Technology",
54+
"Intended Audience :: Science/Research",
55+
"License :: OSI Approved :: Apache Software License",
56+
"Operating System :: POSIX :: Linux",
57+
"Topic :: Scientific/Engineering",
58+
"Topic :: Scientific/Engineering :: Artificial Intelligence",
59+
"Topic :: Scientific/Engineering :: Mathematics",
60+
"Topic :: Software Development",
61+
"Topic :: Software Development :: Libraries :: Python Modules",
62+
],
63+
)

src/guidellm/backend/__init__.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,9 @@
1-
from .base import *
2-
from .openai import *
1+
from .base import Backend, BackendTypes, GenerativeResponse
2+
from .openai import OpenAIBackend
3+
4+
__all__ = [
5+
"Backend",
6+
"BackendTypes",
7+
"GenerativeResponse",
8+
"OpenAIBackend",
9+
]

src/guidellm/backend/base.py

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1+
import uuid
12
from abc import ABC, abstractmethod
3+
from dataclasses import dataclass
24
from enum import Enum
35
from typing import Iterator, List, Optional, Type, Union
4-
from dataclasses import dataclass
5-
import uuid
6+
67
from loguru import logger
7-
from guidellm.core.result import BenchmarkResult
8-
from guidellm.core.request import BenchmarkRequest
8+
9+
from guidellm.core.request import TextGenerationRequest
10+
from guidellm.core.result import TextGenerationResult
911

1012
__all__ = ["Backend", "BackendTypes", "GenerativeResponse"]
1113

@@ -69,18 +71,18 @@ def create_backend(backend_type: Union[str, BackendTypes], **kwargs) -> "Backend
6971
raise ValueError(f"Unsupported backend type: {backend_type}")
7072
return Backend._registry[backend_type](**kwargs)
7173

72-
def submit(self, request: BenchmarkRequest) -> BenchmarkResult:
74+
def submit(self, request: TextGenerationRequest) -> TextGenerationResult:
7375
"""
74-
Submit a benchmark request and populate the BenchmarkResult.
76+
Submit a result request and populate the BenchmarkResult.
7577
76-
:param request: The benchmark request to submit.
77-
:type request: BenchmarkRequest
78-
:return: The populated benchmark result.
79-
:rtype: BenchmarkResult
78+
:param request: The result request to submit.
79+
:type request: TextGenerationRequest
80+
:return: The populated result result.
81+
:rtype: TextGenerationResult
8082
"""
8183
logger.info(f"Submitting request with prompt: {request.prompt}")
8284
result_id = str(uuid.uuid4())
83-
result = BenchmarkResult(result_id)
85+
result = TextGenerationResult(result_id)
8486
result.start(request.prompt)
8587

8688
for response in self.make_request(request):
@@ -98,12 +100,14 @@ def submit(self, request: BenchmarkRequest) -> BenchmarkResult:
98100
return result
99101

100102
@abstractmethod
101-
def make_request(self, request: BenchmarkRequest) -> Iterator[GenerativeResponse]:
103+
def make_request(
104+
self, request: TextGenerationRequest
105+
) -> Iterator[GenerativeResponse]:
102106
"""
103107
Abstract method to make a request to the backend.
104108
105-
:param request: The benchmark request to submit.
106-
:type request: BenchmarkRequest
109+
:param request: The result request to submit.
110+
:type request: TextGenerationRequest
107111
:return: An iterator over the generative responses.
108112
:rtype: Iterator[GenerativeResponse]
109113
"""

src/guidellm/backend/openai.py

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
1+
from typing import Any, Iterator, List, Optional
2+
13
import openai
2-
from typing import Iterator, List, Optional, Dict, Any
3-
from transformers import AutoTokenizer
44
from loguru import logger
5+
from transformers import AutoTokenizer
6+
57
from guidellm.backend import Backend, BackendTypes, GenerativeResponse
6-
from guidellm.core.request import BenchmarkRequest
8+
from guidellm.core.request import TextGenerationRequest
79

810
__all__ = ["OpenAIBackend"]
911

1012

1113
@Backend.register_backend(BackendTypes.OPENAI_SERVER)
1214
class OpenAIBackend(Backend):
1315
"""
14-
An OpenAI backend implementation for the generative AI benchmark.
16+
An OpenAI backend implementation for the generative AI result.
1517
1618
:param target: The target URL string for the OpenAI server.
1719
:type target: str
@@ -58,15 +60,18 @@ def __init__(
5860
self.model = self.default_model()
5961

6062
logger.info(
61-
f"Initialized OpenAIBackend with target: {self.target} and model: {self.model}"
63+
f"Initialized OpenAIBackend with target: {self.target} "
64+
f"and model: {self.model}"
6265
)
6366

64-
def make_request(self, request: BenchmarkRequest) -> Iterator[GenerativeResponse]:
67+
def make_request(
68+
self, request: TextGenerationRequest
69+
) -> Iterator[GenerativeResponse]:
6570
"""
6671
Make a request to the OpenAI backend.
6772
68-
:param request: The benchmark request to submit.
69-
:type request: BenchmarkRequest
73+
:param request: The result request to submit.
74+
:type request: TextGenerationRequest
7075
:return: An iterator over the generative responses.
7176
:rtype: Iterator[GenerativeResponse]
7277
"""
@@ -84,7 +89,10 @@ def make_request(self, request: BenchmarkRequest) -> Iterator[GenerativeResponse
8489
request_args.update(self.request_args)
8590

8691
response = openai.Completion.create(
87-
engine=self.model, prompt=request.prompt, stream=True, **request_args,
92+
engine=self.model,
93+
prompt=request.prompt,
94+
stream=True,
95+
**request_args,
8896
)
8997

9098
for chunk in response:

src/guidellm/core/__init__.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1-
from .distribution import *
2-
from .request import *
3-
from .result import *
1+
from .distribution import Distribution
2+
from .request import TextGenerationRequest
3+
from .result import (
4+
RequestConcurrencyMeasurement,
5+
TextGenerationBenchmark,
6+
TextGenerationBenchmarkReport,
7+
TextGenerationError,
8+
TextGenerationResult,
9+
)
10+
11+
__all__ = [
12+
"Distribution",
13+
"TextGenerationRequest",
14+
"TextGenerationResult",
15+
"TextGenerationError",
16+
"TextGenerationBenchmark",
17+
"TextGenerationBenchmarkReport",
18+
"RequestConcurrencyMeasurement",
19+
]

0 commit comments

Comments
 (0)