Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

infra: migrate to uv #29566

Merged
merged 134 commits into from
Feb 6, 2025
Merged
Show file tree
Hide file tree
Changes from 67 commits
Commits
Show all changes
134 commits
Select commit Hold shift + click to select a range
b07e6be
update
ccurme Feb 2, 2025
f71cf38
update core
ccurme Feb 3, 2025
10f677f
remove tool.poetry
ccurme Feb 3, 2025
4202c14
core
ccurme Feb 3, 2025
6693a0c
todo: delete tool.pdm.dev-dependencies
ccurme Feb 3, 2025
a1a6ef1
update
ccurme Feb 3, 2025
e034999
add action to setup uv and python
ccurme Feb 3, 2025
b7bdf0b
update get_min_versions script
ccurme Feb 3, 2025
aa7637b
update workflows
ccurme Feb 3, 2025
070e12f
update check_diff script
ccurme Feb 3, 2025
dcbedef
update
ccurme Feb 3, 2025
4dcc659
update scripts (todo: fix)
ccurme Feb 3, 2025
ea838e8
x
ccurme Feb 3, 2025
7013870
x
ccurme Feb 3, 2025
dfce027
update get_min_versions
ccurme Feb 3, 2025
1a4af62
x
ccurme Feb 3, 2025
c71fc8b
x
ccurme Feb 3, 2025
e20603e
update dependency tests
ccurme Feb 3, 2025
1a22baf
x
ccurme Feb 3, 2025
d6e2af4
x
ccurme Feb 3, 2025
d9ce5f4
lint
ccurme Feb 3, 2025
fb79799
x
ccurme Feb 3, 2025
cfa56be
x
ccurme Feb 3, 2025
3898048
add optional dependencies
ccurme Feb 3, 2025
7a8d558
test extras
ccurme Feb 3, 2025
bc24f60
update release workflows
ccurme Feb 3, 2025
e939cd4
increment version
ccurme Feb 3, 2025
1c634f9
Revert "test extras"
ccurme Feb 3, 2025
dd47b8c
x
ccurme Feb 3, 2025
fb4adb4
x
ccurme Feb 3, 2025
d9d8735
x
ccurme Feb 3, 2025
0064cc4
test release with python 3.11
ccurme Feb 3, 2025
584a4bd
fix check_prerelease_dependencies script
ccurme Feb 3, 2025
407f331
Merge branch 'master' into cc/migrate_uv
ccurme Feb 4, 2025
7a3643e
increment core version
ccurme Feb 4, 2025
c1ea951
specify --frozen
ccurme Feb 4, 2025
d8faef3
set UV_FROZEN
ccurme Feb 4, 2025
4c24c8c
update text-splitters
ccurme Feb 4, 2025
b643307
add lxml to test dependencies
ccurme Feb 4, 2025
b5229bb
x
ccurme Feb 4, 2025
4361786
fix spacy constraints
ccurme Feb 4, 2025
d54b964
Revert: add lxml to test dependencies
ccurme Feb 4, 2025
2f2b06e
fix check_prerelease_dependencies script
ccurme Feb 4, 2025
4390092
x
ccurme Feb 4, 2025
d3b9a4e
bound ruff
ccurme Feb 4, 2025
488dfb4
x
ccurme Feb 4, 2025
795ebf0
x
ccurme Feb 4, 2025
e6136ca
x
ccurme Feb 4, 2025
98a0cf2
Revert "x"
ccurme Feb 4, 2025
1f30936
x
ccurme Feb 4, 2025
bc4c706
x
ccurme Feb 4, 2025
035892f
x
ccurme Feb 4, 2025
eb2d824
x
ccurme Feb 4, 2025
2358a5a
x
ccurme Feb 4, 2025
39c4129
x
ccurme Feb 4, 2025
3bb8ea6
x
ccurme Feb 4, 2025
c74e686
x
ccurme Feb 4, 2025
26c7a54
x
ccurme Feb 4, 2025
b432d3c
x
ccurme Feb 4, 2025
fbf271f
fix sqlite caching in test
ccurme Feb 4, 2025
42988b8
x
ccurme Feb 4, 2025
99ed91f
VIRTUAL_ENV: .venv
ccurme Feb 4, 2025
3dc938b
Revert "VIRTUAL_ENV: .venv"
ccurme Feb 4, 2025
38cb39f
x
ccurme Feb 4, 2025
a87d670
x
ccurme Feb 4, 2025
5f44833
x
ccurme Feb 4, 2025
03ae7d4
x
ccurme Feb 4, 2025
b0b0371
x
ccurme Feb 4, 2025
2620666
voyageai
ccurme Feb 4, 2025
ab9b38c
chroma
ccurme Feb 4, 2025
f990dfa
mistral
ccurme Feb 4, 2025
79bd2b6
prompty
ccurme Feb 4, 2025
9af02a5
exa
ccurme Feb 4, 2025
ff01ae6
fireworks
ccurme Feb 4, 2025
a1573ec
Merge branch 'master' into cc/migrate_uv
ccurme Feb 5, 2025
93ed105
groq
ccurme Feb 5, 2025
0d7dc22
deepseek
ccurme Feb 5, 2025
623781b
openai
ccurme Feb 5, 2025
2c8d365
xai
ccurme Feb 5, 2025
2cf7cd5
nomic
ccurme Feb 5, 2025
fb827c5
pinecone
ccurme Feb 5, 2025
2efa99b
qdrant
ccurme Feb 5, 2025
e6a7d1a
anthropic
ccurme Feb 5, 2025
938b59a
huggingface
ccurme Feb 5, 2025
0397f46
ollama
ccurme Feb 5, 2025
33e1e28
standard-tests
ccurme Feb 5, 2025
76ebfe6
uv doesn't automatically downgrade python version if it conflicts wit…
ccurme Feb 5, 2025
7b7ae76
x
ccurme Feb 5, 2025
c1e980a
temporarily just run cli in ci
ccurme Feb 5, 2025
9a140c5
x
ccurme Feb 5, 2025
1f93811
x
ccurme Feb 5, 2025
cc055b2
x
ccurme Feb 5, 2025
322ad54
x
ccurme Feb 5, 2025
42d980b
x
ccurme Feb 5, 2025
ac64ecc
Revert "temporarily just run cli in ci"
ccurme Feb 5, 2025
a2d6306
monorepo
ccurme Feb 5, 2025
e0d5fe6
update docs workflows and scripts
ccurme Feb 5, 2025
48909cf
update scheduled test job
ccurme Feb 5, 2025
ed46da3
temporarily disable ci checks
ccurme Feb 5, 2025
36b15b9
fix
ccurme Feb 5, 2025
edf8b65
x
ccurme Feb 5, 2025
ff3db37
x
ccurme Feb 5, 2025
84146f3
x
ccurme Feb 5, 2025
927b252
a
ccurme Feb 5, 2025
0f553cd
x
ccurme Feb 5, 2025
a510625
x
ccurme Feb 5, 2025
1aed3e9
x
ccurme Feb 5, 2025
76e9546
x
ccurme Feb 5, 2025
6498021
x
ccurme Feb 5, 2025
dbccfc6
x
ccurme Feb 5, 2025
42514d6
x
ccurme Feb 5, 2025
65e94a8
x
ccurme Feb 5, 2025
899eae0
x
ccurme Feb 5, 2025
a34c0c3
Revert "temporarily disable ci checks"
ccurme Feb 5, 2025
895d20c
x
ccurme Feb 5, 2025
78f0568
infra: update docs for uv migration (#29620)
ccurme Feb 5, 2025
bdf045f
increment core version
ccurme Feb 5, 2025
540ec89
update api doc build workflow
ccurme Feb 5, 2025
b42e3c4
increment text-splitters version
ccurme Feb 5, 2025
91fa2c3
increment openai version
ccurme Feb 5, 2025
88dca23
increment anthropic version
ccurme Feb 5, 2025
5db6442
update api doc build workflow
ccurme Feb 5, 2025
13c6712
update api doc build workflow
ccurme Feb 5, 2025
a40db45
x
ccurme Feb 6, 2025
26a75d9
Merge branch 'master' into cc/migrate_uv
ccurme Feb 6, 2025
1dafe0e
increment langchain version
ccurme Feb 6, 2025
f0c24fd
update api doc build workflow
ccurme Feb 6, 2025
77fad31
x
ccurme Feb 6, 2025
e1c7c45
x
ccurme Feb 6, 2025
5b224c4
x
ccurme Feb 6, 2025
6751e15
delete poetry lock files
ccurme Feb 6, 2025
542ed83
debug
ccurme Feb 6, 2025
e24da89
x
ccurme Feb 6, 2025
2b17d6e
parse uv pyproject.toml in create_api_rst.py
ccurme Feb 6, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .github/actions/uv_setup/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# TODO: https://docs.astral.sh/uv/guides/integration/github/#caching
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume this interacts ok with python-version but that would be main suspect if things go wrong with enable-cache: true


name: uv-install
description: Set up Python and uv

inputs:
python-version:
description: Python version, supporting MAJOR.MINOR only
required: true

env:
UV_VERSION: "0.5.25"

runs:
using: composite
steps:
- uses: actions/checkout@v4

- name: Install uv and set the python version
uses: astral-sh/setup-uv@v5
with:
version: ${{ env.UV_VERSION }}
python-version: ${{ inputs.python-version }}
29 changes: 16 additions & 13 deletions .github/scripts/check_diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
from pathlib import Path
import tomllib

from packaging.requirements import Requirement

from get_min_versions import get_min_version_from_toml


Expand Down Expand Up @@ -61,15 +63,17 @@ def dependents_graph() -> dict:

# load regular and test deps from pyproject.toml
with open(path, "rb") as f:
pyproject = tomllib.load(f)["tool"]["poetry"]
pyproject = tomllib.load(f)

pkg_dir = "libs" + "/".join(path.split("libs")[1].split("/")[:-1])
for dep in [
*pyproject["dependencies"].keys(),
*pyproject["group"]["test"]["dependencies"].keys(),
*pyproject["project"]["dependencies"],
*pyproject["dependency-groups"]["test"],
]:
requirement = Requirement(dep)
package_name = requirement.name
if "langchain" in dep:
dependents[dep].add(pkg_dir)
dependents[package_name].add(pkg_dir)
continue

# load extended deps from extended_testing_deps.txt
Expand Down Expand Up @@ -120,8 +124,7 @@ def _get_configs_for_single_dir(job: str, dir_: str) -> List[Dict[str, str]]:
py_versions = ["3.9", "3.10", "3.11", "3.12", "3.13"]
# custom logic for specific directories
elif dir_ == "libs/partners/milvus":
# milvus poetry doesn't allow 3.12 because they
# declare deps in funny way
# milvus doesn't allow 3.12 because they declare deps in funny way
py_versions = ["3.9", "3.11"]

elif dir_ in PY_312_MAX_PACKAGES:
Expand All @@ -148,17 +151,17 @@ def _get_configs_for_single_dir(job: str, dir_: str) -> List[Dict[str, str]]:
def _get_pydantic_test_configs(
dir_: str, *, python_version: str = "3.11"
) -> List[Dict[str, str]]:
with open("./libs/core/poetry.lock", "rb") as f:
core_poetry_lock_data = tomllib.load(f)
for package in core_poetry_lock_data["package"]:
with open("./libs/core/uv.lock", "rb") as f:
core_uv_lock_data = tomllib.load(f)
for package in core_uv_lock_data["package"]:
if package["name"] == "pydantic":
core_max_pydantic_minor = package["version"].split(".")[1]
break

with open(f"./{dir_}/poetry.lock", "rb") as f:
dir_poetry_lock_data = tomllib.load(f)
with open(f"./{dir_}/uv.lock", "rb") as f:
dir_uv_lock_data = tomllib.load(f)

for package in dir_poetry_lock_data["package"]:
for package in dir_uv_lock_data["package"]:
if package["name"] == "pydantic":
dir_max_pydantic_minor = package["version"].split(".")[1]
break
Expand Down Expand Up @@ -304,7 +307,7 @@ def _get_configs_for_multi_dirs(
f"Unknown lib: {file}. check_diff.py likely needs "
"an update for this new library!"
)
elif file.startswith("docs/") or file in ["pyproject.toml", "poetry.lock"]: # docs or root poetry files
elif file.startswith("docs/") or file in ["pyproject.toml", "uv.lock"]: # docs or root uv files
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might be worth adding a lint case that confirms there are no poetry.lock files in the tree

docs_edited = True
dirs_to_run["lint"].add(".")

Expand Down
11 changes: 5 additions & 6 deletions .github/scripts/check_prerelease_dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,25 @@
toml_data = tomllib.load(file)

# see if we're releasing an rc
version = toml_data["tool"]["poetry"]["version"]
version = toml_data["project"]["version"]
releasing_rc = "rc" in version or "dev" in version

# if not, iterate through dependencies and make sure none allow prereleases
if not releasing_rc:
dependencies = toml_data["tool"]["poetry"]["dependencies"]
for lib in dependencies:
dep_version = dependencies[lib]
dependencies = toml_data["project"]["dependencies"]
for dep_version in dependencies:
Comment on lines +18 to +19
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what changed here? why isn't it iterating over the keys anymore?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dependencies is no longer a dict matching dependency names to version constraints / markers etc. It is a list of dependency specifier strings.

dep_version_string = (
dep_version["version"] if isinstance(dep_version, dict) else dep_version
)

if "rc" in dep_version_string:
raise ValueError(
f"Dependency {lib} has a prerelease version. Please remove this."
f"Dependency {dep_version} has a prerelease version. Please remove this."
)

if isinstance(dep_version, dict) and dep_version.get(
"allow-prereleases", False
):
raise ValueError(
f"Dependency {lib} has allow-prereleases set to true. Please remove this."
f"Dependency {dep_version} has allow-prereleases set to true. Please remove this."
)
41 changes: 28 additions & 13 deletions .github/scripts/get_min_versions.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from collections import defaultdict
import sys
from typing import Optional

Expand All @@ -7,6 +8,7 @@
# for python 3.10 and below, which doesnt have stdlib tomllib
import tomli as tomllib

from packaging.requirements import Requirement
from packaging.specifiers import SpecifierSet
from packaging.version import Version

Expand Down Expand Up @@ -94,6 +96,23 @@ def get_minimum_version(package_name: str, spec_string: str) -> Optional[str]:
return str(min(valid_versions)) if valid_versions else None


def _check_python_version_from_requirement(
requirement: Requirement, python_version: str
) -> bool:
if not requirement.marker:
return True
else:
marker_str = str(requirement.marker)
if "python_version" or "python_full_version" in marker_str:
python_version_str = "".join(
char
for char in marker_str
if char.isdigit() or char in (".", "<", ">", "=", ",")
)
return check_python_version(python_version, python_version_str)
return True


def get_min_version_from_toml(
toml_path: str,
versions_for: str,
Expand All @@ -105,8 +124,10 @@ def get_min_version_from_toml(
with open(toml_path, "rb") as file:
toml_data = tomllib.load(file)

# Get the dependencies from tool.poetry.dependencies
dependencies = toml_data["tool"]["poetry"]["dependencies"]
dependencies = defaultdict(list)
for dep in toml_data["project"]["dependencies"]:
requirement = Requirement(dep)
dependencies[requirement.name].append(requirement)

# Initialize a dictionary to store the minimum versions
min_versions = {}
Expand All @@ -121,17 +142,11 @@ def get_min_version_from_toml(
if lib in dependencies:
if include and lib not in include:
continue
# Get the version string
version_string = dependencies[lib]

if isinstance(version_string, dict):
version_string = version_string["version"]
if isinstance(version_string, list):
version_string = [
vs
for vs in version_string
if check_python_version(python_version, vs["python"])
][0]["version"]
requirements = dependencies[lib]
for requirement in requirements:
if _check_python_version_from_requirement(requirement, python_version):
version_string = str(requirement.specifier)
break

# Use parse_version to get the minimum supported version from version_string
min_version = get_minimum_version(lib, version_string)
Expand Down
15 changes: 6 additions & 9 deletions .github/workflows/_compile_integration_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ on:
description: "Python version to use"

env:
POETRY_VERSION: "1.8.4"
UV_FROZEN: "true"

jobs:
build:
Expand All @@ -22,25 +22,22 @@ jobs:
working-directory: ${{ inputs.working-directory }}
runs-on: ubuntu-latest
timeout-minutes: 20
name: "poetry run pytest -m compile tests/integration_tests #${{ inputs.python-version }}"
name: "uv run pytest -m compile tests/integration_tests #${{ inputs.python-version }}"
steps:
- uses: actions/checkout@v4

- name: Set up Python ${{ inputs.python-version }} + Poetry ${{ env.POETRY_VERSION }}
uses: "./.github/actions/poetry_setup"
- name: Set up Python ${{ inputs.python-version }} + uv
uses: "./.github/actions/uv_setup"
with:
python-version: ${{ inputs.python-version }}
poetry-version: ${{ env.POETRY_VERSION }}
working-directory: ${{ inputs.working-directory }}
cache-key: compile-integration

- name: Install integration dependencies
shell: bash
run: poetry install --with=test_integration,test
run: uv sync --group test --group test_integration

- name: Check integration tests compile
shell: bash
run: poetry run pytest -m compile tests/integration_tests
run: uv run pytest -m compile tests/integration_tests

- name: Ensure the tests did not create any additional files
shell: bash
Expand Down
13 changes: 5 additions & 8 deletions .github/workflows/_integration_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ on:
description: "Python version to use"

env:
POETRY_VERSION: "1.8.4"
UV_FROZEN: "true"

jobs:
build:
Expand All @@ -24,22 +24,19 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Set up Python ${{ inputs.python-version }} + Poetry ${{ env.POETRY_VERSION }}
uses: "./.github/actions/poetry_setup"
- name: Set up Python ${{ inputs.python-version }} + uv
uses: "./.github/actions/uv_setup"
with:
python-version: ${{ inputs.python-version }}
poetry-version: ${{ env.POETRY_VERSION }}
working-directory: ${{ inputs.working-directory }}
cache-key: core

- name: Install dependencies
shell: bash
run: poetry install --with test,test_integration
run: uv sync --group test --group test_integration

- name: Install deps outside pyproject
if: ${{ startsWith(inputs.working-directory, 'libs/community/') }}
shell: bash
run: poetry run pip install "boto3<2" "google-cloud-aiplatform<2"
run: VIRTUAL_ENV=.venv uv pip install "boto3<2" "google-cloud-aiplatform<2"
Comment on lines 36 to +39
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can add these back into pyproject.toml (integration test group) now that we're on uv - these were removed because their dep histories aren't cached by pypi for poetry. uv should be able to figure it out though


- name: Run integration tests
shell: bash
Expand Down
47 changes: 7 additions & 40 deletions .github/workflows/_lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@ on:
description: "Python version to use"

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

# This env var allows us to get inline annotations when ruff has complaints.
RUFF_OUTPUT_FORMAT: github

UV_FROZEN: "true"

jobs:
build:
name: "make lint #${{ inputs.python-version }}"
Expand All @@ -27,25 +28,10 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Set up Python ${{ inputs.python-version }} + Poetry ${{ env.POETRY_VERSION }}
uses: "./.github/actions/poetry_setup"
- name: Set up Python ${{ inputs.python-version }} + uv
uses: "./.github/actions/uv_setup"
with:
python-version: ${{ inputs.python-version }}
poetry-version: ${{ env.POETRY_VERSION }}
working-directory: ${{ inputs.working-directory }}
cache-key: lint-with-extras

- name: Check Poetry File
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there an equivalent uv check, or not necessary? will uv_setup fail if uv.lock and pyproject.toml are out of sync?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's uv lock --check

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

- name: Install dependencies
# Also installs dev/lint/test/typing dependencies, to ensure we have
Expand All @@ -58,17 +44,7 @@ jobs:
# It doesn't matter how you change it, any change will cause a cache-bust.
working-directory: ${{ inputs.working-directory }}
run: |
poetry install --with lint,typing

- name: Get .mypy_cache to speed up mypy
uses: actions/cache@v4
env:
SEGMENT_DOWNLOAD_TIMEOUT_MIN: "2"
with:
path: |
${{ env.WORKDIR }}/.mypy_cache
key: mypy-lint-${{ runner.os }}-${{ runner.arch }}-py${{ inputs.python-version }}-${{ inputs.working-directory }}-${{ hashFiles(format('{0}/poetry.lock', inputs.working-directory)) }}

uv sync --group lint --group typing

- name: Analysing the code with our lint
working-directory: ${{ inputs.working-directory }}
Expand All @@ -87,21 +63,12 @@ jobs:
if: ${{ ! startsWith(inputs.working-directory, 'libs/partners/') }}
working-directory: ${{ inputs.working-directory }}
run: |
poetry install --with test
uv sync --group test
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

technically I think this is a functional change because this will remove lint/typing deps, whereas poetry install (without --sync) would only add deps, and not remove anything

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated in 06b99bd

- name: Install unit+integration test dependencies
if: ${{ startsWith(inputs.working-directory, 'libs/partners/') }}
working-directory: ${{ inputs.working-directory }}
run: |
poetry install --with test,test_integration

- name: Get .mypy_cache_test to speed up mypy
uses: actions/cache@v4
env:
SEGMENT_DOWNLOAD_TIMEOUT_MIN: "2"
with:
path: |
${{ env.WORKDIR }}/.mypy_cache_test
key: mypy-test-${{ runner.os }}-${{ runner.arch }}-py${{ inputs.python-version }}-${{ inputs.working-directory }}-${{ hashFiles(format('{0}/poetry.lock', inputs.working-directory)) }}
uv sync --group test --group test_integration

- name: Analysing the code with our lint
working-directory: ${{ inputs.working-directory }}
Expand Down
Loading
Loading