diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 647780ea..98964aa1 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -32,9 +32,11 @@ jobs: run: | pip install -e . pip install tantivy@git+https://github.com/quickwit-oss/tantivy-py#164adc87e1a033117001cf70e38c82a53014d985 - pip install pytest pytest-mock black + pip install pytest pytest-mock black isort - name: Black run: black --check --diff --no-color --quiet . + - name: isort + run: isort --check --diff --quiet . - name: Run tests run: pytest -x -v --durations=30 tests - name: doctest diff --git a/docs/src/examples/modal_langchain.py b/docs/src/examples/modal_langchain.py index f929b6d4..20c9960a 100644 --- a/docs/src/examples/modal_langchain.py +++ b/docs/src/examples/modal_langchain.py @@ -1,18 +1,19 @@ -import sys -from modal import Secret, Stub, Image, web_endpoint -import lancedb -import re import pickle -import requests +import re +import sys import zipfile from pathlib import Path +import requests +from langchain.chains import RetrievalQA from langchain.document_loaders import UnstructuredHTMLLoader from langchain.embeddings import OpenAIEmbeddings +from langchain.llms import OpenAI from langchain.text_splitter import RecursiveCharacterTextSplitter from langchain.vectorstores import LanceDB -from langchain.llms import OpenAI -from langchain.chains import RetrievalQA +from modal import Image, Secret, Stub, web_endpoint + +import lancedb lancedb_image = Image.debian_slim().pip_install( "lancedb", "langchain", "openai", "pandas", "tiktoken", "unstructured", "tabulate" diff --git a/docs/src/notebooks/diffusiondb/datagen.py b/docs/src/notebooks/diffusiondb/datagen.py index 493b81d8..9218d9cf 100755 --- a/docs/src/notebooks/diffusiondb/datagen.py +++ b/docs/src/notebooks/diffusiondb/datagen.py @@ -21,12 +21,13 @@ from argparse import ArgumentParser from multiprocessing import Pool import lance -import lancedb import pyarrow as pa from datasets import load_dataset from PIL import Image from transformers import CLIPModel, CLIPProcessor, CLIPTokenizerFast +import lancedb + MODEL_ID = "openai/clip-vit-base-patch32" device = "cuda" diff --git a/python/lancedb/context.py b/python/lancedb/context.py index a90b8f70..219f90f7 100644 --- a/python/lancedb/context.py +++ b/python/lancedb/context.py @@ -13,7 +13,8 @@ from __future__ import annotations import pandas as pd -from .exceptions import MissingValueError, MissingColumnError + +from .exceptions import MissingColumnError, MissingValueError def contextualize(raw_df: pd.DataFrame) -> Contextualizer: diff --git a/python/lancedb/db.py b/python/lancedb/db.py index ea1e9abf..80b04641 100644 --- a/python/lancedb/db.py +++ b/python/lancedb/db.py @@ -12,18 +12,17 @@ # limitations under the License. from __future__ import annotations -import functools +import functools import os from pathlib import Path -import os import pyarrow as pa from pyarrow import fs from .common import DATA, URI from .table import LanceTable -from .util import get_uri_scheme, get_uri_location +from .util import get_uri_location, get_uri_scheme class LanceDBConnection: diff --git a/python/lancedb/query.py b/python/lancedb/query.py index 10dc6bc1..cb1e51c7 100644 --- a/python/lancedb/query.py +++ b/python/lancedb/query.py @@ -11,12 +11,13 @@ # See the License for the specific language governing permissions and # limitations under the License. from __future__ import annotations + +import asyncio from typing import Awaitable, Literal import numpy as np import pandas as pd import pyarrow as pa -import asyncio from .common import VECTOR_COLUMN_NAME diff --git a/python/lancedb/remote/__init__.py b/python/lancedb/remote/__init__.py index 8932c666..090b124a 100644 --- a/python/lancedb/remote/__init__.py +++ b/python/lancedb/remote/__init__.py @@ -13,10 +13,10 @@ import abc from typing import List, Optional + import attr import pandas as pd import pyarrow as pa - from pydantic import BaseModel __all__ = ["LanceDBClient", "VectorQuery", "VectorQueryResult"] diff --git a/python/lancedb/remote/client.py b/python/lancedb/remote/client.py index 3970712d..707603ad 100644 --- a/python/lancedb/remote/client.py +++ b/python/lancedb/remote/client.py @@ -13,11 +13,11 @@ import functools +import urllib.parse import aiohttp import attr import pyarrow as pa -import urllib.parse from lancedb.remote import VectorQuery, VectorQueryResult from lancedb.remote.errors import LanceDBClientError diff --git a/python/tests/test_e2e_remote_db.py b/python/tests/test_e2e_remote_db.py index 3f5344c7..54daa904 100644 --- a/python/tests/test_e2e_remote_db.py +++ b/python/tests/test_e2e_remote_db.py @@ -11,12 +11,11 @@ # See the License for the specific language governing permissions and # limitations under the License. -from lancedb import LanceDBConnection - import numpy as np - import pytest +from lancedb import LanceDBConnection + # TODO: setup integ test mark and script diff --git a/python/tests/test_embeddings.py b/python/tests/test_embeddings.py index 5cae7c61..39938356 100644 --- a/python/tests/test_embeddings.py +++ b/python/tests/test_embeddings.py @@ -14,6 +14,7 @@ import sys import numpy as np import pyarrow as pa + from lancedb.embeddings import with_embeddings diff --git a/python/tests/test_fts.py b/python/tests/test_fts.py index 91c5e236..99156710 100644 --- a/python/tests/test_fts.py +++ b/python/tests/test_fts.py @@ -13,13 +13,13 @@ import os import random -import lancedb.fts import numpy as np import pandas as pd import pytest import tantivy import lancedb as ldb +import lancedb.fts @pytest.fixture diff --git a/python/tests/test_io.py b/python/tests/test_io.py index d6b092bb..656200a8 100644 --- a/python/tests/test_io.py +++ b/python/tests/test_io.py @@ -12,6 +12,7 @@ # limitations under the License. import os + import pytest import lancedb diff --git a/python/tests/test_query.py b/python/tests/test_query.py index 1c50ca63..55713544 100644 --- a/python/tests/test_query.py +++ b/python/tests/test_query.py @@ -17,9 +17,9 @@ import pandas as pd import pandas.testing as tm import pyarrow as pa import pytest -from lancedb.query import LanceQueryBuilder from lancedb.db import LanceDBConnection +from lancedb.query import LanceQueryBuilder class MockTable: diff --git a/python/tests/test_remote_db.py b/python/tests/test_remote_db.py index b0e3d0c9..7971340d 100644 --- a/python/tests/test_remote_db.py +++ b/python/tests/test_remote_db.py @@ -13,9 +13,8 @@ import pyarrow as pa - -from lancedb.remote.client import VectorQuery, VectorQueryResult from lancedb.db import LanceDBConnection +from lancedb.remote.client import VectorQuery, VectorQueryResult class FakeLanceDBClient: diff --git a/python/tests/test_table.py b/python/tests/test_table.py index 311e9b2c..cf672fa8 100644 --- a/python/tests/test_table.py +++ b/python/tests/test_table.py @@ -17,6 +17,7 @@ from pathlib import Path import pandas as pd import pyarrow as pa import pytest + from lancedb.table import LanceTable