Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create Makefile #24

Merged
merged 2 commits into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 74 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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)
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ test = [
"torch",
"transformers",
"pillow",
"asv",
]

[project.urls]
Expand Down
Loading