Skip to content

Commit

Permalink
refactor: replace poetry with uv
Browse files Browse the repository at this point in the history
- Updated installation docs with pip and uv methods
- Updated contributing guidelines for UV usage
- Updated GitHub workflows to use UV
- Added tabbed installation instructions
- Removed poetry dependencies and configuration
  • Loading branch information
devin-ai-integration[bot] committed Nov 23, 2024
1 parent 06cdc13 commit d0410d3
Show file tree
Hide file tree
Showing 13 changed files with 588 additions and 185 deletions.
21 changes: 16 additions & 5 deletions .github/workflows/evals.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,26 @@ jobs:
uses: actions/setup-python@v4
with:
python-version: 3.11
cache: "poetry"

- name: Install Poetry
uses: snok/install-poetry@v1.3.1
- name: Cache UV virtualenv
uses: actions/cache@v2
with:
path: |
~/.cache/uv
~/.uv
key: ${{ runner.os }}-uv-${{ hashFiles('**/requirements*.txt') }}
restore-keys: |
${{ runner.os }}-uv-
- name: Install UV
run: curl -LsSf https://astral.sh/uv/install.sh | sh

- name: Install dependencies
run: poetry install --with dev,anthropic
run: |
uv pip install -e ".[test-docs,anthropic]"
uv pip install -r requirements-dev.txt
- name: Run all tests
run: poetry run pytest tests/
run: pytest tests/
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
21 changes: 11 additions & 10 deletions .github/workflows/pyright.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,23 @@ jobs:
with:
python-version: ${{ matrix.python-version }}

- name: Cache Poetry virtualenv
- name: Cache UV virtualenv
uses: actions/cache@v2
with:
path: ~/.cache/pypoetry/virtualenvs
key: ${{ runner.os }}-poetry-${{ hashFiles('**/poetry.lock') }}
path: |
~/.cache/uv
~/.uv
key: ${{ runner.os }}-uv-${{ hashFiles('**/requirements*.txt') }}
restore-keys: |
${{ runner.os }}-poetry-
${{ runner.os }}-uv-
- name: Install Poetry
uses: snok/install-poetry@v1.3.1
- name: Install UV
run: curl -LsSf https://astral.sh/uv/install.sh | sh

- name: Install dependencies
run: poetry install --with dev,anthropic

- name: Add poetry to PATH
run: echo "$(poetry env info --path)/bin" >> $GITHUB_PATH
run: |
uv pip install -e ".[test-docs,anthropic]"
uv pip install -r requirements-dev.txt
- uses: jakebailey/pyright-action@v2
with:
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/ruff.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ jobs:
uses: actions/setup-python@v4
with:
python-version: 3.9
cache: "pip"
- name: Install UV
run: curl -LsSf https://astral.sh/uv/install.sh | sh
- name: Install dev dependencies
run: |
python3 -m pip install --upgrade pip setuptools wheel
python3 -m pip install -r requirements.txt
python3 -m pip install -r requirements-doc.txt
uv pip install -r requirements.txt
uv pip install -r requirements-doc.txt
- name: Run Continuous Integration Action
uses: astral-sh/ruff-action@v1
- name: Upload Artifacts
Expand Down
26 changes: 15 additions & 11 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,27 @@ jobs:
with:
python-version: ${{ matrix.python-version }}

- name: Cache Poetry virtualenv
- name: Cache UV virtualenv
uses: actions/cache@v2
with:
path: ~/.cache/pypoetry/virtualenvs
key: ${{ runner.os }}-poetry-${{ hashFiles('**/poetry.lock') }}
path: |
~/.cache/uv
~/.uv
key: ${{ runner.os }}-uv-${{ hashFiles('**/requirements*.txt') }}
restore-keys: |
${{ runner.os }}-poetry-
${{ runner.os }}-uv-
- name: Install Poetry
uses: snok/install-poetry@v1.3.1
- name: Install UV
run: curl -LsSf https://astral.sh/uv/install.sh | sh

- name: Install dependencies
run: poetry install --with dev,anthropic
run: |
uv pip install -e ".[test-docs,anthropic]"
uv pip install -r requirements-dev.txt
- name: Run tests
if: matrix.python-version != '3.11'
run: poetry run pytest tests/ -k 'not llm and not openai and not gemini and not anthropic and not cohere and not vertexai' && poetry run pytest tests/llm/test_cohere
run: pytest tests/ -k 'not llm and not openai and not gemini and not anthropic and not cohere and not vertexai' && pytest tests/llm/test_cohere
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
Expand All @@ -46,9 +50,9 @@ jobs:
- name: Generate coverage report
if: matrix.python-version == '3.11'
run: |
poetry run coverage run -m pytest tests/ -k "not docs and not anthropic and not gemini and not cohere and not vertexai and not fireworks"
poetry run coverage report
poetry run coverage html
coverage run -m pytest tests/ -k "not docs and not anthropic and not gemini and not cohere and not vertexai and not fireworks"
coverage report
coverage html
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
24 changes: 14 additions & 10 deletions .github/workflows/test_docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,27 +20,31 @@ jobs:
sudo apt-get update
sudo apt-get install -y graphviz libcairo2-dev xdg-utils
- name: Install Poetry
uses: snok/install-poetry@v1.3.1

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: "poetry"

- name: Cache Poetry virtualenv
- name: Cache UV virtualenv
uses: actions/cache@v2
with:
path: ~/.cache/pypoetry/virtualenvs
key: ${{ runner.os }}-poetry-${{ hashFiles('**/poetry.lock') }}
path: |
~/.cache/uv
~/.uv
key: ${{ runner.os }}-uv-${{ hashFiles('**/requirements*.txt') }}
restore-keys: |
${{ runner.os }}-poetry-
${{ runner.os }}-uv-
- name: Install UV
run: curl -LsSf https://astral.sh/uv/install.sh | sh

- name: Install dependencies
run: poetry install --with dev,docs,test-docs,anthropic,google-generativeai
run: |
uv pip install -e ".[dev,docs,test-docs,anthropic,google-generativeai]"
uv pip install -r requirements-dev.txt
uv pip install -r requirements-doc.txt
- name: Run tests
run: poetry run pytest tests/llm/test_openai/docs
run: pytest tests/llm/test_openai/docs
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
24 changes: 24 additions & 0 deletions docs/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,30 @@ If it is not a small change, please start by [filing an issue](https://github.co

If you need ideas, you can check out the [help wanted](https://github.com/jxnl/instructor/labels/help%20wanted) or [good first issue](https://github.com/jxnl/instructor/labels/good%20first%20issue) labels.

## Development Setup

1. Install UV if you haven't already:
```bash
curl -LsSf https://astral.sh/uv/install.sh | sh
```

2. Clone the repository and install dependencies:
```bash
git clone https://github.com/jxnl/instructor.git
cd instructor
uv pip install -e ".[test-docs]"
```

3. Install development dependencies:
```bash
uv pip install -r requirements-dev.txt
```

4. Install documentation dependencies (if working on docs):
```bash
uv pip install -r requirements-doc.txt
```

[Grit](https://docs.grit.io/) is used to enforce best practices. You can run `grit check` to check your code before submitting a pull request.

# Contributors
Expand Down
File renamed without changes.
53 changes: 44 additions & 9 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,22 @@ It stands out for its simplicity, transparency, and user-centric design, built o

[:material-star: Star the Repo](https://github.com/jxnl/instructor){: .md-button .md-button--primary } [:material-book-open-variant: Cookbooks](./examples/index.md){: .md-button } [:material-lightbulb: Prompting Guide](./prompting/index.md){: .md-button }

=== "pip"
```bash
pip install instructor
```

=== "uv"
```bash
uv pip install instructor
```

If you ever get stuck, you can always run `instructor docs` to open the documentation in your browser. It even supports searching for specific topics.

```bash
instructor docs [QUERY]
```

## Newsletter

If you want to be notified of tips, new blog posts, and research, subscribe to our newsletter. Here's what you can expect:
Expand Down Expand Up @@ -77,9 +93,15 @@ Subscribe to our newsletter for updates on AI development. We provide content to

## Getting Started

```
pip install -U instructor
```
=== "pip"
```bash
pip install -U instructor
```

=== "uv"
```bash
uv pip install instructor
```

If you ever get stuck, you can always run `instructor docs` to open the documentation in your browser. It even supports searching for specific topics.

Expand All @@ -93,12 +115,25 @@ You can also check out our [cookbooks](./examples/index.md) and [concepts](./con

To keep the bundle size small, `instructor` only ships with the OpenAI client. Before using the other clients and their respective `from_xx` method, make sure you've installed the dependencies following the instructions below.

1. Anthropic : `pip install "instructor[anthropic]"`
2. Google Generative AI: `pip install "instructor[google-generativeai]"`
3. Vertex AI: `pip install "instructor[vertexai]"`
4. Cohere: `pip install "instructor[cohere]"`
5. Litellm: `pip install "instructor[litellm]"`
6. Mistral: `pip install "instructor[mistralai]"`
=== "pip"
```bash
pip install "instructor[anthropic]" # For Anthropic
pip install "instructor[google-generativeai]" # For Google Generative AI
pip install "instructor[vertexai]" # For Vertex AI
pip install "instructor[cohere]" # For Cohere
pip install "instructor[litellm]" # For Litellm
pip install "instructor[mistralai]" # For Mistral
```

=== "uv"
```bash
uv pip install "instructor[anthropic]" # For Anthropic
uv pip install "instructor[google-generativeai]" # For Google Generative AI
uv pip install "instructor[vertexai]" # For Vertex AI
uv pip install "instructor[cohere]" # For Cohere
uv pip install "instructor[litellm]" # For Litellm
uv pip install "instructor[mistralai]" # For Mistral
```

Now, let's see Instructor in action with a simple example:

Expand Down
23 changes: 16 additions & 7 deletions docs/installation.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
---
title: Installing Instructor with Pip
description: Learn how to install Instructor and its dependencies using pip for Python 3.9+. Simple setup guide included.
title: Installing Instructor
description: Learn how to install Instructor and its dependencies using pip or uv for Python 3.9+. Simple setup guide included.
---

Installation is as simple as:
# Installation

```bash
pip install instructor
```
=== "pip"
```bash
pip install instructor
```

=== "uv"
```bash
uv pip install instructor
```

Instructor has a few dependencies:

Expand All @@ -16,4 +22,7 @@ Instructor has a few dependencies:
- [`docstring-parser`](https://pypi.org/project/docstring-parser/): A parser for Python docstrings, to improve the experience of working with docstrings in jsonschema.
- [`pydantic`](https://pypi.org/project/pydantic/): Data validation and settings management using python type annotations.

If you've got Python 3.9+ and `pip` installed, you're good to go.
If you've got Python 3.9+ and either `pip` or `uv` installed, you're good to go.

!!! tip "Using UV"
[UV](https://github.com/astral-sh/uv) is a new, extremely fast Python package installer and resolver. It's a great alternative to pip, offering significantly faster installation times.
Loading

0 comments on commit d0410d3

Please sign in to comment.