Skip to content

Commit ed85e9e

Browse files
authored
Documentation enhancements pre release (#1175)
* Update the Python support version * Add main missing docs strings * Update citation count * Add pre-commit dev doc * Update version to reflect prerelease candidate * ci: update publish workflow to Python 3.11 and modern action versions
1 parent bbedcdd commit ed85e9e

File tree

12 files changed

+148
-45
lines changed

12 files changed

+148
-45
lines changed

.bumpversion.toml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
11
[tool.bumpversion]
2-
current_version = "1.5.3-dev0"
2+
current_version = "2.0.0rc1"
33

44
parse = """(?x)
55
(?P<major>0|[1-9]\\d*)\\.
66
(?P<minor>0|[1-9]\\d*)\\.
77
(?P<patch>0|[1-9]\\d*)
88
(?:
9-
- # dash separator for pre-release section
10-
(?P<pre_l>[a-zA-Z-]+) # pre-release label
9+
(?P<pre_l>[a-zA-Z]+) # pre-release label (no dash)
1110
(?P<pre_n>0|[1-9]\\d*) # pre-release version number
1211
)? # pre-release section is optional
1312
"""
1413
serialize = [
1514
"{major}.{minor}.{patch}",
16-
"{major}.{minor}.{patch}-{pre_l}{pre_n}"
15+
"{major}.{minor}.{patch}{pre_l}{pre_n}"
1716
]
1817

1918
[tool.bumpversion.parts.pre_l]

.github/workflows/publish.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,18 @@ jobs:
1111
runs-on: ubuntu-latest
1212
if: "!contains(github.ref, '-dev')"
1313
steps:
14-
- uses: actions/checkout@v3
15-
- uses: actions/setup-python@v4
14+
- uses: actions/checkout@v4
15+
- uses: actions/setup-python@v5
1616
with:
17-
python-version: "3.9"
17+
python-version: "3.11"
1818

1919
- name: Build package
2020
run: |
2121
python -m pip install --upgrade pip build
2222
python -m build
2323
2424
- name: Publish to Test PyPI
25-
uses: pypa/gh-action-pypi-publish@release/v1
25+
uses: pypa/gh-action-pypi-publish@release/v2
2626
with:
2727
password: ${{ secrets.TEST_PYPI_TOKEN }}
2828
repository-url: https://test.pypi.org/legacy/
@@ -34,18 +34,18 @@ jobs:
3434
if: "!contains(github.ref, '-dev')" # Skip dev versions
3535
needs: [test-pypi] # Wait for test-pypi to succeed
3636
steps:
37-
- uses: actions/checkout@v3
38-
- uses: actions/setup-python@v4
37+
- uses: actions/checkout@v4
38+
- uses: actions/setup-python@v5
3939
with:
40-
python-version: "3.9"
40+
python-version: "3.11"
4141

4242
- name: Build package
4343
run: |
4444
python -m pip install --upgrade pip build
4545
python -m build
4646
4747
- name: Publish to PyPI
48-
uses: pypa/gh-action-pypi-publish@release/v1
48+
uses: pypa/gh-action-pypi-publish@release/v2
4949
with:
5050
password: ${{ secrets.PYPI_TOKEN }}
5151
skip-existing: true

CONTRIBUTING.md

Lines changed: 74 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Developer's Guide
22

3-
Depends on Python 3.9+
3+
Depends on Python 3.10+
44

55
## Getting started
66

@@ -28,12 +28,12 @@ Depends on Python 3.9+
2828

2929
4. Check or confirm your settings using `git remote -v`
3030

31-
```text
31+
```bash
3232
origin git@github.com:[your user name]/DeepForest.git (fetch)
3333
origin git@github.com:[your user name]/DeepForest.git (push)
3434
upstream https://github.com/weecology/DeepForest.git (fetch)
3535
upstream https://github.com/weecology/DeepForest.git (push)
36-
```
36+
```
3737

3838
5. Install the package from the main directory.
3939

@@ -70,26 +70,85 @@ $ pip install . --upgrade # or python setup.py install
7070
$ pytest -v
7171
```
7272

73-
### Checking and fixing code style
73+
### Code Quality and Style
74+
75+
We use [pre-commit](https://pre-commit.com/) to ensure consistent code quality and style across the project. Pre-commit runs automated checks and fixes before each commit to catch issues early.
76+
77+
#### Setting up pre-commit
78+
79+
1. **Install pre-commit** (if not already installed):
80+
```bash
81+
pip install pre-commit
82+
```
83+
84+
2. **Install the pre-commit hooks** in your local repository:
85+
```bash
86+
pre-commit install
87+
```
88+
89+
3. **Run pre-commit on all files** (optional, for initial setup):
90+
```bash
91+
pre-commit run --all-files
92+
```
93+
94+
#### What pre-commit does
95+
96+
Our pre-commit configuration (`.pre-commit-config.yaml`) includes:
97+
98+
- **Code formatting**: Uses [Ruff](https://docs.astral.sh/ruff/) for fast Python linting and formatting
99+
- **Import sorting**: Automatically sorts and organizes imports
100+
- **Docstring formatting**: Uses [docformatter](https://github.com/PyCQA/docformatter) to format docstrings
101+
- **Notebook formatting**: Formats Jupyter notebooks in the documentation
102+
- **File checks**: Ensures files end with newlines, removes trailing whitespace, checks YAML/JSON syntax
103+
- **Large file detection**: Prevents accidentally committing large files
104+
105+
#### Running pre-commit manually
106+
107+
You can run pre-commit checks manually at any time:
108+
109+
```bash
110+
# Run on staged files only
111+
pre-commit run
112+
113+
# Run on all files
114+
pre-commit run --all-files
115+
116+
# Run a specific hook
117+
pre-commit run ruff
118+
```
119+
120+
#### Fixing pre-commit issues
74121

75-
#### Using Yapf
122+
Most pre-commit hooks will automatically fix issues for you. If a hook fails:
76123

77-
We use [yapf](https://github.com/google/yapf) for code formatting and style checking.
124+
1. **Check the output** - pre-commit will show you what needs to be fixed
125+
2. **Re-run the hook** - many hooks can auto-fix issues:
126+
```bash
127+
pre-commit run --all-files
128+
```
129+
3. **Stage the fixed files** and commit again:
130+
```bash
131+
git add .
132+
git commit -m "Your commit message"
133+
```
78134

79-
The easiest way to make sure your code is formatted correctly is to integrate it into your editor.
80-
See [EDITOR SUPPORT](https://github.com/google/yapf/blob/main/EDITOR%20SUPPORT.md).
135+
#### Bypassing pre-commit (not recommended)
81136

82-
You can also run yapf from the command line to cleanup the style in your changes:
137+
If you need to bypass pre-commit for a specific commit (not recommended for regular development):
83138

84139
```bash
85-
yapf -i --recursive src/deepforest/ --style=.style.yapf
140+
git commit --no-verify -m "Your commit message"
86141
```
87142

88-
If the style tests fail on a pull request, running the above command is the easiest way to fix this.
143+
#### Editor integration
144+
145+
For the best development experience, consider integrating these tools directly into your editor:
89146

90-
#### Using pre-commit
147+
- **VS Code**: Install the Ruff extension for real-time linting and formatting
148+
- **PyCharm**: Configure Ruff as an external tool
149+
- **Vim/Neovim**: Use plugins like `nvim-lspconfig` with the Ruff language server
91150

92-
We configure all our checks using the `.pre-commit-config.yaml` file. To verify your code styling before committing, you should run `pre-commit install` to set up the hooks, followed by `pre-commit run` to execute them. This will apply the formatting rules specified in the `.style.yapf` file. For additional information, please refer to the [pre-commit documentation](https://pre-commit.com/index.html).
151+
For more information, see the [pre-commit documentation](https://pre-commit.com/).
93152

94153
## Documentation
95154

@@ -175,14 +234,15 @@ The model will be uploaded to [https://huggingface.co/weecology/[model-name]](ht
175234
176235
### CropModel
177236
178-
```python```
237+
```python
179238
from deepforest.model import CropModel
180239
181240
crop_model = CropModel()
182241
crop_model.push_to_hub("weecology/cropmodel-deadtrees")
183242
184243
# Reload it later
185244
crop_model.from_pretrained("Weecology/cropmodel-deadtrees")
245+
186246
```
187247
188248
Please name the cropmodel based on what is being classified.

HISTORY.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
# DeepForest Changelog
22

3-
## Version 2.0.0 (Date: TBD)
3+
## Version 2.0.0rc1 (Date: October 21, 2025)
44

5-
### Breaking Changes - Deprecated Items Removed:
5+
### Release Candidate 1 - Beta Release
6+
#### Breaking Changes - Deprecated Items Removed:
67

78
**Removed Functions:**
89
- `xml_to_annotations()` - Use `utilities.read_pascal_voc(path)` or the general `utilities.read_file(path)`.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
[![Version](https://img.shields.io/pypi/v/DeepForest.svg)](https://pypi.python.org/pypi/DeepForest)
88
[![PyPI - Downloads](https://img.shields.io/pypi/dm/deepforest)](https://pypi.python.org/pypi/DeepForest)
99
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.2538143.svg)](https://doi.org/10.5281/zenodo.2538143)
10-
[![Python Version](https://img.shields.io/badge/python-%3E%3D3.8%2C%20%3C3.13-blue.svg)](https://www.python.org/downloads/)
10+
[![Python Version](https://img.shields.io/badge/python-%3E%3D3.10%2C%20%3C3.13-blue.svg)](https://www.python.org/downloads/)
1111
[![Citations](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/weecology/DeepForest/refs/heads/main/citation_count.json)](https://scholar.google.com/scholar?hl=en&as_sdt=40005&sciodt=0,10&cites=4018186955550406830&scipsc=&q=)
1212

1313
![](www/MEE_Figure4.png)

citation_count.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"schemaVersion": 1,
33
"label": "Citations",
4-
"message": "118",
4+
"message": "123",
55
"color": "blue"
66
}

docs/getting_started/install.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,29 @@ pip install .
3636
```bash
3737
git clone https://github.com/weecology/DeepForest.git
3838
cd DeepForest
39-
uv sync --all-extras -dev
39+
uv sync --all-extras --dev
4040
```
4141

42+
## Development Installation
43+
44+
For developers who want to contribute to DeepForest, install the package in development mode with all dependencies:
45+
46+
```bash
47+
git clone https://github.com/weecology/DeepForest.git
48+
cd DeepForest
49+
pip install .'[dev,docs]'
50+
```
51+
52+
Or using uv:
53+
54+
```bash
55+
git clone https://github.com/weecology/DeepForest.git
56+
cd DeepForest
57+
uv sync --all-extras --dev
58+
```
59+
60+
This installs DeepForest in editable mode with development and documentation dependencies.
61+
4262
## GPU support
4363

4464
PyTorch can be run on GPUs to allow faster model training and prediction. DeepForest is a PyTorch Lightning module, which automatically distributes data to available GPUs. If using a release model with training, the module can be moved from CPU to GPU for prediction using the `pytorch.to()` method.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "deepforest"
3-
version = "1.5.3-dev0"
3+
version = "2.0.0rc1"
44
description = "Platform for individual detection from airborne remote sensing including trees, birds, and livestock. Supports multiple detection models, adding models for species classification, and easy fine tuning to particular ecosystems."
55
readme = "README.md"
66
requires-python = ">=3.10,<3.13"

src/deepforest/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
__version__ = "1.5.3-dev0"
1+
__version__ = "2.0.0rc1"
22
# Version updated using bump-my-version

src/deepforest/model.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ class BaseModel:
2828
config: DeepForest configuration object
2929
"""
3030

31-
def __init__(self, config):
31+
def __init__(self, config) -> None:
3232
# Check for required properties and formats
3333
self.config = config
3434

35-
def create_model(self):
35+
def create_model(self) -> torch.nn.Module:
3636
"""Create model from configuration.
3737
3838
Must be implemented by subclasses to return a PyTorch nn.Module.
@@ -43,7 +43,7 @@ def create_model(self):
4343
"Take in args and return a pytorch nn module."
4444
)
4545

46-
def check_model(self):
46+
def check_model(self) -> None:
4747
"""Validate model follows DeepForest guidelines.
4848
4949
Tests model with dummy data to ensure proper input/output
@@ -66,7 +66,15 @@ def check_model(self):
6666
assert model_keys == ["boxes", "labels", "scores"]
6767

6868

69-
def simple_resnet_50(num_classes=2):
69+
def simple_resnet_50(num_classes: int = 2) -> torch.nn.Module:
70+
"""Create a simple ResNet-50 model for classification.
71+
72+
Args:
73+
num_classes: Number of output classes for the final layer
74+
75+
Returns:
76+
torch.nn.Module: ResNet-50 model with modified final layer
77+
"""
7078
m = models.resnet50(weights=models.ResNet50_Weights.DEFAULT)
7179
num_ftrs = m.fc.in_features
7280
m.fc = torch.nn.Linear(num_ftrs, num_classes)

0 commit comments

Comments
 (0)