Skip to content

Contributors Guide

This guide details how to set up your development environment as a SpatialBench contributor.

Fork and clone the repository

Your first step is to create a personal copy of the repository and connect it to the main project.

  1. Fork the repository

  2. Navigate to the official SpatialBench GitHub repository.

  3. Click the Fork button in the top-right corner. This creates a complete copy of the project in your own GitHub account.

  4. Clone your fork

  5. Next, clone your newly created fork to your local machine. This command downloads the repository into a new folder named sedona-spatialbench.

  6. Replace YourUsername with your actual GitHub username.

    git clone https://github.com/YourUsername/sedona-spatialbench.git
    cd sedona-spatialbench
    
  7. Configure the remotes

  8. 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 SpatialBench repository.

  9. Your fork is automatically configured as the origin remote.

    # Add the main repository as the "upstream" remote
    git remote add upstream https://github.com/apache/sedona-spatialbench.git
    
  10. Verify the configuration

  11. Run the following command to verify that you have two remotes configured correctly: origin (your fork) and upstream (the main repository).

    git remote -v
    
  12. The output should look like this:

    origin    https://github.com/YourUsername/sedona-spatialbench.git (fetch)
    origin    https://github.com/YourUsername/sedona-spatialbench.git (push)
    upstream  https://github.com/apache/sedona-spatialbench.git (fetch)
    upstream  https://github.com/apache/sedona-spatialbench.git (push)
    

Development Setup

SpatialBench is written in Rust and is a standard cargo workspace. You can install a recent version of the Rust compiler and cargo from rustup.rs.

To run tests:

cargo test

A local development version of the CLI can be run with:

cargo run --bin spatialbench-cli

Debugging

IDE

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 your IDE with the rust-analyzer extension.

Verbose CLI Output

When debugging the SpatialBench CLI, you can enable verbose output to see detailed logging:

Enable verbose output (info level logging),

cargo run --bin spatialbench-cli -- --scale-factor 1 --verbose

Or using environment variables for more granular control,

RUST_LOG=debug cargo run --bin spatialbench-cli -- --scale-factor 1

The --verbose flag sets the log level to info and ignores the RUST_LOG environment variable. When not specified, logging is configured via RUST_LOG.

Logging Levels

You can control logging granularity using RUST_LOG:

# Show only errors
RUST_LOG=error cargo run --bin spatialbench-cli -- --scale-factor 1

# Show warnings and errors
RUST_LOG=warn cargo run --bin spatialbench-cli -- --scale-factor 1

# Show info, warnings, and errors
RUST_LOG=info cargo run --bin spatialbench-cli -- --scale-factor 1

# Show debug output
RUST_LOG=debug cargo run --bin spatialbench-cli -- --scale-factor 1

# Show trace output (very verbose)
RUST_LOG=trace cargo run --bin spatialbench-cli -- --scale-factor 1

# Show debug output for specific modules
RUST_LOG=spatialbench=debug cargo run --bin spatialbench-cli -- --scale-factor 1

Testing

We use cargo to run the Rust tests:

cargo test

You can run tests for a specific crate:

cd spatialbench
cargo test

Linting

Install pre-commit. This will automatically run various checks (e.g., formatting) that will be needed to pass CI:

pre-commit install

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:

cargo clippy

Documentation

To contribute to the SpatialBench documentation:

  1. Clone the repository and create a fork.
  2. Install the Documentation dependencies:
    pip install -r docs/requirements.txt
    
  3. Make your changes to the documentation files.
  4. Preview your changes locally using these commands:
  5. mkdocs serve - Start the live-reloading docs server.
  6. mkdocs build - Build the documentation site.
  7. mkdocs -h - Print help message and exit.
  8. Push your changes and open a pull request.