Skip to content

Commit

Permalink
feat(deps): migrate from poetry to uv
Browse files Browse the repository at this point in the history
  • Loading branch information
collindutter committed Feb 25, 2025
1 parent 0e5a15c commit e4c3179
Show file tree
Hide file tree
Showing 14 changed files with 6,157 additions and 7,770 deletions.
25 changes: 5 additions & 20 deletions .github/actions/init-bare-environment/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,12 @@ runs:
with:
python-version: ${{ matrix.python-version }}

- name: Install and configure Poetry
uses: snok/install-poetry@v1
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true

- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v4
with:
path: .venv
key: venv-bare-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
enable-cache: true
cache-dependency-glob: "uv.lock"

- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --with test --with dev
shell: bash

- name: Activate venv
run: |
source $VENV
echo PATH=$PATH >> $GITHUB_ENV
shell: bash
run: uv sync --all-extras --all-groups
28 changes: 7 additions & 21 deletions .github/actions/init-environment/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,34 +12,20 @@ runs:
with:
python-version: ${{ matrix.python-version }}

- name: Install and configure Poetry
uses: snok/install-poetry@v1
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true

- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v4
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
enable-cache: true
cache-dependency-glob: "uv.lock"

- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --with test --with dev --with docs --all-extras
shell: bash
- name: Activate venv
run: |
source $VENV
echo PATH=$PATH >> $GITHUB_ENV
shell: bash
run: uv sync --all-extras --all-groups

- name: Get installed Playwright version
id: playwright-version
run: |
version=$(poetry run playwright/ -V | awk '{print $2}' | tr -d '\n')
version=$(uv run playwright -V | awk '{print $2}' | tr -d '\n')
echo "version=$version" >> $GITHUB_OUTPUT
shell: bash

Expand All @@ -51,5 +37,5 @@ runs:

- name: Install playwright
if: steps.playwright-cache.outputs.cache-hit != 'true'
run: playwright install --with-deps
run: uv run playwright install --with-deps
shell: bash
10 changes: 4 additions & 6 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ jobs:
uses: actions/checkout@v4
- name: Init environment
uses: ./.github/actions/init-environment
- name: Poetry Config
run: poetry config pypi-token.pypi ${{ secrets.PYPI_TOKEN }}
- name: Poetry Build
run: poetry build
- name: Poetry Publish
run: poetry publish
- name: uv Build
run: uv build
- name: uv Publish
run: uv publish --token ${{ secrets.PYPI_TOKEN }}
6 changes: 3 additions & 3 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
- name: Init environment
uses: ./.github/actions/init-bare-environment
- name: Run unit tests
run: poetry run pytest -n auto tests/unit/structures
run: uv run pytest -n auto tests/unit/structures
test-windows:
runs-on: windows-latest
strategy:
Expand All @@ -55,7 +55,7 @@ jobs:
uses: ./.github/actions/init-environment
- name: Run unit tests
# TODO: make test/unit fails with the following error:
# process_begin: CreateProcess(NULL, poetry run pytest -n auto tests/unit, ...) failed.
# process_begin: CreateProcess(NULL, uv run pytest -n auto tests/unit, ...) failed.
# make (e=2): The system cannot find the file specified.
# make: *** [Makefile:24: test/unit] Error 2
run: poetry run pytest -n auto tests/unit
run: uv run pytest -n auto tests/unit
5 changes: 2 additions & 3 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@ build:
python: "3.11"
jobs:
post_create_environment:
- pip install poetry
- poetry config virtualenvs.create false
- pip install uv
post_install:
- VIRTUAL_ENV=$READTHEDOCS_VIRTUALENV_PATH poetry install --with docs
- UV_PROJECT_ENVIRONMENT=$READTHEDOCS_VIRTUALENV_PATH uv sync --group docs

formats: all

Expand Down
36 changes: 18 additions & 18 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,72 +4,72 @@ install: ## Install all dependencies.

.PHONY: install/core
install/core: ## Install core dependencies.
@poetry install
@uv sync

.PHONY: install/all
install/all: ## Install all dependencies.
@poetry install --with dev --with test --with docs --all-extras
@poetry run pre-commit install
@uv sync --all-groups --all-extras
@uv run pre-commit install

.PHONY: install/dev
install/dev: ## Install dev dependencies.
@poetry install --with dev
@uv sync --group dev

.PHONY: install/test
install/test: ## Install test dependencies.
@poetry install --with test
@uv sync --group test

.PHONY: test ## Run all tests.
test: test/unit test/integration

.PHONY: test/unit
test/unit: ## Run unit tests.
@poetry run pytest -n auto tests/unit
@uv run pytest -n auto tests/unit

.PHONY: test/unit/%
test/unit/%: ## Run specific unit tests.
@poetry run pytest -n auto tests/unit -k $*
@uv run pytest -n auto tests/unit -k $*

.PHONY: test/unit/coverage
test/unit/coverage:
@poetry run pytest -n auto --cov=griptape tests/unit
@uv run pytest -n auto --cov=griptape tests/unit

.PHONY: test/integration
test/integration:
@poetry run pytest -n auto tests/integration/test_code_blocks.py
@uv run pytest -n auto tests/integration/test_code_blocks.py

.PHONY: lint
lint: ## Lint project.
@poetry run ruff check --fix
@uv run ruff check --fix

.PHONY: format
format: ## Format project.
@poetry run ruff format
@poetry run mdformat .github/ docs/
@uv run ruff format
@uv run mdformat .github/ docs/

.PHONY: check
check: check/format check/lint check/types check/spell ## Run all checks.

.PHONY: check/format
check/format:
@poetry run ruff format --check
@poetry run mdformat --check .github/ docs/
@uv run ruff format --check
@uv run mdformat --check .github/ docs/

.PHONY: check/lint
check/lint:
@poetry run ruff check
@uv run ruff check

.PHONY: check/types
check/types:
@poetry run pyright griptape $(shell find docs -type f -path "*/src/*")
@uv run pyright griptape $(shell find docs -type f -path "*/src/*")

.PHONY: check/spell
check/spell:
@poetry run typos
@uv run typos

.PHONY: docs
docs: ## Build documentation.
@poetry run python -m mkdocs build --clean --strict
@uv run python -m mkdocs build --clean --strict

.DEFAULT_GOAL := help
.PHONY: help
Expand Down
6 changes: 3 additions & 3 deletions docs/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ We welcome and encourage pull requests. To streamline the process, please follow

## Getting Started

Griptape docs are built using [MkDocs](https://squidfunk.github.io/mkdocs-material/getting-started/). Dependencies are managed using [Poetry](https://python-poetry.org/).
Griptape docs are built using [MkDocs](https://squidfunk.github.io/mkdocs-material/getting-started/). Dependencies are managed using [uv](https://docs.astral.sh/uv/).

To contribute to Griptape docs, install the `docs` extra with:

`poetry install --with docs`
`uv install --group docs`

Then serve the documentation locally with:

`poetry run mkdocs serve`
`uv run mkdocs serve`

You should see something similar to the following:

Expand Down
2 changes: 1 addition & 1 deletion docs/griptape-framework/drivers/web-scraper-drivers.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Example using `ProxyWebScraperDriver` directly:
playwright browsers to be installed.

To install the playwright browsers, run `playwright install` in your terminal. If you are using
poetry, run `poetry run playwright install` instead. The `playwright` command should already be
uv, run `uv run playwright install` instead. The `playwright` command should already be
installed as a dependency of the `drivers-web-scraper-markdownify` extra. For more details about
playwright, see [the playwright docs](https://playwright.dev/python/docs/library).

Expand Down
16 changes: 8 additions & 8 deletions docs/griptape-framework/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,18 @@ Install **griptape**:
pip install "griptape[all]" -U
```

### Using Poetry
### Using Uv

To get started with Griptape using Poetry first create a new poetry project from the terminal:
To get started with Griptape using [uv](https://docs.astral.sh/uv/), first create a new `uv` project from the terminal:

```
poetry new griptape-quickstart
uv init griptape-quickstart
```

Change your working directory to the new `griptape-quickstart` directory created by Poetry and add the the `griptape` dependency.
Change your working directory to the new `griptape-quickstart` directory created by `uv` and add the the `griptape` dependency.

```
poetry add "griptape[all]"
uv add "griptape[all]"
```

### Extras
Expand All @@ -53,16 +53,16 @@ However, if you wish to optimize the installation size or only require specific
To install just the core dependencies:

```
poetry add griptape
uv add griptape
```

To install specific extras (e.g., drivers for [AnthropicPromptDriver](./drivers/prompt-drivers.md#anthropic) and [PineconeVectorStoreDriver](./drivers/vector-store-drivers.md#pinecone)):

```
poetry add "griptape[drivers-prompt-anthropic,drivers-vector-pinecone]"
uv add "griptape[drivers-prompt-anthropic,drivers-vector-pinecone]"
```

For a comprehensive list of extras, please refer to the `[tool.poetry.extras]` section of Griptape's [pyproject.toml](https://github.com/griptape-ai/griptape/blob/main/pyproject.toml).
For a comprehensive list of extras, please refer to the `[project.optional-dependencies]` section of Griptape's [pyproject.toml](https://github.com/griptape-ai/griptape/blob/main/pyproject.toml).

## Build a Simple Agent

Expand Down
2 changes: 1 addition & 1 deletion docs/griptape-framework/tools/official-tools/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ You can specify a local working directory and environment variables during tool
```

```
poetry run python src/docs/task-memory.py
uv run python src/docs/task-memory.py
[08/12/24 15:13:56] INFO PromptTask 203ee958d1934811afe0bb86fb246e86
Input: Make 2 files and then list the files in the current directory
[08/12/24 15:13:58] INFO Subtask eb4e843b6f37498f9f0e85ada68114ac
Expand Down
Loading

0 comments on commit e4c3179

Please sign in to comment.