Elffuss BraidHub

kikocis/lancedb public

main · 1.6 KiBRenderedRawPermalink
1# LanceDB
2
3A Python library for [LanceDB](https://github.com/lancedb/lancedb).
4
5## Installation
6
7```bash
8pip install lancedb
9```
10
11## Usage
12
13### Basic Example
14
15```python
16import lancedb
17db = lancedb.connect('<PATH_TO_LANCEDB_DATASET>')
18table = db.open_table('my_table')
19results = table.search([0.1, 0.3]).limit(20).to_list()
20print(results)
21```
22
23## Development
24
25LanceDb is based on the rust crate `lancedb` and is built with maturin. In order to build with maturin
26you will either need a conda environment or a virtual environment (venv).
27
28```bash
29python -m venv venv
30. ./venv/bin/activate
31```
32
33Install the necessary packages:
34
35```bash
36python -m pip install .[tests,dev]
37```
38
39To build the python package you can use maturin:
40
41```bash
42# This will build the rust bindings and place them in the appropriate place
43# in your venv or conda environment
44maturin develop
45```
46
47To run the unit tests:
48
49```bash
50pytest
51```
52
53To run the doc tests:
54
55```bash
56pytest --doctest-modules python/lancedb
57```
58
59To run linter and automatically fix all errors:
60
61```bash
62ruff format python
63ruff --fix python
64```
65
66If any packages are missing, install them with:
67
68```bash
69pip install <PACKAGE_NAME>
70```
71
72___
73For **Windows** users, there may be errors when installing packages, so these commands may be helpful:
74
75Activate the virtual environment:
76
77```bash
78. .\venv\Scripts\activate
79```
80
81You may need to run the installs separately:
82
83```bash
84pip install -e .[tests]
85pip install -e .[dev]
86```
87
88`tantivy` requires `rust` to be installed, so install it with `conda`, as it doesn't support windows installation:
89
90```bash
91pip install wheel
92pip install cargo
93conda install rust
94pip install tantivy
95```