Compare commits

...

3 Commits

Author SHA1 Message Date
Lei Xu b57faf9835 rename gha task 2026-01-29 16:26:28 -08:00
Lei Xu 4800f31479 fixlint 2026-01-29 16:21:23 -08:00
Lei Xu ec464ad01e remove pydantic 1 support 2026-01-29 16:18:56 -08:00
3 changed files with 21 additions and 65 deletions
+2 -3
View File
@@ -25,7 +25,7 @@ jobs:
lint: lint:
name: "Lint" name: "Lint"
timeout-minutes: 30 timeout-minutes: 30
runs-on: "ubuntu-22.04" runs-on: "ubuntu-24.04"
defaults: defaults:
run: run:
shell: bash shell: bash
@@ -195,7 +195,7 @@ jobs:
# Make sure wheels are not included in the Rust cache # Make sure wheels are not included in the Rust cache
- name: Delete wheels - name: Delete wheels
run: rm -rf target/wheels run: rm -rf target/wheels
pydantic1x: min-deps:
timeout-minutes: 30 timeout-minutes: 30
runs-on: "ubuntu-24.04" runs-on: "ubuntu-24.04"
defaults: defaults:
@@ -217,7 +217,6 @@ jobs:
python-version: "3.10" python-version: "3.10"
- name: Install lancedb - name: Install lancedb
run: | run: |
pip install "pydantic<2"
pip install pyarrow==16 pip install pyarrow==16
pip install --extra-index-url https://pypi.fury.io/lance-format/ --extra-index-url https://pypi.fury.io/lancedb/ -e .[tests] pip install --extra-index-url https://pypi.fury.io/lance-format/ --extra-index-url https://pypi.fury.io/lancedb/ -e .[tests]
pip install tantivy pip install tantivy
+1 -1
View File
@@ -8,7 +8,7 @@ dependencies = [
"overrides>=0.7; python_version<'3.12'", "overrides>=0.7; python_version<'3.12'",
"packaging", "packaging",
"pyarrow>=16", "pyarrow>=16",
"pydantic>=1.10", "pydantic>=2",
"tqdm>=4.27.0", "tqdm>=4.27.0",
"lance-namespace>=0.3.2" "lance-namespace>=0.3.2"
] ]
+5 -48
View File
@@ -6,7 +6,6 @@
from __future__ import annotations from __future__ import annotations
import inspect import inspect
import sys
import types import types
from abc import ABC, abstractmethod from abc import ABC, abstractmethod
from datetime import date, datetime from datetime import date, datetime
@@ -141,14 +140,6 @@ def Vector(
raise TypeError("A list of numbers or numpy.ndarray is needed") raise TypeError("A list of numbers or numpy.ndarray is needed")
return cls(v) return cls(v)
if PYDANTIC_VERSION.major < 2:
@classmethod
def __modify_schema__(cls, field_schema: Dict[str, Any]):
field_schema["items"] = {"type": "number"}
field_schema["maxItems"] = dim
field_schema["minItems"] = dim
return FixedSizeList return FixedSizeList
@@ -226,18 +217,6 @@ def MultiVector(
def __get_validators__(cls) -> Generator[Callable, None, None]: def __get_validators__(cls) -> Generator[Callable, None, None]:
yield cls.validate yield cls.validate
# For pydantic v1
@classmethod
def validate(cls, v):
if not isinstance(v, (list, range)):
raise TypeError("A list of vectors is needed")
for vec in v:
if not isinstance(vec, (list, range, np.ndarray)) or len(vec) != dim:
raise TypeError(f"Each vector must be a list of {dim} numbers")
return cls(v)
if PYDANTIC_VERSION.major < 2:
@classmethod @classmethod
def __modify_schema__(cls, field_schema: Dict[str, Any]): def __modify_schema__(cls, field_schema: Dict[str, Any]):
field_schema["items"] = { field_schema["items"] = {
@@ -281,19 +260,9 @@ def _py_type_to_arrow_type(py_type: Type[Any], field: FieldInfo) -> pa.DataType:
) )
if PYDANTIC_VERSION.major < 2: def _pydantic_model_to_fields(model: pydantic.BaseModel) -> List[pa.Field]:
def _pydantic_model_to_fields(model: pydantic.BaseModel) -> List[pa.Field]:
return [ return [
_pydantic_to_field(name, field) for name, field in model.__fields__.items() _pydantic_to_field(name, field) for name, field in model.model_fields.items()
]
else:
def _pydantic_model_to_fields(model: pydantic.BaseModel) -> List[pa.Field]:
return [
_pydantic_to_field(name, field)
for name, field in model.model_fields.items()
] ]
@@ -334,7 +303,7 @@ def _unwrap_optional_annotation(annotation: Any) -> Any | None:
non_none = [arg for arg in args if arg is not type(None)] non_none = [arg for arg in args if arg is not type(None)]
if len(non_none) == 1 and len(non_none) != len(args): if len(non_none) == 1 and len(non_none) != len(args):
return non_none[0] return non_none[0]
elif sys.version_info >= (3, 10) and isinstance(annotation, types.UnionType): elif isinstance(annotation, types.UnionType):
args = annotation.__args__ args = annotation.__args__
non_none = [arg for arg in args if arg is not type(None)] non_none = [arg for arg in args if arg is not type(None)]
if len(non_none) == 1 and len(non_none) != len(args): if len(non_none) == 1 and len(non_none) != len(args):
@@ -367,7 +336,7 @@ def is_nullable(field: FieldInfo) -> bool:
if origin == Union: if origin == Union:
if any(typ is type(None) for typ in args): if any(typ is type(None) for typ in args):
return True return True
elif sys.version_info >= (3, 10) and isinstance(field.annotation, types.UnionType): elif isinstance(field.annotation, types.UnionType):
args = field.annotation.__args__ args = field.annotation.__args__
for typ in args: for typ in args:
if typ is type(None): if typ is type(None):
@@ -474,8 +443,6 @@ class LanceModel(pydantic.BaseModel):
@classmethod @classmethod
def safe_get_fields(cls): def safe_get_fields(cls):
if PYDANTIC_VERSION.major < 2:
return cls.__fields__
return cls.model_fields return cls.model_fields
@classmethod @classmethod
@@ -518,17 +485,7 @@ def get_extras(field_info: FieldInfo, key: str) -> Any:
return (field_info.field_info.extra or {}).get("json_schema_extra", {}).get(key) return (field_info.field_info.extra or {}).get("json_schema_extra", {}).get(key)
if PYDANTIC_VERSION.major < 2: def model_to_dict(model: pydantic.BaseModel) -> Dict[str, Any]:
def model_to_dict(model: pydantic.BaseModel) -> Dict[str, Any]:
"""
Convert a Pydantic model to a dictionary.
"""
return model.dict()
else:
def model_to_dict(model: pydantic.BaseModel) -> Dict[str, Any]:
""" """
Convert a Pydantic model to a dictionary. Convert a Pydantic model to a dictionary.
""" """