From 26d9f0cc7daa6a89475bb6c3d581bf845668207b Mon Sep 17 00:00:00 2001 From: Andrew Lapp Date: Wed, 21 Feb 2024 18:56:16 +0000 Subject: [PATCH] Dockerize and Add Release-Push Workflow (#688) --------- Co-authored-by: Andrew Lapp --- .github/workflows/release_docker.yml | 37 +++++++++++++++++++ .../{release.yml => release_pypi.yaml} | 4 +- Dockerfile | 17 +++++++++ README.md | 2 +- docs/community/contribute.md | 9 +++++ docs/quickstart.md | 11 ++++-- docs/reference/vllm.md | 12 ++++-- 7 files changed, 81 insertions(+), 11 deletions(-) create mode 100644 .github/workflows/release_docker.yml rename .github/workflows/{release.yml => release_pypi.yaml} (96%) create mode 100644 Dockerfile diff --git a/.github/workflows/release_docker.yml b/.github/workflows/release_docker.yml new file mode 100644 index 000000000..0e099a08b --- /dev/null +++ b/.github/workflows/release_docker.yml @@ -0,0 +1,37 @@ +name: Release Docker + +on: + release: + types: + - created + workflow_dispatch: + inputs: + release_tag: + description: 'Release Tag (for manual dispatch)' + required: false + default: 'latest' +jobs: + release-job: + name: Build and publish on Docker Hub + runs-on: ubuntu-latest + environment: release + steps: + + - name: Checkout + uses: actions/checkout@v4 + - name: Log in to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + push: true + tags: | + outlinesdev/outlines:latest + outlinesdev/outlines:${{ github.event.release.tag_name }} + build-args: | + BUILDKIT_CONTEXT_KEEP_GIT_DIR=true + - name: Clean docker cache + run: docker system prune --all --force diff --git a/.github/workflows/release.yml b/.github/workflows/release_pypi.yaml similarity index 96% rename from .github/workflows/release.yml rename to .github/workflows/release_pypi.yaml index e6bf1b119..dc2414d41 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release_pypi.yaml @@ -1,16 +1,14 @@ -name: Release +name: Release PyPi on: release: types: - created - jobs: release-job: name: Build and publish on PyPi runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - name: Set up Python uses: actions/setup-python@v2 with: diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..b4e3a7b3a --- /dev/null +++ b/Dockerfile @@ -0,0 +1,17 @@ +FROM python:3.10 + +WORKDIR /outlines + +RUN pip install --upgrade pip + +# Copy necessary build components +COPY pyproject.toml . +COPY outlines ./outlines + +# Install outlines and outlines[serve] +# .git required by setuptools-scm +RUN --mount=source=.git,target=.git,type=bind \ + pip install --no-cache-dir .[serve] + +# https://outlines-dev.github.io/outlines/reference/vllm/ +ENTRYPOINT python3 -m outlines.serve.serve diff --git a/README.md b/README.md index a5b89d1cd..521a7d10f 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ First time here? Go to our [setup guide](https://outlines-dev.github.io/outlines - [x] 💾 Caching of generations - [x] 🗂️ Batch inference - [x] 🎲 Sample with the greedy, multinomial and beam search algorithms (and more to come!) -- [x] 🚀 [Serve with vLLM](https://outlines-dev.github.io/outlines/reference/vllm) +- [x] 🚀 [Serve with vLLM](https://outlines-dev.github.io/outlines/reference/vllm), with official Docker image, [`outlinesdev/outlines`](https://hub.docker.com/r/outlinesdev/outlines)! Outlines 〰 has new releases and features coming every week. Make sure to ⭐ star and 👀 watch this repository, follow [@dottxtai][twitter] to stay up to date! diff --git a/docs/community/contribute.md b/docs/community/contribute.md index 8b14e790a..d69fb9dfb 100644 --- a/docs/community/contribute.md +++ b/docs/community/contribute.md @@ -42,6 +42,15 @@ pip install -e .[test] pre-commit install ``` +#### Developing Serve Endpoint Via Docker + +```bash +docker build -t outlines-serve . +docker run -p 8000:8000 outlines-serve --model="mistralai/Mistral-7B-Instruct-v0.2" +``` + +This builds `outlines-serve` and runs on `localhost:8000` with the model `Mistral-7B-Instruct-v0.2` + ### Before pushing your code Run the tests: diff --git a/docs/quickstart.md b/docs/quickstart.md index ee952dd61..7d4e86fbc 100644 --- a/docs/quickstart.md +++ b/docs/quickstart.md @@ -239,15 +239,18 @@ Outlines can be deployed as a LLM service using [vLLM][vllm]{:target="_blank"} a First start the server: ```python -python -m outlines.serve.serve +python -m outlines.serve.serve --model="mistralai/Mistral-7B-Instruct-v0.2" ``` -This will by default start a server at `http://127.0.0.1:8000` (check what the console says, though) with the OPT-125M model. If you want to specify another model: +Or you can start the server with Outlines' official Docker image: -```python -python -m outlines.serve.serve --model="mistralai/Mistral-7B-Instruct-v0.2" +```bash +docker run -p 8000:8000 outlinesdev/outlines --model="mistralai/Mistral-7B-Instruct-v0.2" ``` +This will by default start a server at `http://127.0.0.1:8000` (check what the console says, though). Without the `--model` argument set, the OPT-125M model is used. + + You can then query the model in shell by passing a prompt and a [JSON Schema][jsonschema]{:target="_blank"} specification for the structure of the output: ```bash diff --git a/docs/reference/vllm.md b/docs/reference/vllm.md index df619b7ee..0a6f5dc62 100644 --- a/docs/reference/vllm.md +++ b/docs/reference/vllm.md @@ -13,15 +13,21 @@ pip install outlines[serve] You can then start the server with: ```bash -python -m outlines.serve.serve +python -m outlines.serve.serve --model="mistralai/Mistral-7B-Instruct-v0.2" ``` -This will by default start a server at `http://127.0.0.1:8000` (check what the console says, though) with the OPT-125M model. If you want to specify another model (e.g. Mistral-7B-Instruct-v0.2), you can do so with the `--model` parameter: +This will by default start a server at `http://127.0.0.1:8000` (check what the console says, though). Without the `--model` argument set, the OPT-125M model is used. The `--model` argument allows you to specify any model of your choosing. + +### Alternative Method: Via Docker + +You can install and run the server with Outlines' official Docker image using the command ```bash -python -m outlines.serve.serve --model="mistralai/Mistral-7B-Instruct-v0.2" +docker run -p 8000:8000 outlinesdev/outlines --model="mistralai/Mistral-7B-Instruct-v0.2" ``` +## Querying Endpoint + You can then query the model in shell by passing a prompt and either 1. a [JSON Schema][jsonschema]{:target="_blank"} specification or