Skip to content

Commit 0e496ed

Browse files
authored
docs: contributing guide (lancedb#1970)
* Adds basic contributing guides. * Simplifies Python development with a Makefile.
1 parent 17c9e9a commit 0e496ed

File tree

7 files changed

+340
-125
lines changed

7 files changed

+340
-125
lines changed

CONTRIBUTING.md

+78
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# Contributing to LanceDB
2+
3+
LanceDB is an open-source project and we welcome contributions from the community.
4+
This document outlines the process for contributing to LanceDB.
5+
6+
## Reporting Issues
7+
8+
If you encounter a bug or have a feature request, please open an issue on the
9+
[GitHub issue tracker](https://github.com/lancedb/lancedb).
10+
11+
## Picking an issue
12+
13+
We track issues on the GitHub issue tracker. If you are looking for something to
14+
work on, check the [good first issue](https://github.com/lancedb/lancedb/contribute) label. These issues are typically the best described and have the smallest scope.
15+
16+
If there's an issue you are interested in working on, please leave a comment on the issue. This will help us avoid duplicate work. Additionally, if you have questions about the issue, please ask them in the issue comments. We are happy to provide guidance on how to approach the issue.
17+
18+
## Configuring Git
19+
20+
First, fork the repository on GitHub, then clone your fork:
21+
22+
```bash
23+
git clone https://github.com/<username>/lancedb.git
24+
cd lancedb
25+
```
26+
27+
Then add the main repository as a remote:
28+
29+
```bash
30+
git remote add upstream https://github.com/lancedb/lancedb.git
31+
git fetch upstream
32+
```
33+
34+
## Setting up your development environment
35+
36+
We have development environments for Python, Typescript, and Java. Each environment has its own setup instructions.
37+
38+
* [Python](python/CONTRIBUTING.md)
39+
* [Typescript](nodejs/CONTRIBUTING.md)
40+
<!-- TODO: add Java contributing guide -->
41+
* [Documentation](docs/README.md)
42+
43+
44+
## Best practices for pull requests
45+
46+
For the best chance of having your pull request accepted, please follow these guidelines:
47+
48+
1. Unit test all bug fixes and new features. Your code will not be merged if it
49+
doesn't have tests.
50+
1. If you change the public API, update the documentation in the `docs` directory.
51+
1. Aim to minimize the number of changes in each pull request. Keep to solving
52+
one problem at a time, when possible.
53+
1. Before marking a pull request ready-for-review, do a self review of your code.
54+
Is it clear why you are making the changes? Are the changes easy to understand?
55+
1. Use [conventional commit messages](https://www.conventionalcommits.org/en/) as pull request titles. Examples:
56+
* New feature: `feat: adding foo API`
57+
* Bug fix: `fix: issue with foo API`
58+
* Documentation change: `docs: adding foo API documentation`
59+
1. If your pull request is a work in progress, leave the pull request as a draft.
60+
We will assume the pull request is ready for review when it is opened.
61+
1. When writing tests, test the error cases. Make sure they have understandable
62+
error messages.
63+
64+
## Project structure
65+
66+
The core library is written in Rust. The Python, Typescript, and Java libraries
67+
are wrappers around the Rust library.
68+
69+
* `src/lancedb`: Rust library source code
70+
* `python`: Python package source code
71+
* `nodejs`: Typescript package source code
72+
* `node`: **Deprecated** Typescript package source code
73+
* `java`: Java package source code
74+
* `docs`: Documentation source code
75+
76+
## Release process
77+
78+
For information on the release process, see: [release_process.md](release_process.md)

docs/README.md

+64-19
Original file line numberDiff line numberDiff line change
@@ -9,36 +9,81 @@ unreleased features.
99
## Building the docs
1010

1111
### Setup
12-
1. Install LanceDB. From LanceDB repo root: `pip install -e python`
13-
2. Install dependencies. From LanceDB repo root: `pip install -r docs/requirements.txt`
14-
3. Make sure you have node and npm setup
15-
4. Make sure protobuf and libssl are installed
12+
1. Install LanceDB Python. See setup in [Python contributing guide](../python/CONTRIBUTING.md).
13+
Run `make develop` to install the Python package.
14+
2. Install documentation dependencies. From LanceDB repo root: `pip install -r docs/requirements.txt`
1615

17-
### Building node module and create markdown files
16+
### Preview the docs
1817

19-
See [Javascript docs README](./src/javascript/README.md)
18+
```shell
19+
cd docs
20+
mkdocs serve
21+
```
2022

21-
### Build docs
22-
From LanceDB repo root:
23+
If you want to just generate the HTML files:
2324

24-
Run: `PYTHONPATH=. mkdocs build -f docs/mkdocs.yml`
25+
```shell
26+
PYTHONPATH=. mkdocs build -f docs/mkdocs.yml
27+
```
2528

2629
If successful, you should see a `docs/site` directory that you can verify locally.
2730

28-
### Run local server
31+
## Adding examples
2932

30-
You can run a local server to test the docs prior to deployment by navigating to the `docs` directory and running the following command:
33+
To make sure examples are correct, we put examples in test files so they can be
34+
run as part of our test suites.
3135

32-
```bash
33-
cd docs
34-
mkdocs serve
36+
You can see the tests are at:
37+
38+
* Python: `python/python/tests/docs`
39+
* Typescript: `nodejs/examples/`
40+
41+
### Checking python examples
42+
43+
```shell
44+
cd python
45+
pytest -vv python/tests/docs
3546
```
3647

37-
### Run doctest for typescript example
48+
### Checking typescript examples
3849

39-
```bash
40-
cd lancedb/docs
41-
npm i
50+
The `@lancedb/lancedb` package must be built before running the tests:
51+
52+
```shell
53+
pushd nodejs
54+
npm ci
4255
npm run build
43-
npm run all
56+
popd
57+
```
58+
59+
Then you can run the examples by going to the `nodejs/examples` directory and
60+
running the tests like a normal npm package:
61+
62+
```shell
63+
pushd nodejs/examples
64+
npm ci
65+
npm test
66+
popd
67+
```
68+
69+
## API documentation
70+
71+
### Python
72+
73+
The Python API documentation is organized based on the file `docs/src/python/python.md`.
74+
We manually add entries there so we can control the organization of the reference page.
75+
**However, this means any new types must be manually added to the file.** No additional
76+
steps are needed to generate the API documentation.
77+
78+
### Typescript
79+
80+
The typescript API documentation is generated from the typescript source code using [typedoc](https://typedoc.org/).
81+
82+
When new APIs are added, you must manually re-run the typedoc command to update the API documentation.
83+
The new files should be checked into the repository.
84+
85+
```shell
86+
pushd nodejs
87+
npm run docs
88+
popd
4489
```

nodejs/CONTRIBUTING.md

+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# Contributing to LanceDB Typescript
2+
3+
This document outlines the process for contributing to LanceDB Typescript.
4+
For general contribution guidelines, see [CONTRIBUTING.md](../CONTRIBUTING.md).
5+
6+
## Project layout
7+
8+
The Typescript package is a wrapper around the Rust library, `lancedb`. We use
9+
the [napi-rs](https://napi.rs/) library to create the bindings between Rust and
10+
Typescript.
11+
12+
* `src/`: Rust bindings source code
13+
* `lancedb/`: Typescript package source code
14+
* `__test__/`: Unit tests
15+
* `examples/`: An npm package with the examples shown in the documentation
16+
17+
## Development environment
18+
19+
To set up your development environment, you will need to install the following:
20+
21+
1. Node.js 14 or later
22+
2. Rust's package manager, Cargo. Use [rustup](https://rustup.rs/) to install.
23+
3. [protoc](https://grpc.io/docs/protoc-installation/) (Protocol Buffers compiler)
24+
25+
Initial setup:
26+
27+
```shell
28+
npm install
29+
```
30+
31+
### Commit Hooks
32+
33+
It is **highly recommended** to install the [pre-commit](https://pre-commit.com/) hooks to ensure that your
34+
code is formatted correctly and passes basic checks before committing:
35+
36+
```shell
37+
pre-commit install
38+
```
39+
40+
## Development
41+
42+
Most common development commands can be run using the npm scripts.
43+
44+
Build the package
45+
46+
```shell
47+
npm install
48+
npm run build
49+
```
50+
51+
Lint:
52+
53+
```shell
54+
npm run lint
55+
```
56+
57+
Format and fix lints:
58+
59+
```shell
60+
npm run lint-fix
61+
```
62+
63+
Run tests:
64+
65+
```shell
66+
npm test
67+
```
68+
69+
To run a single test:
70+
71+
```shell
72+
# Single file: table.test.ts
73+
npm test -- table.test.ts
74+
# Single test: 'merge insert' in table.test.ts
75+
npm test -- table.test.ts --testNamePattern=merge\ insert
76+
```

nodejs/README.md

+1-34
Original file line numberDiff line numberDiff line change
@@ -36,37 +36,4 @@ The [quickstart](../basic.md) contains a more complete example.
3636

3737
## Development
3838

39-
```sh
40-
npm run build
41-
npm run test
42-
```
43-
44-
### Running lint / format
45-
46-
LanceDb uses [biome](https://biomejs.dev/) for linting and formatting. if you are using VSCode you will need to install the official [Biome](https://marketplace.visualstudio.com/items?itemName=biomejs.biome) extension.
47-
To manually lint your code you can run:
48-
49-
```sh
50-
npm run lint
51-
```
52-
53-
to automatically fix all fixable issues:
54-
55-
```sh
56-
npm run lint-fix
57-
```
58-
59-
If you do not have your workspace root set to the `nodejs` directory, unfortunately the extension will not work. You can still run the linting and formatting commands manually.
60-
61-
### Generating docs
62-
63-
```sh
64-
npm run docs
65-
66-
cd ../docs
67-
# Asssume the virtual environment was created
68-
# python3 -m venv venv
69-
# pip install -r requirements.txt
70-
. ./venv/bin/activate
71-
mkdocs build
72-
```
39+
See [CONTRIBUTING.md](./CONTRIBUTING.md) for information on how to contribute to LanceDB.

python/CONTRIBUTING.md

+78
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# Contributing to LanceDB Python
2+
3+
This document outlines the process for contributing to LanceDB Python.
4+
For general contribution guidelines, see [CONTRIBUTING.md](../CONTRIBUTING.md).
5+
6+
## Project layout
7+
8+
The Python package is a wrapper around the Rust library, `lancedb`. We use
9+
[pyo3](https://pyo3.rs/) to create the bindings between Rust and Python.
10+
11+
* `src/`: Rust bindings source code
12+
* `python/lancedb`: Python package source code
13+
* `python/tests`: Unit tests
14+
15+
## Development environment
16+
17+
To set up your development environment, you will need to install the following:
18+
19+
1. Python 3.9 or later
20+
2. Cargo (Rust's package manager). Use [rustup](https://rustup.rs/) to install.
21+
3. [protoc](https://grpc.io/docs/protoc-installation/) (Protocol Buffers compiler)
22+
23+
Create a virtual environment to work in:
24+
25+
```bash
26+
python -m venv venv
27+
source venv/bin/activate
28+
pip install maturin
29+
```
30+
31+
### Commit Hooks
32+
33+
It is **highly recommended** to install the pre-commit hooks to ensure that your
34+
code is formatted correctly and passes basic checks before committing:
35+
36+
```bash
37+
make develop # this will install pre-commit itself
38+
pre-commit install
39+
```
40+
41+
## Development
42+
43+
Most common development commands can be run using the Makefile.
44+
45+
Build the package
46+
47+
```shell
48+
make develop
49+
```
50+
51+
Format:
52+
53+
```shell
54+
make format
55+
```
56+
57+
Run tests:
58+
59+
```shell
60+
make test
61+
make doctest
62+
```
63+
64+
To run a single test, you can use the `pytest` command directly. Provide the path
65+
to the test file, and optionally the test name after `::`.
66+
67+
```shell
68+
# Single file: test_table.py
69+
pytest -vv python/tests/test_table.py
70+
# Single test: test_basic in test_table.py
71+
pytest -vv python/tests/test_table.py::test_basic
72+
```
73+
74+
To see all commands, run:
75+
76+
```shell
77+
make help
78+
```

0 commit comments

Comments
 (0)