Skip to content

Commit

Permalink
Add pre commit functionality to the repo, fix any errors popping up w…
Browse files Browse the repository at this point in the history
…ith current state of main and running the pre commit checks, fix install and versioning issues with dev dependencies
  • Loading branch information
markurtz committed Jul 17, 2024
1 parent f905346 commit c8b0871
Show file tree
Hide file tree
Showing 12 changed files with 64 additions and 26 deletions.
1 change: 0 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,3 @@ jobs:
- name: Run tox
run: tox

41 changes: 41 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.5.2
hooks:
- id: ruff
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 24.4.2
hooks:
- id: black
- repo: https://github.com/pycqa/isort
rev: 5.13.2
hooks:
- id: isort
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.10.1
hooks:
- id: mypy
args: [--check-untyped-defs]
additional_dependencies:
[
# main dependencies
click,
datasets,
loguru,
numpy,
openai,
requests,
transformers,

# dev dependencies
pytest,

# types
types-click,
types-requests,
]
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1 +1 @@
include LICENSE
include LICENSE
1 change: 0 additions & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
TODO
1 change: 0 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
TODO
26 changes: 13 additions & 13 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,19 @@ dependencies = [

[project.optional-dependencies]
dev = [
"guidellm[code_quality]",
"pre-commit",
"sphinx",
]
code_quality = [
"black",
"isort",
"mypy",
"pytest",
"pytest-mock",
"ruff",
"tox",
"types-requests"
# general
"pre-commit~=3.5.0",
"sphinx~=7.1.2",

# code quality
"black~=24.4.2",
"isort~=5.13.2",
"mypy~=1.10.1",
"pytest~=8.2.2",
"pytest-mock~=3.14.0",
"ruff~=0.5.2",
"tox~=4.16.0",
"types-requests~=2.32.0"
]


Expand Down
6 changes: 3 additions & 3 deletions src/guidellm/core/distribution.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Distribution:
:type data: List[Union[int, float]], optional
"""

def __init__(self, data: Optional[List[Union[int, float]]] = None):
def __init__(self, data: Optional[Union[List[int], List[float]]] = None):
"""
Initialize the Distribution with optional data.
Expand Down Expand Up @@ -227,7 +227,7 @@ def describe(self) -> dict:
logger.debug(f"Generated description: {description}")
return description

def add_data(self, new_data: List[Union[int, float]]):
def add_data(self, new_data: Union[List[int], List[float]]):
"""
Add new data points to the distribution.
Expand All @@ -237,7 +237,7 @@ def add_data(self, new_data: List[Union[int, float]]):
self._data.extend(new_data)
logger.debug(f"Added new data: {new_data}")

def remove_data(self, remove_data: List[Union[int, float]]):
def remove_data(self, remove_data: Union[List[int], List[float]]):
"""
Remove specified data points from the distribution.
Expand Down
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ def inner_wrapper(*_, base_url: Optional[str] = None, **kwargs) -> OpenAIBackend

defaults.update(kwargs)

return Backend.create(**defaults)
return Backend.create(**defaults) # type: ignore

return inner_wrapper
2 changes: 1 addition & 1 deletion tests/dummy/data/openai.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def openai_completion_factory(
}
payload.update(kwargs)

yield Completion(**payload)
yield Completion(**payload) # type: ignore


def openai_model_factory(n: int = 3) -> Generator[Model, None, None]:
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def openai_models_list_patch(mocker) -> List[openai.types.Model]:
Mock available models function to avoid OpenAI API call.
"""

items: list[openai.types.Model] = [
items: List[openai.types.Model] = [
item for item in dummy.data.openai_model_factory()
]
mocker.patch(
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/request/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def test_request_generator_repr():
@pytest.mark.regression
def test_request_generator_iter_calls_create_item():
generator = TestRequestGenerator(mode="sync")
generator.create_item = Mock(
generator.create_item = Mock( # type: ignore
return_value=TextGenerationRequest(prompt="Mock prompt")
)

Expand All @@ -91,7 +91,7 @@ def test_request_generator_iter_calls_create_item():
@pytest.mark.regression
def test_request_generator_async_iter_calls_create_item():
generator = TestRequestGenerator(mode="sync")
generator.create_item = Mock(
generator.create_item = Mock( # type: ignore
return_value=TextGenerationRequest(prompt="Mock prompt")
)

Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ env_list = py38,py39,py310,py311,py312

[testenv]
deps = .[code_quality]
commands =
commands =
python -m pytest tests/unit

[testenv:lint]
Expand Down

0 comments on commit c8b0871

Please sign in to comment.