From d707ac6de41bd6347d1d2b252237dabe951127a2 Mon Sep 17 00:00:00 2001 From: Remi Gau Date: Thu, 14 Dec 2023 16:46:31 +0100 Subject: [PATCH] use tox to install test data (#73) --- .github/workflows/test.yml | 17 ++++---------- docs/source/contributing.md | 10 ++++++++- pyproject.toml | 1 + tox.ini | 45 +++++++++++++++++++++++++++++++++++++ 4 files changed, 59 insertions(+), 14 deletions(-) create mode 100644 tox.ini diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0be3914..735a460 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -43,6 +43,9 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 0 + - uses: actions/setup-python@v5 + - name: install tox + run: pip install tox - uses: actions/cache@v3 id: cache env: @@ -54,19 +57,7 @@ jobs: - if: ${{ steps.cache.outputs.cache-hit != 'true' }} name: Download fmriprep derivative of ds000017 id: download - run: | - mkdir -p /home/runner/work/giga_connectome/giga_connectome/giga_connectome/data/test_data - cd /home/runner/work/giga_connectome/giga_connectome/giga_connectome/data/test_data - wget --retry-connrefused \ - --waitretry=5 \ - --read-timeout=20 \ - --timeout=15 \ - -t 0 \ - -q \ - -O ds000017.tar.gz \ - "https://zenodo.org/record/8091903/files/ds000017-fmriprep22.0.1-downsampled-nosurface.tar.gz?download=1" - tar -xzf ds000017.tar.gz - rm ds000017.tar.gz + run: tox -e test_data build: runs-on: ubuntu-latest diff --git a/docs/source/contributing.md b/docs/source/contributing.md index fd4fca8..8e1fbb4 100644 --- a/docs/source/contributing.md +++ b/docs/source/contributing.md @@ -27,6 +27,14 @@ pip install -e .[dev] pre-commit install ``` +5. Install the data required for testing from zenodo + +This can be done using tox by running: + +```bash +tox -e test_data +``` + ## Contributing to code This is a very generic workflow. @@ -51,7 +59,7 @@ git checkout -b your_branch 5. Run the tests locally; you can run spectfic tests to speed up the process: ```bash -pytest -v giga_connectome/tests/tests/test_connectome.py::test_calculate_intranetwork_correlation +pytest -v giga_connectome/tests/test_connectome.py::test_calculate_intranetwork_correlation ``` 6. push your changes to your online fork. If this is the first commit, you might want to set up the remote tracking: diff --git a/pyproject.toml b/pyproject.toml index 63ae89d..74833e3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -37,6 +37,7 @@ dev = [ "black", "pre-commit", "giga_connectome[test]", + 'tox', ] test = [ "pytest", diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..280d5d8 --- /dev/null +++ b/tox.ini @@ -0,0 +1,45 @@ +; See https://tox.wiki/en +[tox] +requires = + tox>=4 +; run lint by default when just calling "tox" +env_list = lint + +; ENVIRONMENTS +; ------------ +[style] +description = common environment for style checkers (rely on pre-commit hooks) +skip_install = true +deps = + pre-commit + +; COMMANDS +; -------- +[testenv:lint] +description = run all linters and formatters +skip_install = true +deps = + {[style]deps} +commands = + pre-commit run --all-files --show-diff-on-failure {posargs:} + +[testenv:test_data] +description = install test data +skip_install = true +allowlist_externals = + mkdir + wget + tar + rm +commands = + mkdir -p giga_connectome/data/test_data + wget --retry-connrefused \ + --waitretry=5 \ + --read-timeout=20 \ + --timeout=15 \ + -t 0 \ + -q \ + -O giga_connectome/data/test_data/ds000017.tar.gz \ + "https://zenodo.org/record/8091903/files/ds000017-fmriprep22.0.1-downsampled-nosurface.tar.gz?download=1" + tar -xzf giga_connectome/data/test_data/ds000017.tar.gz -C giga_connectome/data/test_data/ + rm giga_connectome/data/test_data/ds000017.tar.gz