Repository: activeloopai/Hub
File: deeplake/core/vectorstore/deeplake_vectorstore.py (Python)

Code before:
from deeplake.core.vectorstore import utils
from deeplake.core.vectorstore.vector_search import vector_search
from deeplake.core.vectorstore.vector_search import dataset as dataset_utils
from deeplake.core.vectorstore.vector_search import filter as filter_utils

from deeplake.util.bugout_reporter import feature_report_path, deeplake_reporter

logger = logging.getLogger(__name__)


class VectorStore:
    """Base class for VectorStore"""

    def __init__(
        self,
        path: Union[str, pathlib.Path],
        tensor_params: List[Dict[str, object]] = DEFAULT_VECTORSTORE_TENSORS,
        embedding_function: Optional[Callable] = None,
        read_only: Optional[bool] = False,
        ingestion_batch_size: int = 1000,
        num_workers: int = 0,
        exec_option: str = "python",
        token: Optional[str] = None,
        overwrite: bool = False,
        verbose=True,
        runtime={"tensor_db": False},
        **kwargs: Any,
    ) -> None:
        """Creates an empty VectorStore or loads an existing one if it exists at the specified ``path``.

        Examples:
            >>> # Create a vector store with default tensors
            >>> data = VectorStore(
            ...        path = "./my_vector_store",
            ... )

            >>> # Create a vector store in the Deep Lake Managed Tensor Database
            >>> data = VectorStore(
            ...        path = "hub://org_id/dataset_name",
            ...        runtime = {"tensor_db": True},
            ... )

            >>> # Create a vector store with custom tensors
            >>> data = VectorStore(
            ...        path = "./my_vector_store",
            ...        tensor_params = [{"name": "text", "htype": "text"},
            ...                         {"name": "embedding_1", "htype": "embedding"},
            ...                         {"name": "embedding_2", "htype": "embedding"},
            ...                         {"name": "source", "htype": "text"},
            ...                         {"name": "metadata", "htype": "json"}
            ...                        ]

Review comment (bug):
shouldn't this be `None` by default. That's what we do everywhere else in the deeplake repo and it works well, so I think we should adhere to conventions we have elsewhere in order to de-risk edge cases not working. 

Code after:
from deeplake.core.vectorstore import utils
from deeplake.core.vectorstore.vector_search import vector_search
from deeplake.core.vectorstore.vector_search import dataset as dataset_utils
from deeplake.core.vectorstore.vector_search import filter as filter_utils

from deeplake.util.bugout_reporter import feature_report_path, deeplake_reporter

logger = logging.getLogger(__name__)


class VectorStore:
    """Base class for VectorStore"""

    def __init__(
        self,
        path: Union[str, pathlib.Path],
        tensor_params: List[Dict[str, object]] = DEFAULT_VECTORSTORE_TENSORS,
        embedding_function: Optional[Callable] = None,
        read_only: Optional[bool] = False,
        ingestion_batch_size: int = 1000,
        num_workers: int = 0,
        exec_option: str = "python",
        token: Optional[str] = None,
        overwrite: bool = False,
        verbose: bool = True,
        runtime: Optional[Dict] = None,
        **kwargs: Any,
    ) -> None:
        """Creates an empty VectorStore or loads an existing one if it exists at the specified ``path``.

        Examples:
            >>> # Create a vector store with default tensors
            >>> data = VectorStore(
            ...        path = "./my_vector_store",
            ... )

            >>> # Create a vector store in the Deep Lake Managed Tensor Database
            >>> data = VectorStore(
            ...        path = "hub://org_id/dataset_name",
            ...        runtime = {"tensor_db": True},
            ... )

            >>> # Create a vector store with custom tensors
            >>> data = VectorStore(
            ...        path = "./my_vector_store",
            ...        tensor_params = [{"name": "text", "htype": "text"},
            ...                         {"name": "embedding_1", "htype": "embedding"},
            ...                         {"name": "embedding_2", "htype": "embedding"},
            ...                         {"name": "source", "htype": "text"},
            ...                         {"name": "metadata", "htype": "json"}
            ...                        ]