Setup development environment

Setup development environment#

We use uv to manage our development environment. Please make sure you have it installed before proceeding.

  1. Clone the repository

git clone https://github.com/rendeirolab/lazyslide.git
# or
gh repo clone rendeirolab/lazyslide
  1. Checkout to a new branch

Please replace new-feature with a meaningful name for your branch.

git checkout -b new-feature
  1. Sync development environment

uv sync
  1. Install pre-commit hooks

uv run prek install

We use prek to run code formatting and linting checks before each commit.

  1. Start a Python session

IPython

uv run --with ipython ipython

Jupyter

uv run --with jupyter jupyter lab
# With extensions
uv run --with jupyter --with dask-labextension jupyter lab

VS Code/PyCharm If you run in VS Code or PyCharm, you don’t need to do anything else.

Code style#

The configuration is defined in pyproject.toml and enforced through pre-commit hooks.

To format code

uv run task fmt
# or
ruff format docs/source src/lazyslide tests

Testing#

LazySlide uses pytest for testing. Tests are located in the tests directory.

To run all tests

uv run task test

To run a specific test file

uv run python -m pytest tests/test_example.py

When adding new tests:

  1. Create a new file in the tests directory with a name starting with test_*.

  2. Import pytest and the module you want to test.

  3. Write test functions with names starting with test_*.

  4. Use assertions to verify expected behavior.

Documentation#

Documentation is built using Sphinx and is located in the docs directory.

To build the documentation

# Build doc with cache
uv run task doc-build
# Fresh build
uv run task doc-clean-build

To serve the documentation locally

uv run task doc-serve

This will start a local server at http://localhost:8000.

Documentation is written in reStructuredText (.rst) and Jupyter notebooks (.ipynb) using the myst-nb extension.

Submitting changes#

  1. Commit your changes and push them to your branch.

  2. Create a pull request on GitHub.

  3. Ensure all CI checks pass.

  4. Wait for a review from a maintainer.