Skip to content

Commit

Permalink
merge main
Browse files Browse the repository at this point in the history
  • Loading branch information
DaltheCow committed Jul 15, 2024
2 parents d915515 + f905346 commit 993610a
Show file tree
Hide file tree
Showing 42 changed files with 1,040 additions and 396 deletions.
9 changes: 9 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# OpenAI compatible server address.

# If you are going to run custom OpenAI API compatible service change this configuration.
# Could be specified by --openai-base-url CLI parameter
OPENAI_BASE_URL=http://127.0.0.1:8080

# The OpenAI API Key.
# Could be specified by --openai-api-key CLI parameter
OPENAI_API_KEY=invalid
24 changes: 23 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1 +1,23 @@
TODO
name: Code Quality Check

on:
pull_request:
branches:
- main

jobs:
code_quality:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install tox
- name: Run tox
run: tox

1 change: 0 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
TODO
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -160,3 +160,7 @@ cython_debug/
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/


# MacOS files
.DS_Store
66 changes: 49 additions & 17 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,34 +1,66 @@
.PHONY: install
install:
pip install -r requirements.txt
python -m pip install .

install-dev:
pip install -e .[dev]

quality:
ruff check src tests
isort --check-only src tests
flake8 src tests --max-line-length 88
mypy src
.PHONY: install.dev
install.dev:
python -m pip install -e .[dev]


.PHONY: build
build:
python setup.py sdist bdist_wheel

.PHONY: style
style:
ruff format src tests
isort src tests
flake8 src tests --max-line-length 88
python -m ruff format src tests
python -m isort src tests
python -m flake8 src tests --max-line-length 88


.PHONY: types
types:
python -m mypy --check-untyped-defs


.PHONY: quality
quality:
python -m ruff check src tests
python -m black --check src tests
python -m isort --check src tests
python -m mypy --check-untyped-defs



.PHONY: test
test:
python -m pytest -s -vvv --cache-clear tests/
python -m pytest -s -vvv --cache-clear tests

build:
python setup.py sdist bdist_wheel

.PHONY: test.unit
test.unit:
python -m pytest tests/unit


.PHONY: test.integration
test.integration:
python -m pytest tests/integration


.PHONY: test.e2e
test.e2e:
python -m pytest tests/e2e



.PHONY: clean
clean:
rm -rf __pycache__
rm -rf build
rm -rf dist
rm -rf *.egg-info
find . -type f -name "*.pyc" -delete
find . -type d -name "__pycache__" -exec rm -r {} +
rm -rf .mypy_cache
rm -rf .pytest_cache

.PHONY: install install-dev quality style test test-unit test-integration test-e2e test-smoke test-sanity test-regression build clean
rm -rf .tox
71 changes: 70 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,70 @@
# guidellm
# guidellm

# Project configuration

The project is configured with environment variables. Check the example in `.env.example`.

```sh
# Create .env file and update the configuration
cp .env.example .env

# Export all variables
set -o allexport; source .env; set +o allexport
```

## Environment Variables

| Variable | Default Value | Description |
| --------------- | --------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 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. |
| 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. |

</br>

# Code Quality

The variety of tools are available for checking the code quality.

All the code quality tools configuration is placed into next files: `pyproject.toml`, `Makefile`, `tox.ini`

**To provide the code quality next tools are used:**

- `pytest` as a testing framework
- `ruff` as a linter
- `black` & `isort` as formatters
- `mypy` as a static type checker
- `tox` as a automation tool
- `make` as a automation tool (works only on Unix by default)

**Checking code quality using CLI**

All the tools could be run right from the CLI.

Recommended command template: `python -m pytest test.integration`


**Checking code quality using Makefile**

Using `Makefile` you can run almost all common scripts to check the code quality, install dependencies, and to provide auto fixes. All the commands from the `Makefile` are valid to be used in the CLI.

Here are some commands

```sh
# install dev dependencies
make install.dev

# run unit tests
make test.unit

# run quality checkers
make quality

# run autofixes
make style
```

**Checking code quality using tox**

The `tox` is an automation tool for running code quality checkers for selected Python versions. The configuration is placed in the `tox.ini`.

To run the automation just run: `python -m tox`
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
TODO
TODO
81 changes: 78 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,102 @@
requires = ["setuptools", "wheel"]
build-backend = "setuptools.build_meta"


[tool.setuptools.packages.find]
where = ["src"]
include = ["*"]

[tool.setuptools.package-data]
guidellm = ["*"]


# ************************************************
# ********** Project Metadata **********
# ************************************************

[project]
name = "guidellm"
version = "0.1.0"
description = "Guidance platform for deploying and managing large language models."
readme = { file = "README.md", content-type = "text/markdown" }
requires-python = ">=3.8.0,<4.0"
license = { file = "LICENSE" }
authors = [ { name = "Neuralmagic, Inc." } ]
urls = { homepage = "https://github.com/neuralmagic/guidellm" }
dependencies = [
"click",
"datasets",
"loguru",
"numpy",
"openai",
"requests",
"transformers",
]

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


[project.entry-points.console_scripts]
guidellm = "guidellm.main:main"


# ************************************************
# ********** Code Quality Tools **********
# ************************************************

[tool.black]
line-length = 88
target-version = ['py38']


[tool.isort]
profile = "black"


[tool.mypy]
files = "src/guidellm"
python_version = '3.8'
warn_redundant_casts = true
warn_unused_ignores = true
show_error_codes = true
namespace_packages = true
exclude = ["venv", ".tox"]

# Silint "type import errors" as our 3rd-party libs does not have types
# Check: https://mypy.readthedocs.io/en/latest/config_file.html#import-discovery
follow_imports = 'silent'

[[tool.mypy.overrides]]
module = ["transformers.*", "datasets.*"]
ignore_missing_imports=true


[tool.ruff]
line-length = 88
exclude = ["build", "dist", "env", ".venv"]
lint.select = ["E", "F", "W"]

[tool.flake8]
max-line-length = 88

[tool.pytest.ini_options]
addopts = '-s -vvv --cache-clear'
asyncio_mode = 'auto'
markers = [
"smoke: quick tests to check basic functionality",
"sanity: detailed tests to ensure major functions work correctly",
"regression: tests to ensure that new changes do not break existing functionality"
]

64 changes: 0 additions & 64 deletions setup.py

This file was deleted.

4 changes: 2 additions & 2 deletions src/guidellm/backend/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from .base import Backend, BackendTypes, GenerativeResponse
from .base import Backend, BackendEngine, GenerativeResponse
from .openai import OpenAIBackend

__all__ = [
"Backend",
"BackendTypes",
"BackendEngine",
"GenerativeResponse",
"OpenAIBackend",
]
Loading

0 comments on commit 993610a

Please sign in to comment.