infra: update mypy 1.10, ruff 0.5 (#23721)
```python
"""python scripts/update_mypy_ruff.py"""
import glob
import tomllib
from pathlib import Path
import toml
import subprocess
import re
ROOT_DIR = Path(__file__).parents[1]
def main():
for path in glob.glob(str(ROOT_DIR / "libs/**/pyproject.toml"), recursive=True):
print(path)
with open(path, "rb") as f:
pyproject = tomllib.load(f)
try:
pyproject["tool"]["poetry"]["group"]["typing"]["dependencies"]["mypy"] = (
"^1.10"
)
pyproject["tool"]["poetry"]["group"]["lint"]["dependencies"]["ruff"] = (
"^0.5"
)
except KeyError:
continue
with open(path, "w") as f:
toml.dump(pyproject, f)
cwd = "/".join(path.split("/")[:-1])
completed = subprocess.run(
"poetry lock --no-update; poetry install --with typing; poetry run mypy . --no-color",
cwd=cwd,
shell=True,
capture_output=True,
text=True,
)
logs = completed.stdout.split("\n")
to_ignore = {}
for l in logs:
if re.match("^(.*)\:(\d+)\: error:.*\[(.*)\]", l):
path, line_no, error_type = re.match(
"^(.*)\:(\d+)\: error:.*\[(.*)\]", l
).groups()
if (path, line_no) in to_ignore:
to_ignore[(path, line_no)].append(error_type)
else:
to_ignore[(path, line_no)] = [error_type]
print(len(to_ignore))
for (error_path, line_no), error_types in to_ignore.items():
all_errors = ", ".join(error_types)
full_path = f"{cwd}/{error_path}"
try:
with open(full_path, "r") as f:
file_lines = f.readlines()
except FileNotFoundError:
continue
file_lines[int(line_no) - 1] = (
file_lines[int(line_no) - 1][:-1] + f" # type: ignore[{all_errors}]\n"
)
with open(full_path, "w") as f:
f.write("".join(file_lines))
subprocess.run(
"poetry run ruff format .; poetry run ruff --select I --fix .",
cwd=cwd,
shell=True,
capture_output=True,
text=True,
)
if __name__ == "__main__":
main()
```
2024-07-03 17:33:27 +00:00
|
|
|
import glob
|
2023-12-06 19:43:03 +00:00
|
|
|
import json
|
2023-12-15 20:21:59 +00:00
|
|
|
import os
|
infra: update mypy 1.10, ruff 0.5 (#23721)
```python
"""python scripts/update_mypy_ruff.py"""
import glob
import tomllib
from pathlib import Path
import toml
import subprocess
import re
ROOT_DIR = Path(__file__).parents[1]
def main():
for path in glob.glob(str(ROOT_DIR / "libs/**/pyproject.toml"), recursive=True):
print(path)
with open(path, "rb") as f:
pyproject = tomllib.load(f)
try:
pyproject["tool"]["poetry"]["group"]["typing"]["dependencies"]["mypy"] = (
"^1.10"
)
pyproject["tool"]["poetry"]["group"]["lint"]["dependencies"]["ruff"] = (
"^0.5"
)
except KeyError:
continue
with open(path, "w") as f:
toml.dump(pyproject, f)
cwd = "/".join(path.split("/")[:-1])
completed = subprocess.run(
"poetry lock --no-update; poetry install --with typing; poetry run mypy . --no-color",
cwd=cwd,
shell=True,
capture_output=True,
text=True,
)
logs = completed.stdout.split("\n")
to_ignore = {}
for l in logs:
if re.match("^(.*)\:(\d+)\: error:.*\[(.*)\]", l):
path, line_no, error_type = re.match(
"^(.*)\:(\d+)\: error:.*\[(.*)\]", l
).groups()
if (path, line_no) in to_ignore:
to_ignore[(path, line_no)].append(error_type)
else:
to_ignore[(path, line_no)] = [error_type]
print(len(to_ignore))
for (error_path, line_no), error_types in to_ignore.items():
all_errors = ", ".join(error_types)
full_path = f"{cwd}/{error_path}"
try:
with open(full_path, "r") as f:
file_lines = f.readlines()
except FileNotFoundError:
continue
file_lines[int(line_no) - 1] = (
file_lines[int(line_no) - 1][:-1] + f" # type: ignore[{all_errors}]\n"
)
with open(full_path, "w") as f:
f.write("".join(file_lines))
subprocess.run(
"poetry run ruff format .; poetry run ruff --select I --fix .",
cwd=cwd,
shell=True,
capture_output=True,
text=True,
)
if __name__ == "__main__":
main()
```
2024-07-03 17:33:27 +00:00
|
|
|
import sys
|
2024-06-17 20:50:31 +00:00
|
|
|
import tomllib
|
|
|
|
from collections import defaultdict
|
infra: update mypy 1.10, ruff 0.5 (#23721)
```python
"""python scripts/update_mypy_ruff.py"""
import glob
import tomllib
from pathlib import Path
import toml
import subprocess
import re
ROOT_DIR = Path(__file__).parents[1]
def main():
for path in glob.glob(str(ROOT_DIR / "libs/**/pyproject.toml"), recursive=True):
print(path)
with open(path, "rb") as f:
pyproject = tomllib.load(f)
try:
pyproject["tool"]["poetry"]["group"]["typing"]["dependencies"]["mypy"] = (
"^1.10"
)
pyproject["tool"]["poetry"]["group"]["lint"]["dependencies"]["ruff"] = (
"^0.5"
)
except KeyError:
continue
with open(path, "w") as f:
toml.dump(pyproject, f)
cwd = "/".join(path.split("/")[:-1])
completed = subprocess.run(
"poetry lock --no-update; poetry install --with typing; poetry run mypy . --no-color",
cwd=cwd,
shell=True,
capture_output=True,
text=True,
)
logs = completed.stdout.split("\n")
to_ignore = {}
for l in logs:
if re.match("^(.*)\:(\d+)\: error:.*\[(.*)\]", l):
path, line_no, error_type = re.match(
"^(.*)\:(\d+)\: error:.*\[(.*)\]", l
).groups()
if (path, line_no) in to_ignore:
to_ignore[(path, line_no)].append(error_type)
else:
to_ignore[(path, line_no)] = [error_type]
print(len(to_ignore))
for (error_path, line_no), error_types in to_ignore.items():
all_errors = ", ".join(error_types)
full_path = f"{cwd}/{error_path}"
try:
with open(full_path, "r") as f:
file_lines = f.readlines()
except FileNotFoundError:
continue
file_lines[int(line_no) - 1] = (
file_lines[int(line_no) - 1][:-1] + f" # type: ignore[{all_errors}]\n"
)
with open(full_path, "w") as f:
f.write("".join(file_lines))
subprocess.run(
"poetry run ruff format .; poetry run ruff --select I --fix .",
cwd=cwd,
shell=True,
capture_output=True,
text=True,
)
if __name__ == "__main__":
main()
```
2024-07-03 17:33:27 +00:00
|
|
|
from typing import Dict, List, Set
|
2024-07-15 22:48:53 +00:00
|
|
|
from pathlib import Path
|
infra: update mypy 1.10, ruff 0.5 (#23721)
```python
"""python scripts/update_mypy_ruff.py"""
import glob
import tomllib
from pathlib import Path
import toml
import subprocess
import re
ROOT_DIR = Path(__file__).parents[1]
def main():
for path in glob.glob(str(ROOT_DIR / "libs/**/pyproject.toml"), recursive=True):
print(path)
with open(path, "rb") as f:
pyproject = tomllib.load(f)
try:
pyproject["tool"]["poetry"]["group"]["typing"]["dependencies"]["mypy"] = (
"^1.10"
)
pyproject["tool"]["poetry"]["group"]["lint"]["dependencies"]["ruff"] = (
"^0.5"
)
except KeyError:
continue
with open(path, "w") as f:
toml.dump(pyproject, f)
cwd = "/".join(path.split("/")[:-1])
completed = subprocess.run(
"poetry lock --no-update; poetry install --with typing; poetry run mypy . --no-color",
cwd=cwd,
shell=True,
capture_output=True,
text=True,
)
logs = completed.stdout.split("\n")
to_ignore = {}
for l in logs:
if re.match("^(.*)\:(\d+)\: error:.*\[(.*)\]", l):
path, line_no, error_type = re.match(
"^(.*)\:(\d+)\: error:.*\[(.*)\]", l
).groups()
if (path, line_no) in to_ignore:
to_ignore[(path, line_no)].append(error_type)
else:
to_ignore[(path, line_no)] = [error_type]
print(len(to_ignore))
for (error_path, line_no), error_types in to_ignore.items():
all_errors = ", ".join(error_types)
full_path = f"{cwd}/{error_path}"
try:
with open(full_path, "r") as f:
file_lines = f.readlines()
except FileNotFoundError:
continue
file_lines[int(line_no) - 1] = (
file_lines[int(line_no) - 1][:-1] + f" # type: ignore[{all_errors}]\n"
)
with open(full_path, "w") as f:
f.write("".join(file_lines))
subprocess.run(
"poetry run ruff format .; poetry run ruff --select I --fix .",
cwd=cwd,
shell=True,
capture_output=True,
text=True,
)
if __name__ == "__main__":
main()
```
2024-07-03 17:33:27 +00:00
|
|
|
|
2023-12-06 19:43:03 +00:00
|
|
|
|
2024-02-24 00:39:08 +00:00
|
|
|
LANGCHAIN_DIRS = [
|
2023-12-06 19:43:03 +00:00
|
|
|
"libs/core",
|
2024-03-01 02:33:21 +00:00
|
|
|
"libs/text-splitters",
|
2023-12-06 19:43:03 +00:00
|
|
|
"libs/langchain",
|
2024-05-14 02:50:36 +00:00
|
|
|
"libs/community",
|
2023-12-06 19:43:03 +00:00
|
|
|
"libs/experimental",
|
2024-02-24 00:39:08 +00:00
|
|
|
]
|
2023-12-06 19:43:03 +00:00
|
|
|
|
infra: update mypy 1.10, ruff 0.5 (#23721)
```python
"""python scripts/update_mypy_ruff.py"""
import glob
import tomllib
from pathlib import Path
import toml
import subprocess
import re
ROOT_DIR = Path(__file__).parents[1]
def main():
for path in glob.glob(str(ROOT_DIR / "libs/**/pyproject.toml"), recursive=True):
print(path)
with open(path, "rb") as f:
pyproject = tomllib.load(f)
try:
pyproject["tool"]["poetry"]["group"]["typing"]["dependencies"]["mypy"] = (
"^1.10"
)
pyproject["tool"]["poetry"]["group"]["lint"]["dependencies"]["ruff"] = (
"^0.5"
)
except KeyError:
continue
with open(path, "w") as f:
toml.dump(pyproject, f)
cwd = "/".join(path.split("/")[:-1])
completed = subprocess.run(
"poetry lock --no-update; poetry install --with typing; poetry run mypy . --no-color",
cwd=cwd,
shell=True,
capture_output=True,
text=True,
)
logs = completed.stdout.split("\n")
to_ignore = {}
for l in logs:
if re.match("^(.*)\:(\d+)\: error:.*\[(.*)\]", l):
path, line_no, error_type = re.match(
"^(.*)\:(\d+)\: error:.*\[(.*)\]", l
).groups()
if (path, line_no) in to_ignore:
to_ignore[(path, line_no)].append(error_type)
else:
to_ignore[(path, line_no)] = [error_type]
print(len(to_ignore))
for (error_path, line_no), error_types in to_ignore.items():
all_errors = ", ".join(error_types)
full_path = f"{cwd}/{error_path}"
try:
with open(full_path, "r") as f:
file_lines = f.readlines()
except FileNotFoundError:
continue
file_lines[int(line_no) - 1] = (
file_lines[int(line_no) - 1][:-1] + f" # type: ignore[{all_errors}]\n"
)
with open(full_path, "w") as f:
f.write("".join(file_lines))
subprocess.run(
"poetry run ruff format .; poetry run ruff --select I --fix .",
cwd=cwd,
shell=True,
capture_output=True,
text=True,
)
if __name__ == "__main__":
main()
```
2024-07-03 17:33:27 +00:00
|
|
|
|
2024-06-19 19:30:56 +00:00
|
|
|
def all_package_dirs() -> Set[str]:
|
infra: update mypy 1.10, ruff 0.5 (#23721)
```python
"""python scripts/update_mypy_ruff.py"""
import glob
import tomllib
from pathlib import Path
import toml
import subprocess
import re
ROOT_DIR = Path(__file__).parents[1]
def main():
for path in glob.glob(str(ROOT_DIR / "libs/**/pyproject.toml"), recursive=True):
print(path)
with open(path, "rb") as f:
pyproject = tomllib.load(f)
try:
pyproject["tool"]["poetry"]["group"]["typing"]["dependencies"]["mypy"] = (
"^1.10"
)
pyproject["tool"]["poetry"]["group"]["lint"]["dependencies"]["ruff"] = (
"^0.5"
)
except KeyError:
continue
with open(path, "w") as f:
toml.dump(pyproject, f)
cwd = "/".join(path.split("/")[:-1])
completed = subprocess.run(
"poetry lock --no-update; poetry install --with typing; poetry run mypy . --no-color",
cwd=cwd,
shell=True,
capture_output=True,
text=True,
)
logs = completed.stdout.split("\n")
to_ignore = {}
for l in logs:
if re.match("^(.*)\:(\d+)\: error:.*\[(.*)\]", l):
path, line_no, error_type = re.match(
"^(.*)\:(\d+)\: error:.*\[(.*)\]", l
).groups()
if (path, line_no) in to_ignore:
to_ignore[(path, line_no)].append(error_type)
else:
to_ignore[(path, line_no)] = [error_type]
print(len(to_ignore))
for (error_path, line_no), error_types in to_ignore.items():
all_errors = ", ".join(error_types)
full_path = f"{cwd}/{error_path}"
try:
with open(full_path, "r") as f:
file_lines = f.readlines()
except FileNotFoundError:
continue
file_lines[int(line_no) - 1] = (
file_lines[int(line_no) - 1][:-1] + f" # type: ignore[{all_errors}]\n"
)
with open(full_path, "w") as f:
f.write("".join(file_lines))
subprocess.run(
"poetry run ruff format .; poetry run ruff --select I --fix .",
cwd=cwd,
shell=True,
capture_output=True,
text=True,
)
if __name__ == "__main__":
main()
```
2024-07-03 17:33:27 +00:00
|
|
|
return {
|
|
|
|
"/".join(path.split("/")[:-1]).lstrip("./")
|
|
|
|
for path in glob.glob("./libs/**/pyproject.toml", recursive=True)
|
|
|
|
if "libs/cli" not in path and "libs/standard-tests" not in path
|
|
|
|
}
|
2024-06-19 19:30:56 +00:00
|
|
|
|
|
|
|
|
2024-06-17 20:50:31 +00:00
|
|
|
def dependents_graph() -> dict:
|
2024-07-15 22:48:53 +00:00
|
|
|
"""
|
|
|
|
Construct a mapping of package -> dependents, such that we can
|
|
|
|
run tests on all dependents of a package when a change is made.
|
|
|
|
"""
|
2024-06-17 20:50:31 +00:00
|
|
|
dependents = defaultdict(set)
|
|
|
|
|
|
|
|
for path in glob.glob("./libs/**/pyproject.toml", recursive=True):
|
|
|
|
if "template" in path:
|
|
|
|
continue
|
2024-07-15 22:48:53 +00:00
|
|
|
|
|
|
|
# load regular and test deps from pyproject.toml
|
2024-06-17 20:50:31 +00:00
|
|
|
with open(path, "rb") as f:
|
infra: update mypy 1.10, ruff 0.5 (#23721)
```python
"""python scripts/update_mypy_ruff.py"""
import glob
import tomllib
from pathlib import Path
import toml
import subprocess
import re
ROOT_DIR = Path(__file__).parents[1]
def main():
for path in glob.glob(str(ROOT_DIR / "libs/**/pyproject.toml"), recursive=True):
print(path)
with open(path, "rb") as f:
pyproject = tomllib.load(f)
try:
pyproject["tool"]["poetry"]["group"]["typing"]["dependencies"]["mypy"] = (
"^1.10"
)
pyproject["tool"]["poetry"]["group"]["lint"]["dependencies"]["ruff"] = (
"^0.5"
)
except KeyError:
continue
with open(path, "w") as f:
toml.dump(pyproject, f)
cwd = "/".join(path.split("/")[:-1])
completed = subprocess.run(
"poetry lock --no-update; poetry install --with typing; poetry run mypy . --no-color",
cwd=cwd,
shell=True,
capture_output=True,
text=True,
)
logs = completed.stdout.split("\n")
to_ignore = {}
for l in logs:
if re.match("^(.*)\:(\d+)\: error:.*\[(.*)\]", l):
path, line_no, error_type = re.match(
"^(.*)\:(\d+)\: error:.*\[(.*)\]", l
).groups()
if (path, line_no) in to_ignore:
to_ignore[(path, line_no)].append(error_type)
else:
to_ignore[(path, line_no)] = [error_type]
print(len(to_ignore))
for (error_path, line_no), error_types in to_ignore.items():
all_errors = ", ".join(error_types)
full_path = f"{cwd}/{error_path}"
try:
with open(full_path, "r") as f:
file_lines = f.readlines()
except FileNotFoundError:
continue
file_lines[int(line_no) - 1] = (
file_lines[int(line_no) - 1][:-1] + f" # type: ignore[{all_errors}]\n"
)
with open(full_path, "w") as f:
f.write("".join(file_lines))
subprocess.run(
"poetry run ruff format .; poetry run ruff --select I --fix .",
cwd=cwd,
shell=True,
capture_output=True,
text=True,
)
if __name__ == "__main__":
main()
```
2024-07-03 17:33:27 +00:00
|
|
|
pyproject = tomllib.load(f)["tool"]["poetry"]
|
2024-07-15 22:48:53 +00:00
|
|
|
|
2024-06-17 20:50:31 +00:00
|
|
|
pkg_dir = "libs" + "/".join(path.split("libs")[1].split("/")[:-1])
|
2024-07-15 22:48:53 +00:00
|
|
|
for dep in [
|
|
|
|
*pyproject["dependencies"].keys(),
|
|
|
|
*pyproject["group"]["test"]["dependencies"].keys(),
|
|
|
|
]:
|
2024-06-17 20:50:31 +00:00
|
|
|
if "langchain" in dep:
|
|
|
|
dependents[dep].add(pkg_dir)
|
2024-07-15 22:48:53 +00:00
|
|
|
continue
|
|
|
|
|
|
|
|
# load extended deps from extended_testing_deps.txt
|
|
|
|
package_path = Path(path).parent
|
|
|
|
extended_requirement_path = package_path / "extended_testing_deps.txt"
|
|
|
|
if extended_requirement_path.exists():
|
|
|
|
with open(extended_requirement_path, "r") as f:
|
|
|
|
extended_deps = f.read().splitlines()
|
|
|
|
for depline in extended_deps:
|
|
|
|
if depline.startswith("-e "):
|
|
|
|
# editable dependency
|
|
|
|
assert depline.startswith(
|
|
|
|
"-e ../partners/"
|
|
|
|
), "Extended test deps should only editable install partner packages"
|
|
|
|
partner = depline.split("partners/")[1]
|
|
|
|
dep = f"langchain-{partner}"
|
|
|
|
else:
|
|
|
|
dep = depline.split("==")[0]
|
|
|
|
|
|
|
|
if "langchain" in dep:
|
|
|
|
dependents[dep].add(pkg_dir)
|
2024-06-17 20:50:31 +00:00
|
|
|
return dependents
|
|
|
|
|
|
|
|
|
|
|
|
def add_dependents(dirs_to_eval: Set[str], dependents: dict) -> List[str]:
|
|
|
|
updated = set()
|
|
|
|
for dir_ in dirs_to_eval:
|
|
|
|
# handle core manually because it has so many dependents
|
|
|
|
if "core" in dir_:
|
|
|
|
updated.add(dir_)
|
|
|
|
continue
|
|
|
|
pkg = "langchain-" + dir_.split("/")[-1]
|
|
|
|
updated.update(dependents[pkg])
|
|
|
|
updated.add(dir_)
|
|
|
|
return list(updated)
|
|
|
|
|
|
|
|
|
2024-07-10 22:45:18 +00:00
|
|
|
def _get_configs_for_single_dir(job: str, dir_: str) -> List[Dict[str, str]]:
|
2024-08-02 01:23:37 +00:00
|
|
|
if dir_ == "libs/core":
|
|
|
|
return [
|
|
|
|
{"working-directory": dir_, "python-version": f"3.{v}"}
|
|
|
|
for v in range(8, 13)
|
|
|
|
]
|
2024-07-10 22:45:18 +00:00
|
|
|
min_python = "3.8"
|
|
|
|
max_python = "3.12"
|
|
|
|
|
|
|
|
# custom logic for specific directories
|
|
|
|
if dir_ == "libs/partners/milvus":
|
|
|
|
# milvus poetry doesn't allow 3.12 because they
|
|
|
|
# declare deps in funny way
|
|
|
|
max_python = "3.11"
|
|
|
|
|
2024-07-26 21:17:11 +00:00
|
|
|
if dir_ in ["libs/community", "libs/langchain"] and job == "extended-tests":
|
2024-07-26 21:10:14 +00:00
|
|
|
# community extended test resolution in 3.12 is slow
|
|
|
|
# even in uv
|
|
|
|
max_python = "3.11"
|
|
|
|
|
2024-07-30 18:43:10 +00:00
|
|
|
if dir_ == "libs/community" and job == "compile-integration-tests":
|
|
|
|
# community integration deps are slow in 3.12
|
|
|
|
max_python = "3.11"
|
|
|
|
|
2024-07-10 22:45:18 +00:00
|
|
|
return [
|
|
|
|
{"working-directory": dir_, "python-version": min_python},
|
|
|
|
{"working-directory": dir_, "python-version": max_python},
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
def _get_configs_for_multi_dirs(
|
|
|
|
job: str, dirs_to_run: List[str], dependents: dict
|
|
|
|
) -> List[Dict[str, str]]:
|
|
|
|
if job == "lint":
|
|
|
|
dirs = add_dependents(
|
|
|
|
dirs_to_run["lint"] | dirs_to_run["test"] | dirs_to_run["extended-test"],
|
|
|
|
dependents,
|
|
|
|
)
|
|
|
|
elif job in ["test", "compile-integration-tests", "dependencies"]:
|
|
|
|
dirs = add_dependents(
|
|
|
|
dirs_to_run["test"] | dirs_to_run["extended-test"], dependents
|
|
|
|
)
|
|
|
|
elif job == "extended-tests":
|
|
|
|
dirs = list(dirs_to_run["extended-test"])
|
|
|
|
else:
|
|
|
|
raise ValueError(f"Unknown job: {job}")
|
|
|
|
|
|
|
|
return [
|
|
|
|
config for dir_ in dirs for config in _get_configs_for_single_dir(job, dir_)
|
|
|
|
]
|
|
|
|
|
|
|
|
|
2023-12-06 19:43:03 +00:00
|
|
|
if __name__ == "__main__":
|
|
|
|
files = sys.argv[1:]
|
2024-02-24 00:39:08 +00:00
|
|
|
|
|
|
|
dirs_to_run: Dict[str, set] = {
|
|
|
|
"lint": set(),
|
|
|
|
"test": set(),
|
|
|
|
"extended-test": set(),
|
|
|
|
}
|
2024-04-18 23:42:03 +00:00
|
|
|
docs_edited = False
|
2023-12-06 19:43:03 +00:00
|
|
|
|
2024-06-19 19:30:56 +00:00
|
|
|
if len(files) >= 300:
|
2024-01-03 21:30:16 +00:00
|
|
|
# max diff length is 300 files - there are likely files missing
|
2024-06-19 19:30:56 +00:00
|
|
|
dirs_to_run["lint"] = all_package_dirs()
|
|
|
|
dirs_to_run["test"] = all_package_dirs()
|
|
|
|
dirs_to_run["extended-test"] = set(LANGCHAIN_DIRS)
|
2023-12-06 19:43:03 +00:00
|
|
|
for file in files:
|
|
|
|
if any(
|
|
|
|
file.startswith(dir_)
|
|
|
|
for dir_ in (
|
|
|
|
".github/workflows",
|
|
|
|
".github/tools",
|
|
|
|
".github/actions",
|
|
|
|
".github/scripts/check_diff.py",
|
|
|
|
)
|
|
|
|
):
|
2024-02-24 00:39:08 +00:00
|
|
|
# add all LANGCHAIN_DIRS for infra changes
|
|
|
|
dirs_to_run["extended-test"].update(LANGCHAIN_DIRS)
|
|
|
|
dirs_to_run["lint"].add(".")
|
|
|
|
|
|
|
|
if any(file.startswith(dir_) for dir_ in LANGCHAIN_DIRS):
|
|
|
|
# add that dir and all dirs after in LANGCHAIN_DIRS
|
|
|
|
# for extended testing
|
|
|
|
found = False
|
|
|
|
for dir_ in LANGCHAIN_DIRS:
|
|
|
|
if file.startswith(dir_):
|
|
|
|
found = True
|
|
|
|
if found:
|
|
|
|
dirs_to_run["extended-test"].add(dir_)
|
2024-04-09 19:43:00 +00:00
|
|
|
elif file.startswith("libs/standard-tests"):
|
|
|
|
# TODO: update to include all packages that rely on standard-tests (all partner packages)
|
|
|
|
# note: won't run on external repo partners
|
|
|
|
dirs_to_run["lint"].add("libs/standard-tests")
|
|
|
|
dirs_to_run["test"].add("libs/partners/mistralai")
|
|
|
|
dirs_to_run["test"].add("libs/partners/openai")
|
2024-04-16 16:12:36 +00:00
|
|
|
dirs_to_run["test"].add("libs/partners/anthropic")
|
|
|
|
dirs_to_run["test"].add("libs/partners/ai21")
|
|
|
|
dirs_to_run["test"].add("libs/partners/fireworks")
|
|
|
|
dirs_to_run["test"].add("libs/partners/groq")
|
2024-04-09 19:43:00 +00:00
|
|
|
|
2024-03-13 03:48:56 +00:00
|
|
|
elif file.startswith("libs/cli"):
|
|
|
|
# todo: add cli makefile
|
|
|
|
pass
|
2024-02-24 00:39:08 +00:00
|
|
|
elif file.startswith("libs/partners"):
|
2023-12-06 19:43:03 +00:00
|
|
|
partner_dir = file.split("/")[2]
|
2024-03-28 20:45:59 +00:00
|
|
|
if os.path.isdir(f"libs/partners/{partner_dir}") and [
|
|
|
|
filename
|
|
|
|
for filename in os.listdir(f"libs/partners/{partner_dir}")
|
|
|
|
if not filename.startswith(".")
|
|
|
|
] != ["README.md"]:
|
|
|
|
dirs_to_run["test"].add(f"libs/partners/{partner_dir}")
|
2024-03-01 01:49:28 +00:00
|
|
|
# Skip if the directory was deleted or is just a tombstone readme
|
2023-12-06 19:43:03 +00:00
|
|
|
elif file.startswith("libs/"):
|
2024-02-24 00:39:08 +00:00
|
|
|
raise ValueError(
|
|
|
|
f"Unknown lib: {file}. check_diff.py likely needs "
|
|
|
|
"an update for this new library!"
|
|
|
|
)
|
|
|
|
elif any(file.startswith(p) for p in ["docs/", "templates/", "cookbook/"]):
|
2024-04-18 23:42:03 +00:00
|
|
|
if file.startswith("docs/"):
|
|
|
|
docs_edited = True
|
2024-02-24 00:39:08 +00:00
|
|
|
dirs_to_run["lint"].add(".")
|
2024-02-23 00:53:10 +00:00
|
|
|
|
2024-06-17 20:50:31 +00:00
|
|
|
dependents = dependents_graph()
|
|
|
|
|
2024-07-10 22:45:18 +00:00
|
|
|
# we now have dirs_by_job
|
|
|
|
# todo: clean this up
|
|
|
|
|
|
|
|
map_job_to_configs = {
|
|
|
|
job: _get_configs_for_multi_dirs(job, dirs_to_run, dependents)
|
|
|
|
for job in [
|
|
|
|
"lint",
|
|
|
|
"test",
|
|
|
|
"extended-tests",
|
|
|
|
"compile-integration-tests",
|
|
|
|
"dependencies",
|
|
|
|
]
|
2024-02-24 00:39:08 +00:00
|
|
|
}
|
2024-07-10 22:45:18 +00:00
|
|
|
map_job_to_configs["test-doc-imports"] = (
|
|
|
|
[{"python-version": "3.12"}] if docs_edited else []
|
|
|
|
)
|
|
|
|
|
|
|
|
for key, value in map_job_to_configs.items():
|
2024-02-24 00:39:08 +00:00
|
|
|
json_output = json.dumps(value)
|
2024-05-22 22:21:08 +00:00
|
|
|
print(f"{key}={json_output}")
|