Skip to content

Commit faa88cc

Browse files
author
Dmytro Parfeniuk
committed
🚧 WIP
1 parent 71600c1 commit faa88cc

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

+531
-372
lines changed

.env.example

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
## Docker configurations
2+
3+
# You can hardcode the platform to build the vLLM locally since it is supported only
4+
# for the x86 CPU architecture. ARM CPU architecture may cause to some issues without that.
5+
# BUILDPLATFORM=linux/x86_64
6+
7+
# This environment variable defines which port will be available locally
8+
DOCKER_VLLM_PORT_EXPOSE=8000

pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ lint.select = ["E", "F", "W"]
2020
max-line-length = 88
2121

2222
[tool.pytest.ini_options]
23+
addopts = '-s -vvv --cache-clear'
24+
asyncio_mode = 'auto'
2325
python_classes = "DisableTestClasses"
2426
markers = [
2527
"smoke: quick tests to check basic functionality",
File renamed without changes.

src/domain/__init__.py

Whitespace-only changes.
File renamed without changes.

src/guidellm/backend/base.py renamed to src/domain/backend/base.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
1-
import functools
21
import uuid
32
from abc import ABC, abstractmethod
43
from dataclasses import dataclass
54
from enum import Enum
6-
from typing import Generic, Iterator, List, Optional, Type, Union
5+
from typing import Iterator, List, Optional, Type, Union
76

87
from loguru import logger
98

10-
from guidellm.core.request import TextGenerationRequest
11-
from guidellm.core.result import TextGenerationResult
9+
from domain.core import TextGenerationRequest, TextGenerationResult
1210

1311
__all__ = ["Backend", "BackendEngine", "GenerativeResponse"]
1412

@@ -46,8 +44,8 @@ class Backend(ABC):
4644

4745
_registry = {}
4846

49-
@staticmethod
50-
def register(backend_type: BackendEngine):
47+
@classmethod
48+
def register(cls, backend_type: BackendEngine):
5149
"""
5250
A decorator to register a backend class in the backend registry.
5351
@@ -56,13 +54,13 @@ def register(backend_type: BackendEngine):
5654
"""
5755

5856
def inner_wrapper(wrapped_class: Type["Backend"]):
59-
Backend._registry[backend_type] = wrapped_class
57+
cls._registry[backend_type] = wrapped_class
6058
return wrapped_class
6159

6260
return inner_wrapper
6361

64-
@staticmethod
65-
def create(backend_type: Union[str, BackendEngine], **kwargs) -> "Backend":
62+
@classmethod
63+
def create(cls, backend_type: Union[str, BackendEngine], **kwargs) -> "Backend":
6664
"""
6765
Factory method to create a backend based on the backend type.
6866
@@ -76,11 +74,11 @@ def create(backend_type: Union[str, BackendEngine], **kwargs) -> "Backend":
7674

7775
logger.info(f"Creating backend of type {backend_type}")
7876

79-
if backend_type not in Backend._registry:
77+
if backend_type not in cls._registry:
8078
logger.error(f"Unsupported backend type: {backend_type}")
8179
raise ValueError(f"Unsupported backend type: {backend_type}")
8280

83-
return Backend._registry[backend_type](**kwargs)
81+
return cls._registry[backend_type](**kwargs)
8482

8583
def submit(self, request: TextGenerationRequest) -> TextGenerationResult:
8684
"""
@@ -91,6 +89,7 @@ def submit(self, request: TextGenerationRequest) -> TextGenerationResult:
9189
:return: The populated result result.
9290
:rtype: TextGenerationResult
9391
"""
92+
9493
logger.info(f"Submitting request with prompt: {request.prompt}")
9594
result_id = str(uuid.uuid4())
9695
result = TextGenerationResult(result_id)
@@ -108,6 +107,7 @@ def submit(self, request: TextGenerationRequest) -> TextGenerationResult:
108107
break
109108

110109
logger.info(f"Request completed with output: {result.output}")
110+
111111
return result
112112

113113
@abstractmethod

src/guidellm/backend/openai.py renamed to src/domain/backend/openai.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
from typing import Any, Dict, Iterable, Iterator, List, Optional
44

55
from loguru import logger
6-
from openai import OpenAI, Stream
6+
from openai import OpenAI
77
from openai.types import Completion
88
from transformers import AutoTokenizer
99

10-
from guidellm.backend import Backend, BackendEngine, GenerativeResponse
11-
from guidellm.core.request import TextGenerationRequest
10+
from domain.backend import Backend, BackendEngine, GenerativeResponse
11+
from domain.core import TextGenerationRequest
1212

1313
__all__ = ["OpenAIBackend"]
1414

@@ -49,15 +49,17 @@ def __init__(
4949

5050
if not (_api_key := (openai_api_key or os.getenv("OPENAI_API_KEY", None))):
5151
raise ValueError(
52-
"`OPENAI_API_KEY` environment variable or --openai-api-key CLI parameter "
52+
"`OPENAI_API_KEY` environment variable "
53+
"or --openai-api-key CLI parameter "
5354
"must be specify for the OpenAI backend"
5455
)
5556

5657
if not (
5758
_base_url := (internal_callback_url or os.getenv("OPENAI_BASE_URL", None))
5859
):
5960
raise ValueError(
60-
"`OPENAI_BASE_URL` environment variable or --openai-base-url CLI parameter "
61+
"`OPENAI_BASE_URL` environment variable "
62+
"or --openai-base-url CLI parameter "
6163
"must be specify for the OpenAI backend"
6264
)
6365
self.openai_client = OpenAI(api_key=_api_key, base_url=_base_url)
File renamed without changes.

src/guidellm/core/distribution.py renamed to src/domain/core/distribution.py

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

33
import numpy as np
44
from loguru import logger
55

6-
__all__ = ["Distribution"]
7-
86

97
class Distribution:
108
"""
@@ -16,7 +14,7 @@ class Distribution:
1614
:type data: List[Union[int, float]], optional
1715
"""
1816

19-
def __init__(self, data: List[Union[int, float]] = None):
17+
def __init__(self, data: Optional[List[Union[int, float]]] = None):
2018
"""
2119
Initialize the Distribution with optional data.
2220

src/guidellm/core/request.py renamed to src/domain/core/request.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33

44
from loguru import logger
55

6-
__all__ = ["TextGenerationRequest"]
7-
86

97
class TextGenerationRequest:
108
"""

0 commit comments

Comments
 (0)