|
| 1 | +<!-- |
| 2 | +Copyright The NiPreps Developers <[email protected]> |
| 3 | +
|
| 4 | +Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +you may not use this file except in compliance with the License. |
| 6 | +You may obtain a copy of the License at |
| 7 | +
|
| 8 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +
|
| 10 | +Unless required by applicable law or agreed to in writing, software |
| 11 | +distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +See the License for the specific language governing permissions and |
| 14 | +limitations under the License. |
| 15 | +
|
| 16 | +We support and encourage derived works from this project, please read |
| 17 | +about our expectations at |
| 18 | +
|
| 19 | + https://www.nipreps.org/community/licensing/ |
| 20 | +--> |
| 21 | + |
| 22 | +# AGENTS instructions |
| 23 | + |
| 24 | +The project's source code lives under `src/nifreeze/` and tests under `tests/`. |
| 25 | + |
| 26 | +## Testing |
| 27 | + |
| 28 | +### Pre-requisites |
| 29 | + |
| 30 | +- Bootstrap version metadata (which will create an `src/nifreeze/_version.py` file): |
| 31 | + ``` |
| 32 | + python -m hatch version |
| 33 | + ``` |
| 34 | + |
| 35 | +- Some software needs to be installed prior to testing, for example ANTs |
| 36 | + ``` |
| 37 | + conda install -c conda-forge ants=2.4 libitk=5.3 libiconv |
| 38 | + ``` |
| 39 | +- Notebooks generate figures with latex commands inside, therefore: |
| 40 | + ``` |
| 41 | + sudo apt install texlive texlive-latex-extra texlive-fonts-recommended cm-super dvipng |
| 42 | + ``` |
| 43 | +- A number of tests use pre-existing data (stored in the git-annex-enabled GIN G-Node https://gin.g-node.org/nipreps-data/tests-nifreeze) that need be found at location indicated by the environment variable `TEST_DATA_HOME`: |
| 44 | + ``` |
| 45 | + uvx datalad-installer --sudo ok git-annex |
| 46 | + uv tool install --with=datalad-osf --with=datalad-next datalad |
| 47 | + uv tool install --with=datalad-next datalad-osf |
| 48 | + datalad wtf # check datalad is installed |
| 49 | +
|
| 50 | + # Install the dataset |
| 51 | + if [[ ! -d "${TEST_DATA_HOME}" ]]; then |
| 52 | + datalad install -rg --source=https://gin.g-node.org/nipreps-data/tests-nifreeze ${TEST_DATA_HOME} |
| 53 | + else |
| 54 | + cd ${TEST_DATA_HOME} |
| 55 | + datalad update --merge -r . |
| 56 | + datalad get -r -J4 * |
| 57 | + fi |
| 58 | + ``` |
| 59 | + Files in GIN's annex can be retrieved using curl by composing the URL like this one for the [`dmri_data/motion_test_data/dwi_motion.h5` file](https://gin.g-node.org/nipreps-data/tests-nifreeze/raw/master/dmri_data/motion_test_data/dwi_motion.h5) |
| 60 | + |
| 61 | +- Some test data comes from DIPY: |
| 62 | + ``` |
| 63 | + echo "from dipy.data import fetch_stanford_hardi; fetch_stanford_hardi()" > fetch.py |
| 64 | + uv tool install dipy |
| 65 | + uv add --script fetch.py dipy |
| 66 | + uv run fetch.py |
| 67 | + ``` |
| 68 | + |
| 69 | +Details about testing are found in `.github/workflows/test.yml` |
| 70 | + |
| 71 | +### Unit tests |
| 72 | + |
| 73 | +- Unit tests can be executed with pytest: `pytest tests/`. |
| 74 | +- The project includes doctests, which can be run with `pytest --doctest-module src/nifreeze` |
| 75 | + |
| 76 | +### Integration tests and benchmarks |
| 77 | + |
| 78 | +- The full battery of tests can be run through tox (`tox -v`) |
| 79 | +- Install tox using `uv tool install --with=tox-uv --with=tox-gh-actions tox` |
| 80 | + |
| 81 | +## Documentation building |
| 82 | + |
| 83 | +Documentation can be built as described in `.github/workflows/docs-build-pr.yml`. |
| 84 | + |
| 85 | +## Linting |
| 86 | + |
| 87 | +Before accepting new PRs, we use the latest version of Ruff to lint the code, as in `.github/workflows/contrib.yml`: |
| 88 | + |
| 89 | +- Check correctness: |
| 90 | + ``` |
| 91 | + pipx run ruff check --fix <files> |
| 92 | + ``` |
| 93 | +- Reformat: |
| 94 | + ``` |
| 95 | + pipx run ruff format <files> |
| 96 | + ``` |
| 97 | + |
| 98 | +## Codex instructions |
| 99 | + |
| 100 | +- Always plan first |
| 101 | +- Think harder in the planning phase |
| 102 | +- When proposing tasks, highlight potential critical points that could lead to side effects. |
| 103 | + |
| 104 | +## Commits and PRs |
| 105 | + |
| 106 | +- Commit messages should follow the semantic commit conventions, and at least, contain one line with the following format: `<type-code>: <message>` where `<type-code>` indicates the type of comment. Type of comments can be fixes and bugfixes (`fix:`), enhancements and new features (`enh:`), style (`sty:`), documentation (`doc:`), maintenance (`mnt:`), etc. |
| 107 | +- PR titles should also be semantic, and use the same Type codes but in all caps (e.g., `FIX:`, `ENH:`, `STY:`, `DOC:`, `STY:`, `MNT:`) |
0 commit comments