Skip to content

Commit 6cd31c1

Browse files
authored
docs: Remove duplicate contributing guide and add a linting section (#240)
1 parent 90ba5b4 commit 6cd31c1

File tree

2 files changed

+27
-261
lines changed

2 files changed

+27
-261
lines changed

CONTRIBUTING.md

Lines changed: 2 additions & 239 deletions
Original file line numberDiff line numberDiff line change
@@ -17,243 +17,6 @@
1717
under the License.
1818
-->
1919

20-
<!---
21-
Licensed to the Apache Software Foundation (ASF) under one
22-
or more contributor license agreements. See the NOTICE file
23-
distributed with this work for additional information
24-
regarding copyright ownership. The ASF licenses this file
25-
to you under the Apache License, Version 2.0 (the
26-
"License"); you may not use this file except in compliance
27-
with the License. You may obtain a copy of the License at
20+
# CONTRIBUTING.md
2821

29-
http://www.apache.org/licenses/LICENSE-2.0
30-
31-
Unless required by applicable law or agreed to in writing,
32-
software distributed under the License is distributed on an
33-
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
34-
KIND, either express or implied. See the License for the
35-
specific language governing permissions and limitations
36-
under the License.
37-
-->
38-
39-
# Contributors Guide
40-
41-
This guide details how to set up your development environment as a SedonaDB Contributor.
42-
43-
## Fork and clone the repository
44-
45-
Your first step is to create a personal copy of the repository and connect it to the main project.
46-
47-
1. Fork the repository
48-
49-
* Navigate to the official [SedonaDB GitHub repository](https://github.com/apache/sedona-db).
50-
* Click the **Fork** button in the top-right corner. This creates a complete copy of the project in your own GitHub account.
51-
52-
1. Clone your fork
53-
54-
* Next, clone your newly created fork to your local machine. This command downloads the repository into a new folder named `sedona-db`.
55-
* Replace `YourUsername` with your actual GitHub username.
56-
57-
```shell
58-
git clone https://github.com/YourUsername/sedona-db.git
59-
cd sedona-db
60-
```
61-
62-
1. Configure the remotes
63-
64-
* Your local repository needs to know where the original project is so you can pull in updates. You'll add a remote link, traditionally named **`upstream`**, to the main SedonaDB repository.
65-
* Your fork is automatically configured as the **`origin`** remote.
66-
67-
```shell
68-
# Add the main repository as the "upstream" remote
69-
git remote add upstream https://github.com/apache/sedona-db.git
70-
```
71-
72-
1. Verify the configuration
73-
74-
* Run the following command to verify that you have two remotes configured correctly: `origin` (your fork) and `upstream` (the main repository).
75-
76-
```shell
77-
git remote -v
78-
```
79-
80-
* The output should look like this:
81-
82-
```shell
83-
origin https://github.com/YourUsername/sedona-db.git (fetch)
84-
origin https://github.com/YourUsername/sedona-db.git (push)
85-
upstream https://github.com/apache/sedona-db.git (fetch)
86-
upstream https://github.com/apache/sedona-db.git (push)
87-
```
88-
89-
## Rust
90-
91-
SedonaDB is written in Rust and is a standard `cargo` workspace.
92-
93-
You can install a recent version of the Rust compiler and cargo from
94-
[rustup.rs](https://rustup.rs/) and run tests using `cargo test`.
95-
96-
A local development version of the CLI can be run with `cargo run --bin sedona-cli`.
97-
98-
### Test data setup
99-
100-
Some tests require submodules that contain test data or pinned versions of
101-
external dependencies. These submodules can be initialized with:
102-
103-
```shell
104-
git submodule init
105-
git submodule update --recursive
106-
```
107-
108-
Additionally, some of the data required in the tests can be downloaded by running the following script.
109-
110-
```bash
111-
python submodules/download-assets.py
112-
```
113-
114-
### System dependencies
115-
116-
Some crates wrap external native libraries and require system dependencies
117-
to build.
118-
119-
!!!note "`sedona-s2geography`"
120-
At this time, the only crate that requires this is the `sedona-s2geography`
121-
crate, which requires [CMake](https://cmake.org),
122-
[Abseil](https://github.com/abseil/abseil-cpp) and OpenSSL.
123-
124-
#### macOS
125-
126-
These can be installed on macOS with [Homebrew](https://brew.sh):
127-
128-
```shell
129-
brew install abseil openssl cmake geos
130-
```
131-
132-
#### Linux and Windows
133-
134-
On Linux and Windows, it is recommended to use [vcpkg](https://github.com/microsoft/vcpkg)
135-
to provide external dependencies. This can be done by setting the `CMAKE_TOOLCHAIN_FILE`
136-
environment variable:
137-
138-
```shell
139-
export CMAKE_TOOLCHAIN_FILE=/path/to/vcpkg/scripts/buildsystems/vcpkg.cmake
140-
```
141-
142-
#### Visual Studio Code (VSCode) Configuration
143-
144-
When using VSCode, it may be necessary to set this environment variable in `settings.json`
145-
such that it can be found by rust-analyzer when running build/run tasks:
146-
147-
```json
148-
{
149-
"rust-analyzer.runnables.extraEnv": {
150-
"CMAKE_TOOLCHAIN_FILE": "/path/to/vcpkg/scripts/buildsystems/vcpkg.cmake"
151-
},
152-
"rust-analyzer.cargo.extraEnv": {
153-
"CMAKE_TOOLCHAIN_FILE": "/path/to/vcpkg/scripts/buildsystems/vcpkg.cmake"
154-
}
155-
}
156-
```
157-
158-
## Python
159-
160-
Python bindings to SedonaDB are built with the [Maturin](https://www.maturin.rs) build
161-
backend.
162-
163-
To install a development version of the main Python bindings for the first time, run the following commands:
164-
165-
```shell
166-
cd python/sedonadb
167-
pip install -e ".[test]"
168-
```
169-
170-
If editing Rust code in either SedonaDB or the Python bindings, you can recompile the
171-
native component with:
172-
173-
```shell
174-
maturin develop
175-
```
176-
177-
## Debugging
178-
179-
### Rust
180-
181-
Debugging Rust code is most easily done by writing or finding a test that triggers
182-
the desired behavior and running it using the *Debug* selection in
183-
[VSCode](https://code.visualstudio.com/) with the
184-
[rust-analyzer](https://marketplace.visualstudio.com/items?itemName=rust-lang.rust-analyzer)
185-
extension. Rust code can also be debugged using the CLI by finding the `main()` function in
186-
`sedona-cli` and choosing the *Debug* run option.
187-
188-
### Python, C, and C++
189-
190-
Installation of Python bindings with `maturin develop` ensures a debug-friendly build for
191-
debugging Rust, Python, or C/C++ code. Python code can be debugged using breakpoints in
192-
any IDE that supports debugging an editable Python package installation (e.g., VSCode);
193-
Rust, C, or C++ code can be debugged using the
194-
[CodeLLDB](https://marketplace.visualstudio.com/items?itemName=vadimcn.vscode-lldb)
195-
*Attach to Process...* command from the command palette in VSCode.
196-
197-
## Low-level benchmarking
198-
199-
Low-level Rust benchmarks use [criterion](https://github.com/bheisler/criterion.rs).
200-
In general, there is at least one benchmark for every implementation of a function
201-
(some functions have more than one implementation provided by different libraries),
202-
and a few other benchmarks for low-level iteration where work was done to optimize
203-
specific cases.
204-
205-
### Running benchmarks
206-
207-
Benchmarks for a specific crate can be run with `cargo bench`:
208-
209-
```shell
210-
cd rust/sedona-geo
211-
cargo bench
212-
```
213-
214-
Benchmarks for a specific function can be run with a filter. These can be run
215-
from the workspace or a specific crate (although the output is usually easier
216-
to read for a specific crate).
217-
218-
```shell
219-
cargo bench -- st_area
220-
```
221-
222-
### Managing results
223-
224-
By default, criterion saves the last run and will report the difference between the
225-
current benchmark and the last time it was run (although there are options to
226-
save and load various baselines).
227-
228-
A report of the latest results for all benchmarks can be opened with the following command:
229-
230-
=== "macOS"
231-
```shell
232-
open target/criterion/report/index.html
233-
```
234-
=== "Ubuntu"
235-
```shell
236-
xdg-open target/criterion/report/index.html
237-
```
238-
239-
All previous saved benchmark runs can be cleared with:
240-
241-
```shell
242-
rm -rf target/criterion
243-
```
244-
245-
## Documentation
246-
247-
To contribute to the SedonaDB documentation:
248-
249-
1. Clone the repository and create a fork.
250-
1. Install the Documentation dependencies:
251-
```sh
252-
pip install -r docs/requirements.txt
253-
```
254-
1. Make your changes to the documentation files.
255-
1. Preview your changes locally using these commands:
256-
* `mkdocs serve` - Start the live-reloading docs server.
257-
* `mkdocs build` - Build the documentation site.
258-
* `mkdocs -h` - Print help message and exit.
259-
1. Push your changes and open a pull request.
22+
See the [contributors-guide.md](docs/contributors-guide.md)

docs/contributors-guide.md

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -165,21 +165,12 @@ pip install maturin
165165

166166
### Rust
167167

168-
Debugging Rust code is most easily done by writing or finding a test that triggers
169-
the desired behavior and running it using the *Debug* selection in
170-
[VSCode](https://code.visualstudio.com/) with the
171-
[rust-analyzer](https://marketplace.visualstudio.com/items?itemName=rust-lang.rust-analyzer)
172-
extension. Rust code can also be debugged using the CLI by finding the `main()` function in
168+
Debugging Rust code is most easily done by writing or finding a test that triggers the desired behavior and running it using the *Debug* selection in [VSCode](https://code.visualstudio.com/) with the [rust-analyzer](https://marketplace.visualstudio.com/items?itemName=rust-lang.rust-analyzer) extension. Rust code can also be debugged using the CLI by finding the `main()` function in
173169
`sedona-cli` and choosing the *Debug* run option.
174170
175171
### Python, C, and C++
176172
177-
Installation of Python bindings with `maturin develop` ensures a debug-friendly build for
178-
debugging Rust, Python, or C/C++ code. Python code can be debugged using breakpoints in
179-
any IDE that supports debugging an editable Python package installation (e.g., VSCode);
180-
Rust, C, or C++ code can be debugged using the
181-
[CodeLLDB](https://marketplace.visualstudio.com/items?itemName=vadimcn.vscode-lldb)
182-
*Attach to Process...* command from the command palette in VSCode.
173+
Installation of Python bindings with `maturin develop` ensures a debug-friendly build for debugging Rust, Python, or C/C++ code. Python code can be debugged using breakpoints in any IDE that supports debugging an editable Python package installation (e.g., VSCode); Rust, C, or C++ code can be debugged using the [CodeLLDB](https://marketplace.visualstudio.com/items?itemName=vadimcn.vscode-lldb) *Attach to Process...* command from the command palette in VSCode.
183174
184175
## Testing
185176
@@ -215,13 +206,29 @@ pytest python/sedonadb/tests
215206
216207
Remember that you need to run `maturin develop` to update your python installation after changes in Rust code.
217208
209+
## Linting
210+
211+
Install pre-commit. This will automatically run various checks (e.g formatting) that will be needed to pass CI.
212+
213+
```shell
214+
pre-commit install
215+
```
216+
217+
If pre-commit is not already installed, you can install it using pip.
218+
219+
```shell
220+
pip install pre-commit
221+
```
222+
223+
Additionally, you should run clippy to catch common lints before pushing new Rust changes. This is not included in `pre-commit`, so this should be run manually. Fix any suggestions it makes, and run it again to make sure there are no other changes to make.
224+
225+
```shell
226+
cargo clippy
227+
```
228+
218229
## Low-level benchmarking
219230
220-
Low-level Rust benchmarks use [criterion](https://github.com/bheisler/criterion.rs).
221-
In general, there is at least one benchmark for every implementation of a function
222-
(some functions have more than one implementation provided by different libraries),
223-
and a few other benchmarks for low-level iteration where work was done to optimize
224-
specific cases.
231+
Low-level Rust benchmarks use [criterion](https://github.com/bheisler/criterion.rs). In general, there is at least one benchmark for every implementation of a function (some functions have more than one implementation provided by different libraries), and a few other benchmarks for low-level iteration where work was done to optimize specific cases.
225232
226233
### Running benchmarks
227234
@@ -232,19 +239,15 @@ cd rust/sedona-geo
232239
cargo bench
233240
```
234241
235-
Benchmarks for a specific function can be run with a filter. These can be run
236-
from the workspace or a specific crate (although the output is usually easier
237-
to read for a specific crate).
242+
Benchmarks for a specific function can be run with a filter. These can be run from the workspace or a specific crate (although the output is usually easier to read for a specific crate).
238243
239244
```shell
240245
cargo bench -- st_area
241246
```
242247
243248
### Managing results
244249
245-
By default, criterion saves the last run and will report the difference between the
246-
current benchmark and the last time it was run (although there are options to
247-
save and load various baselines).
250+
By default, criterion saves the last run and will report the difference between the current benchmark and the last time it was run (although there are options to save and load various baselines).
248251
249252
A report of the latest results for all benchmarks can be opened with the following command:
250253

0 commit comments

Comments
 (0)