Skip to content

Commit b6da6bc

Browse files
author
Dmytro Parfeniuk
committed
🚧 WIP
1 parent 4af96de commit b6da6bc

File tree

9 files changed

+214
-117
lines changed

9 files changed

+214
-117
lines changed

.github/workflows/ci.yml

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,23 @@
1-
TODO
1+
name: Code Quality Check
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
8+
jobs:
9+
code_quality:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- uses: actions/checkout@v4
14+
- uses: actions/setup-python@v5
15+
16+
- name: Install dependencies
17+
run: |
18+
python -m pip install --upgrade pip
19+
pip install tox
20+
21+
- name: Run tox
22+
run: tox
23+

Makefile

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,59 @@
11
.PHONY: install
22
install:
3-
python -m pip install -r requirements.txt
3+
python -m pip install .
4+
45

56
.PHONY: install.dev
67
install.dev:
7-
python -m pip install -e .[dev]
8+
python -m pip install .[dev]
9+
810

911
.PHONY: build
1012
build:
1113
python setup.py sdist bdist_wheel
1214

15+
.PHONY: style
16+
style:
17+
python -m ruff format src tests
18+
python -m isort src tests
19+
python -m flake8 src tests --max-line-length 88
20+
21+
22+
.PHONY: types
23+
types:
24+
python -m mypy --check-untyped-defs
25+
1326

1427
.PHONY: quality
1528
quality:
1629
python -m ruff check src tests
30+
python -m black --check src tests
1731
python -m isort --check src tests
18-
python -m flake8 src tests --max-line-length 88
19-
python -m mypy src
32+
python -m mypy --check-untyped-defs
2033

2134

22-
.PHONY: style
23-
style:
24-
python -m ruff format src tests
25-
python -m isort src tests
26-
python -m flake8 src tests --max-line-length 88
27-
2835

2936
.PHONY: test
3037
test:
3138
python -m pytest -s -vvv --cache-clear tests
3239

40+
3341
.PHONY: test.unit
3442
test.unit:
3543
python -m pytest tests/unit
3644

45+
3746
.PHONY: test.integration
3847
test.integration:
3948
python -m pytest tests/integration
4049

50+
4151
.PHONY: test.e2e
4252
test.e2e:
4353
python -m pytest tests/e2e
4454

4555

56+
4657
.PHONY: clean
4758
clean:
4859
rm -rf build

pyproject.toml

Lines changed: 74 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,94 @@
22
requires = ["setuptools", "wheel"]
33
build-backend = "setuptools.build_meta"
44

5+
6+
[tool.setuptools.packages.find]
7+
where = ["src"]
8+
include = ["*"]
9+
10+
[tool.setuptools.package-data]
11+
guidellm = ["*"]
12+
13+
14+
# ************************************************
15+
# ********** Project Metadata **********
16+
# ************************************************
17+
18+
[project]
19+
name = "guidellm"
20+
version = "0.1.0"
21+
description = "Guidance platform for deploying and managing large language models."
22+
readme = { file = "README.md", content-type = "text/markdown" }
23+
requires-python = ">=3.8.0,<4.0"
24+
license = { file = "LICENSE" }
25+
authors = [ { name = "Neuralmagic, Inc." } ]
26+
urls = { homepage = "https://github.com/neuralmagic/guidellm" }
27+
dependencies = [
28+
"click",
29+
"datasets",
30+
"loguru",
31+
"numpy",
32+
"openai",
33+
"requests",
34+
"transformers",
35+
]
36+
37+
[project.optional-dependencies]
38+
dev = [
39+
"black",
40+
"isort",
41+
"mypy",
42+
"pre-commit",
43+
"pytest",
44+
"ruff",
45+
"sphinx",
46+
"tox",
47+
]
48+
code_quality = [
49+
"black",
50+
"isort",
51+
"mypy",
52+
"pytest",
53+
"ruff",
54+
]
55+
56+
57+
[project.entry-points.console_scripts]
58+
guidellm = "guidellm.main:main"
59+
60+
61+
# ************************************************
62+
# ********** Code Quality Tools **********
63+
# ************************************************
64+
565
[tool.black]
666
line-length = 88
767
target-version = ['py38']
868

69+
970
[tool.isort]
1071
profile = "black"
1172

73+
1274
[tool.mypy]
1375
files = "src/guidellm"
76+
python_version = '3.8'
77+
warn_redundant_casts = true
78+
warn_unused_ignores = true
79+
show_error_codes = true
80+
namespace_packages = true
81+
exclude = ["venv", ".tox"]
82+
83+
# Silint "type import errors" as our 3rd-party libs does not have types
84+
# Check: https://mypy.readthedocs.io/en/latest/config_file.html#import-discovery
85+
follow_imports = 'silent'
86+
1487

1588
[tool.ruff]
89+
line-length = 88
1690
exclude = ["build", "dist", "env", ".venv"]
1791
lint.select = ["E", "F", "W"]
1892

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

2294
[tool.pytest.ini_options]
2395
addopts = '-s -vvv --cache-clear'
@@ -27,4 +99,3 @@ markers = [
2799
"sanity: detailed tests to ensure major functions work correctly",
28100
"regression: tests to ensure that new changes do not break existing functionality"
29101
]
30-

setup.py

Lines changed: 0 additions & 64 deletions
This file was deleted.

src/__init__.py

Whitespace-only changes.

src/guidellm/backend/base.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
import uuid
21
from abc import ABC, abstractmethod
32
from dataclasses import dataclass
43
from enum import Enum
5-
from typing import Iterator, List, Optional, Type, Union
4+
from typing import Dict, Iterator, List, Optional, Type, Union
65

76
from loguru import logger
87

@@ -36,7 +35,7 @@ class Backend(ABC):
3635
An abstract base class for generative AI backends.
3736
"""
3837

39-
_registry = {}
38+
_registry: Dict[BackendTypes, "Type[Backend]"] = {}
4039

4140
@staticmethod
4241
def register_backend(backend_type: BackendTypes):
@@ -54,7 +53,7 @@ def inner_wrapper(wrapped_class: Type["Backend"]):
5453
return inner_wrapper
5554

5655
@staticmethod
57-
def create_backend(backend_type: Union[str, BackendTypes], **kwargs) -> "Backend":
56+
def create_backend(backend_type: BackendTypes, **kwargs) -> "Backend":
5857
"""
5958
Factory method to create a backend based on the backend type.
6059
@@ -65,10 +64,13 @@ def create_backend(backend_type: Union[str, BackendTypes], **kwargs) -> "Backend
6564
:return: An instance of a subclass of Backend.
6665
:rtype: Backend
6766
"""
67+
6868
logger.info(f"Creating backend of type {backend_type}")
69+
6970
if backend_type not in Backend._registry:
7071
logger.error(f"Unsupported backend type: {backend_type}")
7172
raise ValueError(f"Unsupported backend type: {backend_type}")
73+
7274
return Backend._registry[backend_type](**kwargs)
7375

7476
def submit(self, request: TextGenerationRequest) -> TextGenerationResult:
@@ -81,16 +83,19 @@ def submit(self, request: TextGenerationRequest) -> TextGenerationResult:
8183
:rtype: TextGenerationResult
8284
"""
8385
logger.info(f"Submitting request with prompt: {request.prompt}")
84-
result_id = str(uuid.uuid4())
85-
result = TextGenerationResult(result_id)
86+
87+
# TODO: Doublecheck why do we need the result id
88+
# result_id = str(uuid.uuid4())
89+
90+
result = TextGenerationResult(TextGenerationRequest(prompt=request.prompt))
8691
result.start(request.prompt)
8792

8893
for response in self.make_request(request):
8994
if response.type_ == "token_iter" and response.add_token:
9095
result.output_token(response.add_token)
9196
elif response.type_ == "final":
9297
result.end(
93-
response.output,
98+
response.output or "",
9499
response.prompt_token_count,
95100
response.output_token_count,
96101
)

src/guidellm/core/distribution.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import List, Union
1+
from typing import List, Optional, Union
22

33
import numpy as np
44
from loguru import logger
@@ -16,7 +16,7 @@ class Distribution:
1616
:type data: List[Union[int, float]], optional
1717
"""
1818

19-
def __init__(self, data: List[Union[int, float]] = None):
19+
def __init__(self, data: Optional[List[Union[int, float]]] = None):
2020
"""
2121
Initialize the Distribution with optional data.
2222

0 commit comments

Comments
 (0)