-
Notifications
You must be signed in to change notification settings - Fork 16.6k
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
infra: migrate to uv #29566
Changes from 67 commits
b07e6be
f71cf38
10f677f
4202c14
6693a0c
a1a6ef1
e034999
b7bdf0b
aa7637b
070e12f
dcbedef
4dcc659
ea838e8
7013870
dfce027
1a4af62
c71fc8b
e20603e
1a22baf
d6e2af4
d9ce5f4
fb79799
cfa56be
3898048
7a8d558
bc24f60
e939cd4
1c634f9
dd47b8c
fb4adb4
d9d8735
0064cc4
584a4bd
407f331
7a3643e
c1ea951
d8faef3
4c24c8c
b643307
b5229bb
4361786
d54b964
2f2b06e
4390092
d3b9a4e
488dfb4
795ebf0
e6136ca
98a0cf2
1f30936
bc4c706
035892f
eb2d824
2358a5a
39c4129
3bb8ea6
c74e686
26c7a54
b432d3c
fbf271f
42988b8
99ed91f
3dc938b
38cb39f
a87d670
5f44833
03ae7d4
b0b0371
2620666
ab9b38c
f990dfa
79bd2b6
9af02a5
ff01ae6
a1573ec
93ed105
0d7dc22
623781b
2c8d365
2cf7cd5
fb827c5
2efa99b
e6a7d1a
938b59a
0397f46
33e1e28
76ebfe6
7b7ae76
c1e980a
9a140c5
1f93811
cc055b2
322ad54
42d980b
ac64ecc
a2d6306
e0d5fe6
48909cf
ed46da3
36b15b9
edf8b65
ff3db37
84146f3
927b252
0f553cd
a510625
1aed3e9
76e9546
6498021
dbccfc6
42514d6
65e94a8
899eae0
a34c0c3
895d20c
78f0568
bdf045f
540ec89
b42e3c4
91fa2c3
88dca23
5db6442
13c6712
a40db45
26a75d9
1dafe0e
f0c24fd
77fad31
e1c7c45
5b224c4
6751e15
542ed83
e24da89
2b17d6e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# TODO: https://docs.astral.sh/uv/guides/integration/github/#caching | ||
|
||
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 }} |
efriis marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
||
|
||
|
@@ -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 | ||
|
@@ -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 | ||
efriis marked this conversation as resolved.
Show resolved
Hide resolved
|
||
py_versions = ["3.9", "3.11"] | ||
|
||
elif dir_ in PY_312_MAX_PACKAGES: | ||
|
@@ -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 | ||
|
@@ -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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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(".") | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what changed here? why isn't it iterating over the keys anymore? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
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." | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,7 @@ on: | |
description: "Python version to use" | ||
|
||
env: | ||
POETRY_VERSION: "1.8.4" | ||
UV_FROZEN: "true" | ||
|
||
jobs: | ||
build: | ||
|
@@ -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
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
|
||
- name: Run integration tests | ||
shell: bash | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 }}" | ||
|
@@ -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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's |
||
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 | ||
|
@@ -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 }} | ||
|
@@ -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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 }} | ||
|
There was a problem hiding this comment.
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 withenable-cache: true