Skip to content

Commit 7f87de1

Browse files
author
Jacob Garber
committed
Improvements to contributing guide
1. Many systems have different default python versions, so use poetry to install the CI-tested version. 2. Install poetry dependencies with `--extras dev` to allow running pytest. 3. Restore instructions about logging into Gcloud to run integration tests. 4. Add command about checking types with mypy.
1 parent 7c49d0a commit 7f87de1

1 file changed

Lines changed: 46 additions & 12 deletions

File tree

CONTRIBUTING.md

Lines changed: 46 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@ This package provides Python tools for accessing and analyzing genomic data from
1212

1313
You'll need:
1414

15-
- Python 3.10.x (CI-tested version)
16-
- [Poetry](https://python-poetry.org/) for dependency management
17-
- [Git](https://git-scm.com/) for version control
15+
- [pipx](https://python-poetry.org/) for installing Python tools
16+
- [git](https://git-scm.com/) for version control
17+
18+
Both of these can be installed using your distribution's package manager or [Homebrew](https://brew.sh/) on Mac.
1819

1920
### Initial setup
2021

@@ -33,16 +34,25 @@ You'll need:
3334
git remote add upstream https://github.com/malariagen/malariagen-data-python.git
3435
```
3536

36-
3. **Install Poetry** (if not already installed)
37+
3. **Install Poetry**
3738

3839
```bash
3940
pipx install poetry
4041
```
4142

42-
4. **Install the project and its dependencies**
43+
4. **Install Python 3.12**
44+
45+
Python 3.12 is tested in the CI-system and is the recommended version to use.
46+
47+
```bash
48+
poetry python install 3.12
49+
```
50+
51+
5. **Install the project and its dependencies**
4352

4453
```bash
45-
poetry install
54+
poetry env use 3.12
55+
poetry install --extras dev
4656
```
4757

4858
**Recommended**: Use `poetry run` to run commands inside the virtual environment:
@@ -71,7 +81,7 @@ You'll need:
7181
python script.py
7282
```
7383

74-
5. **Install pre-commit hooks**
84+
6. **Install pre-commit hooks**
7585

7686
```bash
7787
pipx install pre-commit
@@ -107,16 +117,40 @@ You'll need:
107117

108118
4. **Run tests locally**
109119

110-
Fast unit tests (no external data access):
120+
Fast unit tests using simulated data (no external data access):
111121

112122
```bash
113-
poetry run pytest -v tests/anoph
123+
poetry run pytest -v tests --ignore tests/integration
114124
```
115125

116-
All unit tests (requires setting up credentials for legacy tests):
126+
To run integration tests which read data from GCS, you'll need to [request access to MalariaGEN data on GCS](https://malariagen.github.io/vector-data/vobs/vobs-data-access.html).
127+
128+
Once access has been granted, [install the Google Cloud CLI](https://cloud.google.com/sdk/docs/install). E.g., if on Linux:
117129

118130
```bash
119-
poetry run pytest -v tests --ignore tests/integration
131+
./install_gcloud.sh
132+
```
133+
134+
You'll then need to obtain application-default credentials, e.g.:
135+
136+
```bash
137+
./google-cloud-sdk/bin/gcloud auth application-default login
138+
```
139+
140+
Once this is done, you can run integration tests:
141+
142+
```bash
143+
poetry run pytest -v tests/integration
144+
```
145+
146+
Tests will run slowly the first time, as data required for testing will be read from GCS. Subsequent runs will be faster as data will be cached locally in the "gcs_cache" folder.
147+
148+
6. **Run typechecking**
149+
150+
Run static typechecking with mypy:
151+
152+
```bash
153+
poetry run mypy malariagen_data tests --ignore-missing-imports
120154
```
121155

122156
5. **Check code quality**
@@ -150,7 +184,7 @@ ruff format .
150184
- **Fast tests**: Unit tests should use simulated data when possible (see `tests/anoph/`)
151185
- **Integration tests**: Tests requiring GCS data access are slower and run separately
152186

153-
Run type checking with:
187+
Run dynamic type checking with:
154188

155189
```bash
156190
poetry run pytest -v tests --typeguard-packages=malariagen_data,malariagen_data.anoph

0 commit comments

Comments
 (0)