Skip to content

Commit 722529f

Browse files
authored
Merge branch 'master' into fix#919
2 parents 91f060a + b0e4ed0 commit 722529f

164 files changed

Lines changed: 15452 additions & 4027 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.codecov.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
coverage:
2+
status:
3+
project:
4+
default:
5+
target: auto
6+
patch:
7+
default:
8+
target: 80%
9+
threshold: 0%

.github/actions/setup-python/action.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ runs:
1919
shell: bash
2020
run: |
2121
poetry env use ${{ inputs.python-version }}
22-
poetry install --extras dev
22+
poetry install --with dev,test,docs

.github/workflows/tests.yml

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ jobs:
1212
fail-fast: true
1313
matrix:
1414
python-version: ["3.10", "3.11", "3.12"]
15+
numpy-spec:
16+
# Keep this aligned with pyproject.toml: numpy = ">=2.0.2,<2.1"
17+
- "==2.0.2" # locked baseline
18+
- ">=2.0.2,<2.1" # latest allowed in declared range
1519
runs-on: ubuntu-latest
1620

1721
steps:
@@ -23,8 +27,26 @@ jobs:
2327
with:
2428
python-version: ${{ matrix.python-version }}
2529

26-
- name: Verify NumPy version
27-
run: poetry run python -c "import numpy; print('NumPy version:', numpy.__version__)"
30+
- name: Install matrix NumPy version
31+
run: poetry run pip install --upgrade --no-deps "numpy${{ matrix.numpy-spec }}"
32+
33+
- name: Verify NumPy version and spec
34+
env:
35+
NUMPY_SPEC: ${{ matrix.numpy-spec }}
36+
run: |
37+
poetry run python - <<'PY'
38+
import os
39+
import numpy
40+
from packaging.specifiers import SpecifierSet
41+
42+
spec = SpecifierSet(os.environ["NUMPY_SPEC"])
43+
version = numpy.__version__
44+
if version not in spec:
45+
raise RuntimeError(
46+
f"NumPy version {version} does not satisfy matrix spec {spec}"
47+
)
48+
print("NumPy version:", version, "| spec:", spec)
49+
PY
2850
2951
- name: Run unit tests
3052
run: poetry run pytest -v tests --ignore tests/integration --typeguard-packages=malariagen_data,malariagen_data.anoph

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
.idea
22
.vscode
33
__pycache__
4+
.mypy_cache
45
*.pyc
56
dist
7+
.venv/
68
.coverage
79
coverage.xml
810
.ipynb_checkpoints/

CONTRIBUTING.md

Lines changed: 50 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://pipx.pypa.io/) 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,18 +34,31 @@ 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 --with dev,test,docs
4656
```
4757

58+
This installs the runtime dependencies along with the `dev`, `test`, and `docs`
59+
[dependency groups](https://python-poetry.org/docs/managing-dependencies/#dependency-groups).
60+
If you only need to run tests, `poetry install --with test` is sufficient.
61+
4862
**Recommended**: Use `poetry run` to run commands inside the virtual environment:
4963

5064
```bash
@@ -71,7 +85,7 @@ You'll need:
7185
python script.py
7286
```
7387

74-
5. **Install pre-commit hooks**
88+
6. **Install pre-commit hooks**
7589

7690
```bash
7791
pipx install pre-commit
@@ -107,16 +121,40 @@ You'll need:
107121

108122
4. **Run tests locally**
109123

110-
Fast unit tests (no external data access):
124+
Fast unit tests using simulated data (no external data access):
111125

112126
```bash
113-
poetry run pytest -v tests/anoph
127+
poetry run pytest -v tests --ignore tests/integration
114128
```
115129

116-
All unit tests (requires setting up credentials for legacy tests):
130+
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).
131+
132+
Once access has been granted, [install the Google Cloud CLI](https://cloud.google.com/sdk/docs/install). E.g., if on Linux:
117133

118134
```bash
119-
poetry run pytest -v tests --ignore tests/integration
135+
./install_gcloud.sh
136+
```
137+
138+
You'll then need to obtain application-default credentials, e.g.:
139+
140+
```bash
141+
./google-cloud-sdk/bin/gcloud auth application-default login
142+
```
143+
144+
Once this is done, you can run integration tests:
145+
146+
```bash
147+
poetry run pytest -v tests/integration
148+
```
149+
150+
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.
151+
152+
6. **Run typechecking**
153+
154+
Run static typechecking with mypy:
155+
156+
```bash
157+
poetry run mypy malariagen_data tests --ignore-missing-imports
120158
```
121159

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

153-
Run type checking with:
191+
Run dynamic type checking with:
154192

155193
```bash
156194
poetry run pytest -v tests --typeguard-packages=malariagen_data,malariagen_data.anoph

LINUX_SETUP.md

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
# Developer setup (Linux)
2+
3+
## 1. Install Git
4+
5+
Choose the command for your Linux distribution:
6+
7+
**Ubuntu, Debian, and Mint:**
8+
9+
```bash
10+
sudo apt update
11+
sudo apt install -y git
12+
```
13+
14+
**Fedora:**
15+
16+
```bash
17+
sudo dnf install -y git
18+
```
19+
20+
**Arch Linux:**
21+
22+
```bash
23+
sudo pacman -S sudo
24+
sudo pacman -S git
25+
sudo pacman -S openssh
26+
```
27+
28+
If your Arch install does not have `sudo` configured yet, run the commands above as `root`, then configure `sudo` for your user.
29+
30+
## 2. Fork and clone this repo
31+
32+
After forking the repository on GitHub, clone your fork.
33+
34+
Use SSH if your SSH keys are set up:
35+
36+
```bash
37+
git clone git@github.com:[YOUR_GITHUB_USERNAME]/malariagen-data-python.git
38+
cd malariagen-data-python
39+
```
40+
41+
Use HTTPS if you prefer, or if you do not have SSH keys configured (common on WSL):
42+
43+
```bash
44+
git clone https://github.com/[YOUR_GITHUB_USERNAME]/malariagen-data-python.git
45+
cd malariagen-data-python
46+
```
47+
48+
## 3. Install pipx
49+
50+
Choose the command for your Linux distribution:
51+
52+
**Ubuntu, Debian, and Mint:**
53+
54+
```bash
55+
sudo apt update
56+
sudo apt install -y pipx
57+
pipx ensurepath
58+
```
59+
60+
**Fedora:**
61+
62+
```bash
63+
sudo dnf install -y pipx
64+
pipx ensurepath
65+
```
66+
67+
**Arch Linux:**
68+
69+
```bash
70+
sudo pacman -S python-pipx
71+
pipx ensurepath
72+
```
73+
74+
Close and reopen your terminal to apply PATH changes.
75+
If you prefer to reload the shell in-place, run:
76+
77+
```bash
78+
exec bash
79+
```
80+
81+
## 4. Install Poetry and Python 3.12
82+
83+
The package requires `>=3.10,<3.13`. We use Poetry's built-in installer to handle the Python version universally across all distributions.
84+
85+
```bash
86+
pipx install poetry
87+
poetry python install 3.12
88+
```
89+
90+
## 5. Create development environment
91+
92+
```bash
93+
poetry env use 3.12
94+
poetry install --extras dev
95+
```
96+
97+
## 6. Install pre-commit hooks
98+
99+
```bash
100+
pipx install pre-commit
101+
pre-commit install
102+
```
103+
104+
Run pre-commit checks manually:
105+
106+
```bash
107+
pre-commit run --all-files
108+
```
109+
110+
## 7. Run tests
111+
112+
Run fast unit tests using simulated data:
113+
114+
```bash
115+
poetry run pytest -v tests/anoph
116+
```
117+
118+
## 8. Google Cloud authentication (for legacy tests)
119+
120+
To run legacy 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).
121+
122+
Once access has been granted, [install the Google Cloud CLI](https://cloud.google.com/sdk/docs/install):
123+
124+
```bash
125+
./install_gcloud.sh
126+
```
127+
128+
Then obtain application-default credentials:
129+
130+
```bash
131+
./google-cloud-sdk/bin/gcloud auth application-default login
132+
```
133+
134+
Once authenticated, run legacy tests:
135+
136+
```bash
137+
poetry run pytest --ignore=tests/anoph -v tests
138+
```
139+
140+
Tests will run slowly the first time, as data will be read from GCS and cached locally in the `gcs_cache` folder.

MACOS_SETUP.md

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# Developer setup (macOS)
2+
3+
The Linux setup guide is available in [LINUX_SETUP.md](LINUX_SETUP.md). If you are on macOS, follow these steps instead.
4+
5+
## 1. Install Miniconda
6+
7+
Download and install Miniconda for macOS from https://docs.conda.io/en/latest/miniconda.html.
8+
Choose the Apple Silicon installer if you have an Apple Silicon Mac, or the Intel installer otherwise. You can check with:
9+
```bash
10+
uname -m
11+
# arm64 = Apple Silicon, x86_64 = Intel
12+
```
13+
14+
After installation, close and reopen your terminal for conda to be available.
15+
16+
## 2. Create a conda environment
17+
18+
The package requires Python `>=3.10, <3.13`. Python 3.13+ is not currently supported.
19+
```bash
20+
conda create -n malariagen python=3.11
21+
conda activate malariagen
22+
```
23+
24+
## 3. Fork and clone this repo
25+
26+
Fork the repository on GitHub, then clone your fork:
27+
```bash
28+
git clone git@github.com:[username]/malariagen-data-python.git
29+
cd malariagen-data-python
30+
pip install -e ".[dev]"
31+
```
32+
33+
## 4. Install pre-commit hooks
34+
```bash
35+
pre-commit install
36+
```
37+
38+
Run pre-commit checks manually:
39+
```bash
40+
pre-commit run --all-files
41+
```
42+
43+
## 5. Run tests
44+
45+
Run fast unit tests using simulated data:
46+
```bash
47+
pytest -v tests/anoph
48+
```
49+
50+
## 6. Google Cloud authentication (for legacy tests)
51+
52+
To run legacy 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).
53+
54+
Once access has been granted, install the Google Cloud CLI:
55+
```bash
56+
brew install google-cloud-sdk
57+
```
58+
59+
Then authenticate:
60+
```bash
61+
gcloud auth application-default login
62+
```
63+
64+
This opens a browser — log in with any Google account.
65+
66+
Once authenticated, run legacy tests:
67+
```bash
68+
pytest --ignore=tests/anoph -v tests
69+
```
70+
71+
Tests will run slowly the first time, as data will be read from GCS and cached locally in the `gcs_cache` folder.
72+
73+
## 7. VS Code terminal integration
74+
75+
To use the `code` command from the terminal:
76+
77+
Open VS Code → `Cmd + Shift + P` → type `Shell Command: Install 'code' command in PATH` → press Enter.

0 commit comments

Comments
 (0)