Skip to content

Commit

Permalink
INTPYTHON-468 Switch from Poetry to uv (#53)
Browse files Browse the repository at this point in the history
  • Loading branch information
blink1073 authored Jan 8, 2025
1 parent 7dd2330 commit cd8de7b
Show file tree
Hide file tree
Showing 18 changed files with 3,458 additions and 4,473 deletions.
93 changes: 0 additions & 93 deletions .github/actions/poetry_setup/action.yml

This file was deleted.

65 changes: 0 additions & 65 deletions .github/scripts/get_min_versions.py

This file was deleted.

38 changes: 7 additions & 31 deletions .github/workflows/_lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ on:
description: "From which folder this pipeline executes"

env:
POETRY_VERSION: "1.7.1"
WORKDIR: ${{ inputs.working-directory == '' && '.' || inputs.working-directory }}

# This env var allows us to get inline annotations when ruff has complaints.
Expand All @@ -35,40 +34,18 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }} + Poetry ${{ env.POETRY_VERSION }}
uses: "./.github/actions/poetry_setup"
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true
python-version: ${{ matrix.python-version }}
poetry-version: ${{ env.POETRY_VERSION }}
working-directory: ${{ inputs.working-directory }}
cache-key: lint-with-extras

- name: Check Poetry File
shell: bash
working-directory: ${{ inputs.working-directory }}
run: |
poetry check
- name: Check lock file
shell: bash
working-directory: ${{ inputs.working-directory }}
run: |
poetry lock --check
cache-dependency-glob: "${{ inputs.working-directory }}/uv.lock"

- uses: extractions/setup-just@v2

- name: Install dependencies
# Also installs dev/lint/test/typing dependencies, to ensure we have
# type hints for as many of our libraries as possible.
# This helps catch errors that require dependencies to be spotted, for example:
# https://github.com/langchain-ai/langchain/pull/10249/files#diff-935185cd488d015f026dcd9e19616ff62863e8cde8c0bee70318d3ccbca98341
#
# If you change this configuration, make sure to change the `cache-key`
# in the `poetry_setup` action above to stop using the old cache.
# It doesn't matter how you change it, any change will cause a cache-bust.
working-directory: ${{ inputs.working-directory }}
run: |
just install
run: just install

- name: Get .mypy_cache to speed up mypy
uses: actions/cache@v4
Expand All @@ -77,10 +54,9 @@ jobs:
with:
path: |
${{ env.WORKDIR }}/.mypy_cache
key: mypy-lint-${{ runner.os }}-${{ runner.arch }}-py${{ matrix.python-version }}-${{ inputs.working-directory }}-${{ hashFiles(format('{0}/poetry.lock', inputs.working-directory)) }}
key: mypy-lint-${{ runner.os }}-${{ runner.arch }}-py${{ matrix.python-version }}-${{ inputs.working-directory }}-${{ hashFiles(format('{0}/uv.lock', inputs.working-directory)) }}


- name: Analysing the code with our lint
working-directory: ${{ inputs.working-directory }}
run: |
just lint
run: just lint
71 changes: 24 additions & 47 deletions .github/workflows/_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ on:

env:
PYTHON_VERSION: "3.11"
POETRY_VERSION: "1.7.1"

jobs:
build:
Expand All @@ -34,13 +33,12 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Set up Python + Poetry ${{ env.POETRY_VERSION }}
uses: "./.github/actions/poetry_setup"
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true
python-version: ${{ env.PYTHON_VERSION }}
poetry-version: ${{ env.POETRY_VERSION }}
working-directory: ${{ inputs.working-directory }}
cache-key: release
cache-dependency-glob: "${{ inputs.working-directory }}/uv.lock"

# We want to keep this build stage *separate* from the release stage,
# so that there's no sharing of permissions between them.
Expand All @@ -54,7 +52,7 @@ jobs:
# > from the publish job.
# https://github.com/pypa/gh-action-pypi-publish#non-goals
- name: Build project for distribution
run: poetry build
run: uv build
working-directory: ${{ inputs.working-directory }}

- name: Upload build
Expand All @@ -68,8 +66,8 @@ jobs:
shell: bash
working-directory: ${{ inputs.working-directory }}
run: |
echo pkg-name="$(poetry version | cut -d ' ' -f 1)" >> $GITHUB_OUTPUT
echo version="$(poetry version --short)" >> $GITHUB_OUTPUT
echo pkg-name="$(hatch project metadata | jq -r .name)" >> $GITHUB_OUTPUT
echo version="$(hatch version)" >> $GITHUB_OUTPUT
test-pypi-publish:
needs:
Expand Down Expand Up @@ -102,12 +100,10 @@ jobs:
# - The package is published, and it breaks on the missing dependency when
# used in the real world.

- name: Set up Python + Poetry ${{ env.POETRY_VERSION }}
uses: "./.github/actions/poetry_setup"
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
poetry-version: ${{ env.POETRY_VERSION }}
working-directory: ${{ inputs.working-directory }}

- name: Import published package
shell: bash
Expand All @@ -125,12 +121,12 @@ jobs:
# - attempt install again after 5 seconds if it fails because there is
# sometimes a delay in availability on test pypi
run: |
poetry run pip install \
uv run pip install \
--extra-index-url https://test.pypi.org/simple/ \
"$PKG_NAME==$VERSION" || \
( \
sleep 5 && \
poetry run pip install \
uv run pip install \
--extra-index-url https://test.pypi.org/simple/ \
"$PKG_NAME==$VERSION" \
)
Expand All @@ -140,7 +136,7 @@ jobs:
# If "langgraph-checkpoint-mongodb", it's a namespace package => /-/.
[[ "$PKG_NAME" == "langgraph-checkpoint-mongodb" ]] && IMPORT_NAME="${PKG_NAME//-/.}"
poetry run python -c "import $IMPORT_NAME; print(dir($IMPORT_NAME))"
uv run python -c "import $IMPORT_NAME; print(dir($IMPORT_NAME))"
- uses: extractions/setup-just@v2

Expand All @@ -156,23 +152,17 @@ jobs:
PKG_NAME: ${{ needs.build.outputs.pkg-name }}
VERSION: ${{ needs.build.outputs.version }}
run: |
poetry run pip install \
uv run pip install \
--extra-index-url https://test.pypi.org/simple/ \
"$PKG_NAME==$VERSION"
- name: Start MongoDB
uses: supercharge/mongodb-github-action@1.11.0

- name: Run unit tests
run: just tests
working-directory: ${{ inputs.working-directory }}

- name: Start local Atlas
run: bash scripts/start_local_atlas.sh

- name: Get MongoDB URI
run: cat .local_atlas_uri >> $GITHUB_ENV

- name: Install Ollama
run: curl -fsSL https://ollama.com/install.sh | sh

Expand All @@ -186,22 +176,11 @@ jobs:
run: just integration_tests
working-directory: ${{ inputs.working-directory }}

- name: Get minimum versions
working-directory: ${{ inputs.working-directory }}
id: min-version
run: |
poetry run pip install packaging
min_versions="$(poetry run python $GITHUB_WORKSPACE/.github/scripts/get_min_versions.py pyproject.toml)"
echo "min-versions=$min_versions" >> "$GITHUB_OUTPUT"
echo "min-versions=$min_versions"
- name: Run unit tests with minimum dependency versions
if: ${{ steps.min-version.outputs.min-versions != '' }}
env:
MIN_VERSIONS: ${{ steps.min-version.outputs.min-versions }}
run: |
poetry run pip install $MIN_VERSIONS
just tests
uv sync --python=${{ matrix.python-version }} --resolution=lowest-direct
just test || git checkout uv.lock
git checkout uv.lock
working-directory: ${{ inputs.working-directory }}

publish:
Expand All @@ -225,13 +204,12 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Set up Python + Poetry ${{ env.POETRY_VERSION }}
uses: "./.github/actions/poetry_setup"
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true
python-version: ${{ env.PYTHON_VERSION }}
poetry-version: ${{ env.POETRY_VERSION }}
working-directory: ${{ inputs.working-directory }}
cache-key: release
cache-dependency-glob: "${{ inputs.working-directory }}/uv.lock"

- uses: actions/download-artifact@v4
with:
Expand Down Expand Up @@ -266,13 +244,12 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Set up Python + Poetry ${{ env.POETRY_VERSION }}
uses: "./.github/actions/poetry_setup"
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true
python-version: ${{ env.PYTHON_VERSION }}
poetry-version: ${{ env.POETRY_VERSION }}
working-directory: ${{ inputs.working-directory }}
cache-key: releaseartifact@v4
cache-dependency-glob: "${{ inputs.working-directory }}/uv.lock"

- uses: actions/download-artifact@v4
with:
Expand Down
Loading

0 comments on commit cd8de7b

Please sign in to comment.