From 711290601b219391db8eda391096d9c60d97bb87 Mon Sep 17 00:00:00 2001 From: Umut Date: Wed, 18 Sep 2024 17:45:06 +0300 Subject: [PATCH 1/2] Add `asv` as a test dependency to `pyproject.toml` --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index e8255045..ad49eb4a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -52,6 +52,7 @@ test = [ "torch", "transformers", "pillow", + "asv", ] [project.urls] From bf5b1104945b9979f03d28d5bd5dd968fe478eda Mon Sep 17 00:00:00 2001 From: Umut Date: Wed, 18 Sep 2024 17:45:11 +0300 Subject: [PATCH 2/2] Create Makefile --- Makefile | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..f2c0b7c3 --- /dev/null +++ b/Makefile @@ -0,0 +1,74 @@ +# Optional target to test/benchmark. +TARGET ?= + +.ONESHELL: +.PHONY: +.SILENT: + +# Create a fresh virtual environment with the latest pip. +venv: + rm -rf .venv + python -m venv .venv + source .venv/bin/activate + pip install -U pip + +# Setup the active virtual environment for development. +setup: + pip install -e .[test] + +# Build the latest changes in the rust bindings and install it to the active environment. +install: + pip install -e . + +# Run pre-commit checks. +pcc: + pre-commit run --all-files + +# Run rust tests. +test: + cargo test "$(TARGET)" + +# Run python tests. +pytest: install + pytest -svv tests -k "$(TARGET)" \ + --cov=outlines_core \ + --cov-report=term-missing:skip-covered + +# Run rust benchmarks. +bench: +ifeq ($(TARGET),) + cargo bench +else + cargo bench -- $(TARGET) +endif + +# Run python benchmarks. +pybench: check-clean-git +ifeq ($(TARGET),) + asv run --config benchmarks/asv.conf.json +else + asv run --config benchmarks/asv.conf.json -b "$(TARGET)" +endif + +# Build the documentation of the rust crate and open it. +doc: + cargo doc --document-private-items --open + +# Build the documentation of the python package and open it. +pydoc: + echo "Unable to perform the action as it's not implemented yet." + +# Create wheels for distribution. +dist: + pip install build + python -m build + +# Clean build and distribution files. +clean: + cargo clean + rm -rf dist + +# Make sure that git diff is clean. +check-clean-git: + git diff-index --quiet HEAD \ + || (echo "Unable to perform the action due to uncommited local changes." && exit 1)