Contribute - Outlines (original) (raw)

How to contribute 🏗️

What contributions?

Note that the issue tracker is only intended for actionable items. In doubt, open a discussion or come talk to us.

How to contribute?

Setup

First, fork the repository on GitHub and clone the fork locally:

[](#%5F%5Fcodelineno-0-1)git clone git@github.com/YourUserName/outlines.git [](#%5F%5Fcodelineno-0-2)cd outlines

Create a new virtual environment. If you are using conda:

[](#%5F%5Fcodelineno-1-1)conda env create -f environment.yml

If you are using venv:

[](#%5F%5Fcodelineno-2-1)python -m venv .venv [](#%5F%5Fcodelineno-2-2)source .venv/bin/activate

Then install the dependencies in editable mode, and install the pre-commit hooks:

[](#%5F%5Fcodelineno-3-1)pip install -e ".[test]" [](#%5F%5Fcodelineno-3-2)pre-commit install

Before pushing your code

Run the tests:

And run the code style checks:

[](#%5F%5Fcodelineno-5-1)pre-commit run --all-files

Benchmarking

Outlines uses asv for automated benchmark testing. Benchmarks are run automatically before pull requests are merged to prevent performance degredation.

You can run the benchmark test suite locally with the following command:

[](#%5F%5Fcodelineno-6-1)asv run --config benchmarks/asv.conf.json

Caveats: - If you're on a device with CUDA, you must add the argument --launch-method spawn- Uncommitted code will not be benchmarked, you must first commit your changes.

Run a specific test:

[](#%5F%5Fcodelineno-7-1)asv run --config benchmarks/asv.conf.json -b bench_json_schema.JsonSchemaBenchmark.time_json_schema_to_fsm

Profile a specific test:

[](#%5F%5Fcodelineno-8-1)asv run --config benchmarks/asv.conf.json --profile -b bench_json_schema.JsonSchemaBenchmark.time_json_schema_to_fsm

Compare to origin/main

[](#%5F%5Fcodelineno-9-1)get fetch origin [](#%5F%5Fcodelineno-9-2)asv continuous origin/main HEAD --config benchmarks/asv.conf.json

ASV PR Behavior

Contribute to the documentation

To work on the documentation you will need to install the related dependencies:

[](#%5F%5Fcodelineno-10-1)pip install -r requirements-doc.txt

To build the documentation and serve it locally, run the following command in the repository's root folder:

By following the instruction you will be able to view the documentation locally. It will be updated every time you make a change.

Open a Pull Request

Create a new branch on your fork, commit and push the changes:

[](#%5F%5Fcodelineno-12-1)git checkout -b new-branch [](#%5F%5Fcodelineno-12-2)git add . [](#%5F%5Fcodelineno-12-3)git commit -m "Changes I made" [](#%5F%5Fcodelineno-12-4)git push origin new-branch

Then you can open a pull request on GitHub. It should prompt you to do so. Every subsequent change that you make on your branch will update the pull request.

Do not hesitate to open a draft PR before your contribution is ready, especially if you have questions and/or need feedback. If you need help, come tell us on Discord.