Skip to content

Commit c3e5c6b

Browse files
authored
Fix bugs in docs (#319)
This PR makes several documentation fixes and improvements: - Updates the docs workflow to use `uv sync` instead of `pip`. - Fixes broken links on the inference page. - Adjusts the menu order for better navigation. - Add more instructions on how to use `uvx`.
1 parent 8c32b1d commit c3e5c6b

29 files changed

+896
-1008
lines changed

.github/workflows/docs.yml

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,24 @@ jobs:
2121
contents: write
2222
steps:
2323
- name: Checkout repo
24-
uses: actions/checkout@v3
24+
uses: actions/checkout@v4
2525
with:
2626
fetch-depth: 0
2727

28-
- name: Setup Python
29-
uses: actions/setup-python@v4
28+
- name: Setup UV
29+
uses: astral-sh/setup-uv@v6
3030
with:
3131
python-version: "3.12"
3232

33-
- name: Install sleap-nn with docs dependencies
33+
- name: Install dependencies
3434
run: |
35-
pip install -e ".[docs]"
35+
uv sync --extra dev --extra torch-cpu --extra docs
3636
3737
- name: Print environment info
3838
run: |
39-
which python
40-
pip freeze
39+
which python
40+
uv pip list
41+
uv pip freeze
4142
4243
- name: Setup Git user
4344
run: |
@@ -49,11 +50,11 @@ jobs:
4950
env:
5051
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5152
run: |
52-
mike deploy --update-aliases --allow-empty --push "${{ github.event.release.tag_name }}" latest
53+
uv run mike deploy --update-aliases --allow-empty --push "${{ github.event.release.tag_name }}" latest
5354
5455
- name: Build and upload docs (dev)
5556
if: ${{ github.event_name == 'push' }}
5657
env:
5758
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5859
run: |
59-
mike deploy --update-aliases --allow-empty --push dev
60+
uv run mike deploy --update-aliases --allow-empty --push dev

CONTRIBUTING.md

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Thank you for your interest in contributing to sleap-nn! This guide will help yo
99

1010
2. **Install sleap-nn dependencies based on your platform**\
1111

12-
- Sync all dependencies based on your correct wheel using `uv sync`:
12+
- Sync all dependencies based on your correct wheel using `uv sync`. `uv sync` creates a `.venv` (virtual environment) inside your current working directory. This environment is only active within that directory and can't be directly accessed from outside. To use all installed packages, you must run commands with `uv run` (e.g., `uv run sleap-nn train ...` or `uv run pytest ...`).
1313
- **Windows/Linux with NVIDIA GPU (CUDA 11.8):**
1414

1515
```bash
@@ -28,9 +28,6 @@ Thank you for your interest in contributing to sleap-nn! This guide will help yo
2828
uv sync --extra dev --extra torch-cpu
2929
```
3030

31-
You can find the correct wheel for your system at:\
32-
👉 [https://pytorch.org/get-started/locally](https://pytorch.org/get-started/locally)
33-
3431

3532
## Code Style
3633

@@ -108,22 +105,22 @@ cd sleap-nn
108105

109106
2. Install `sleap-nn` with docs dependencies:
110107
```bash
111-
pip install -e ".[docs]"
108+
uv sync --extra docs --extra dev --extra torch-cpu
112109
```
113110

114111
3. Build and tag a new documentation version:
115112
```bash
116-
mike deploy --update-aliases 0.1.4 latest
113+
uv run mike deploy --update-aliases 0.1.4 latest
117114
```
118115

119116
4. Preview documentation locally:
120117
```bash
121-
mike serve
118+
uv run mike serve
122119
```
123120

124121
5. Push a specific version manually:
125122
```bash
126-
mike deploy --push --update-aliases --allow-empty 0.1.4 latest
123+
uv run mike deploy --push --update-aliases --allow-empty 0.1.4 latest
127124
```
128125

129126
The documentation is automatically deployed to https://nn.sleap.ai/ when changes are pushed to the main branch or when a new release is published.
@@ -132,7 +129,7 @@ The documentation is automatically deployed to https://nn.sleap.ai/ when changes
132129

133130
1. Create a new branch for your feature or bugfix:
134131
```bash
135-
git checkout -b feature/your-feature-name
132+
git checkout -b your-username/your-feature-name
136133
```
137134

138135
2. Make your changes and ensure tests pass

README.md

Lines changed: 51 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
[![CI](https://github.com/talmolab/sleap-nn/actions/workflows/ci.yml/badge.svg)](https://github.com/talmolab/sleap-nn/actions/workflows/ci.yml)
44
[![codecov](https://codecov.io/gh/talmolab/sleap-nn/branch/main/graph/badge.svg?token=Sj8kIFl3pi)](https://codecov.io/gh/talmolab/sleap-nn)
55
[![Release](https://img.shields.io/github/v/release/talmolab/sleap-nn?label=Latest)](https://github.com/talmolab/sleap-nn/releases/)
6+
[![PyPI](https://img.shields.io/pypi/v/sleap-nn?label=PyPI)](https://pypi.org/project/sleap-nn)
7+
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/sleap-nn)
68

79
Neural network backend for training and inference for animal pose estimation.
810

@@ -12,28 +14,41 @@ This is the deep learning engine that powers [SLEAP](https://sleap.ai) (Social L
1214

1315
**📚 [Documentation](https://nn.sleap.ai)** - Comprehensive guides and API reference
1416

15-
## Installation
16-
17-
**Prerequisites: Python 3.11**
17+
## Quick Start
1818

19-
### From PyPI
19+
Let's start SLEAPiNNg !!! 🐭🐭
2020

21-
- **Windows/Linux with NVIDIA GPU (CUDA 11.8):**
21+
> For detailed information on setting up config, training/ inference workflows, please refer to our [docs](https://nn.sleap.ai).
2222
23+
#### 1. Install uv
24+
Install [`uv`](https://github.com/astral-sh/uv) first - a fast Python package manager:
2325
```bash
24-
pip install sleap-nn[torch-cuda118]
26+
# macOS/Linux
27+
curl -LsSf https://astral.sh/uv/install.sh | sh
28+
29+
# Windows
30+
powershell -c "irm https://astral.sh/uv/install.ps1 | iex"
2531
```
2632

27-
- **Windows/Linux with NVIDIA GPU (CUDA 12.8):**
33+
#### 2. Set Up Your Configuration
34+
35+
Create a `config.yaml` file for your experiment.
36+
37+
> Use a sample config from [`docs/sample_configs`](https://github.com/talmolab/sleap-nn/tree/main/docs/sample_configs).
38+
39+
#### 3. Train a model
40+
41+
> Download sample training data from [here](https://storage.googleapis.com/sleap-data/datasets/BermanFlies/random_split1/train.pkg.slp) and validation data from [here](https://storage.googleapis.com/sleap-data/datasets/BermanFlies/random_split1/val.pkg.slp) for quick experimentation.
2842
2943
```bash
30-
pip install sleap-nn[torch-cuda128]
44+
uvx sleap-nn[torch-cpu] train --config-name config.yaml --config-dir /path/to/config_dir/ "data_config.train_labels_path=[labels.pkg.slp]"
3145
```
3246

33-
- **macOS with Apple Silicon (M1, M2, M3, M4) or CPU-only (no GPU or unsupported GPU):**
34-
Note: Even if torch-cpu is used on macOS, the MPS backend will be available.
47+
#### 4. Run inference on the trained model
48+
49+
To run inference:
3550
```bash
36-
pip install sleap-nn[torch-cpu]
51+
uvx sleap-nn[torch-cpu] track --data-path video.mp4 --model-paths model_ckpt_dir/
3752
```
3853

3954

@@ -46,32 +61,37 @@ git clone https://github.com/talmolab/sleap-nn.git
4661
cd sleap-nn
4762
```
4863

49-
2. **Install [`uv`](https://github.com/astral-sh/uv) and development dependencies**
50-
`uv` is a fast and modern package manager for `pyproject.toml`-based projects. Refer [installation docs](https://docs.astral.sh/uv/getting-started/installation/) to install uv.
64+
2. **Install [`uv`](https://github.com/astral-sh/uv)**
65+
Install [`uv`](https://github.com/astral-sh/uv) first - a fast Python package manager:
66+
```bash
67+
# macOS/Linux
68+
curl -LsSf https://astral.sh/uv/install.sh | sh
69+
70+
# Windows
71+
powershell -c "irm https://astral.sh/uv/install.ps1 | iex"
72+
```
73+
5174

5275
3. **Install sleap-nn dependencies based on your platform**\
5376

54-
- Sync all dependencies based on your correct wheel using `uv sync`:
55-
- **Windows/Linux with NVIDIA GPU (CUDA 11.8):**
56-
57-
```bash
58-
uv sync --extra dev --extra torch-cuda118
59-
```
77+
- Sync all dependencies based on your correct wheel using `uv sync`. `uv sync` creates a `.venv` (virtual environment) inside your current working directory. This environment is only active within that directory and can't be directly accessed from outside. To use all installed packages, you must run commands with `uv run` (e.g., `uv run sleap-nn train ...` or `uv run pytest ...`).
78+
- **Windows/Linux with NVIDIA GPU (CUDA 11.8):**
6079

61-
- **Windows/Linux with NVIDIA GPU (CUDA 12.8):**
80+
```bash
81+
uv sync --extra dev --extra torch-cuda118
82+
```
6283

63-
```bash
64-
uv sync --extra dev --extra torch-cuda128
65-
```
66-
67-
- **macOS with Apple Silicon (M1, M2, M3, M4) or CPU-only (no GPU or unsupported GPU):**
68-
Note: Even if torch-cpu is used on macOS, the MPS backend will be available.
69-
```bash
70-
uv sync --extra dev --extra torch-cpu
71-
```
84+
- **Windows/Linux with NVIDIA GPU (CUDA 12.8):**
7285

73-
You can find the correct wheel for your system at:\
74-
👉 [https://pytorch.org/get-started/locally](https://pytorch.org/get-started/locally)
86+
```bash
87+
uv sync --extra dev --extra torch-cuda128
88+
```
89+
90+
- **macOS with Apple Silicon (M1, M2, M3, M4) or CPU-only (no GPU or unsupported GPU):**
91+
Note: Even if torch-cpu is used on macOS, the MPS backend will be available.
92+
```bash
93+
uv sync --extra dev --extra torch-cpu
94+
```
7595

7696
4. **Run tests**
7797
```bash
@@ -83,30 +103,3 @@ cd sleap-nn
83103
uv run black --check sleap_nn tests
84104
uv run ruff check sleap_nn/
85105
```
86-
87-
## Quick Start
88-
89-
Let's start SLEAPiNNg !!! 🐭🐭
90-
91-
> For detailed information on setting up config, training/ inference workflows, please refer to our [docs](https://nn.sleap.ai).
92-
93-
#### 1. Set Up Your Configuration
94-
95-
Create a `config.yaml` file for your experiment.
96-
97-
> Use a sample config from [`docs/sample_configs`](https://github.com/talmolab/sleap-nn/tree/main/docs/sample_configs).
98-
99-
#### 2. Train a model
100-
101-
> Download sample training data from [here](https://storage.googleapis.com/sleap-data/datasets/BermanFlies/random_split1/train.pkg.slp) and validation data from [here](https://storage.googleapis.com/sleap-data/datasets/BermanFlies/random_split1/val.pkg.slp) for quick experimentation.
102-
103-
```bash
104-
sleap-nn train --config-name config.yaml --config-dir configs/ "data_config.train_labels_path=[labels.pkg.slp]"
105-
```
106-
107-
#### 3. Run inference on the trained model
108-
109-
To run inference:
110-
```bash
111-
sleap-nn track --data-path video.mp4 --model-paths model_ckpt_dir/
112-
```

0 commit comments

Comments
 (0)