Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quality (actions, pre-commit) and tests #31

Merged
merged 37 commits into from
Dec 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
6883ab0
Add quality workflow
kaitj Nov 4, 2022
6c76748
update pyproject.toml for quality
kaitj Nov 4, 2022
c466936
update precommit with cmd line args
kaitj Nov 4, 2022
8783832
Add types to reviewer assignment
kaitj Nov 13, 2022
cd3f7b4
quality fixes
kaitj Nov 16, 2022
6796b9c
add yamlfix pre-commit and action
kaitj Nov 18, 2022
cf3c0b0
update pyproject.toml settings
kaitj Nov 22, 2022
1f7dfd7
add pre-commit length for snakefmt
kaitj Nov 22, 2022
5080e9e
rm redundant flake8 ignore
kaitj Nov 22, 2022
cc36335
add fake data for testing
kaitj Nov 22, 2022
bc0eebd
add testing for freesurfer
kaitj Nov 22, 2022
fc9205b
add test case for responsemean
kaitj Nov 22, 2022
7892b49
Use function to check additional dir inputs
kaitj Nov 22, 2022
68eafd6
add test case for dwi_dir flag
kaitj Nov 22, 2022
79e0863
update actions workflow with dry-runs
kaitj Nov 22, 2022
09a80dc
rm debug print statement
kaitj Nov 22, 2022
ccfc486
rm unnecessary files from test
kaitj Nov 23, 2022
6e22438
add type: Path for relative paths
kaitj Nov 29, 2022
4092405
Fix dwi_dir flag, add msg
kaitj Dec 1, 2022
7dc5967
add .gitignore
kaitj Nov 7, 2022
4338fb3
update resource files
kaitj Nov 21, 2022
fef07cf
update rule for removing thalamus labels from segmentation
kaitj Nov 17, 2022
ca5827f
Update tsv file for labelmerge
kaitj Nov 17, 2022
94b0cb2
Update config and fs tsv
kaitj Nov 17, 2022
4e538d5
Copy zona tsv to appropriate directory
kaitj Nov 17, 2022
a19d2ed
update with smk version of python script
kaitj Nov 18, 2022
e7486d8
wip - changes for labelmerge rule
kaitj Nov 18, 2022
f9701ad
fix conflicts, update dseg
kaitj Nov 22, 2022
b458bbd
add labelmerge placeholder
kaitj Nov 22, 2022
cda1307
Update comment regarding transformation
kaitj Nov 23, 2022
0507abf
fix FreesurferThal_dseg.tsv
kaitj Nov 30, 2022
a491fea
add labelmerge container
kaitj Nov 30, 2022
28acc1a
snakefmt quality fixes
kaitj Nov 30, 2022
1a6a28a
fix column headers for tsvs
kaitj Nov 30, 2022
bb0a149
add snakemake cores flag for labelmerge
kaitj Nov 30, 2022
144af01
Merge pull request #30 from kaitj/labelmerge
tkkuehn Dec 5, 2022
717fd3a
fix test_dwi (search T1w instead of dwi)
kaitj Dec 5, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 2 additions & 1 deletion .github/auto_assign.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
# Set to true to add reviewers to pull requests
addReviewers: true

Expand Down Expand Up @@ -26,4 +27,4 @@ numberOfReviewers: 0

# A list of keywords to be skipped the process that add reviewers if pull requests include it
# skipKeywords:
# - wip
# - wip
41 changes: 21 additions & 20 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -1,44 +1,45 @@
name-template: '$RESOLVED_VERSION'
tag-template: 'v$RESOLVED_VERSION'
---
name-template: $RESOLVED_VERSION
tag-template: v$RESOLVED_VERSION
filter-by-commitish: true

template: |
## Changes
$CHANGES
categories:
- title: '🚀 Features'
- title: 🚀 Features
labels:
- 'breaking'
- 'enhancement'
- title: '🐛 Bug Fixes'
- breaking
- enhancement
- title: 🐛 Bug Fixes
labels:
- 'bug'
- title: '🧰 Maintenance'
- bug
- title: 🧰 Maintenance
labels:
- 'maintenance'
- 'test'
- title: '📝 Documentation'
- maintenance
- test
- title: 📝 Documentation
labels:
- 'documentation'
- documentation

exclude-labels:
- skip_changelog

change-template: '- $TITLE @$AUTHOR (#$NUMBER)'
change-title-escapes: '\<*_&' # You can add # and @ to disable mentions, and add ` to disable code blocks.
change-title-escapes: \<*_& # You can add # and @ to disable mentions, and add ` to disable code blocks.

version-resolver:
# major:
# labels:
# - 'breaking'
minor:
labels:
- 'breaking'
- 'enhancement'
- breaking
- enhancement
patch:
labels:
- 'maintenance'
- 'bug'
- 'test'
- 'documentation'
default: patch
- maintenance
- bug
- test
- documentation
default: patch
10 changes: 6 additions & 4 deletions .github/workflows/assign_reviewers.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
name: Assign reviewer
---
name: Assign reviewer

on:
pull_request_target:
pull_request_target:
types: [opened, ready_for_review]

jobs:
jobs:
assign:
runs-on: ubuntu-latest
if: github.event.pull_request.assignee == null
Expand All @@ -12,4 +14,4 @@ jobs:
- name: Assign reviewer
uses: kentaro-m/auto-assign-action@v1.1.2
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"
repo-token: ${{ secrets.GITHUB_TOKEN }}
11 changes: 6 additions & 5 deletions .github/workflows/bump_version.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
name: Bump version
on:
pull_request_target:
Expand Down Expand Up @@ -49,9 +50,9 @@ jobs:
- name: Update version in pyproject.toml
uses: jacobtomlinson/gha-find-replace@master
with:
include: 'pyproject.toml'
find: 'version = "(?:([0-9]+\.[0-9]+\.[0-9]+.+)|([0-9]+\.[0-9]+\.[0-9]+))"'
replace: 'version = "${{ env.NEW_RELEASE }}-pre.${{ env.NEW_BUMP }}"'
include: pyproject.toml
find: version = "(?:([0-9]+\.[0-9]+\.[0-9]+.+)|([0-9]+\.[0-9]+\.[0-9]+))"
replace: version = "${{ env.NEW_RELEASE }}-pre.${{ env.NEW_BUMP }}"

- name: Commit updates
env:
Expand All @@ -60,10 +61,10 @@ jobs:
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git diff-index --quiet HEAD || git commit -m "Bump version to $SNAKEBIDS_VERSION" -a

- name: Push changes
uses: CasperWA/push-protected@v2
with:
branch: ${{ github.event.pull_request.base.ref }}
token: ${{ secrets.BP_PAT_TOKEN }}
unprotect_reviews: True
unprotect_reviews: true
118 changes: 118 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
---
name: Lint and test workflow

on:
push:
branches:
- '*'
- '!push-action/*'
pull_request:
branches:
- '*'
- '!push-action/*'

jobs:
quality:
name: Lint code
if: github.event.pull_request.merged == false
runs-on: ubuntu-latest

steps:
- name: Clone repo
uses: actions/checkout@master

- name: Setup Python 3.10
uses: actions/setup-python@v2
with:
python-version: '3.10'

- uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-3.10
restore-keys: ${{ runner.os }}-pip-3.10

- name: Install Poetry
uses: snok/install-poetry@v1
with:
version: 1.2.0
virtualenvs-create: true
virtualenvs-in-project: true

- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v2
with:
path: .venv
key: venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}-3.10

- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root --with dev

- name: yamlfix
run: poetry run poe yamlfix

- name: isort
run: poetry run poe isort

- name: black
run: poetry run poe black

- name: flake8
run: poetry run poe flake8

- name: snakefmt
run: poetry run poe snakefmt

test:
runs-on: ubuntu-latest
needs: [quality]
strategy:
matrix:
python-version: ['3.8', '3.9', '3.10']
steps:
- name: Clone repo
uses: actions/checkout@master

- name: Select Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ matrix.python-version }}
restore-keys: ${{ runner.os }}-pip-${{ matrix.python-version }}

- name: Install Poetry
uses: snok/install-poetry@v1
with:
version: 1.2.0
virtualenvs-create: true
virtualenvs-in-project: true

- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v2
with:
path: .venv
key: venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}-${{ matrix.python-version
}}

- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root --with dev

- name: Test minimum inputs
run: poetry run poe test_base

- name: Test freesurfer input
run: poetry run poe test_freesurfer

- name: Test responsemean input
run: poetry run poe test_responsemean

- name: Test dwi input
run: poetry run poe test_dwi
12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Add testing folders to ignore
test/data/derivatives/.snakemake/
test/data/derivatives/config/
test/data/derivatives/.snakebids

# Tar files
*.tar

# Ignore files that are available in tar
**/zona_bb_subcortex/MNI152
**/zona_bb_subcortex/MNI2009b
**/zona_bb_subcortex/transforms
36 changes: 24 additions & 12 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,27 +1,39 @@
---
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace

- repo: https://github.com/pycqa/isort
- repo: local
hooks:
- id: yamlfix
name: yamlfix
entry: bash -c "poetry run poe yamlfix"
language: system

- repo: https://github.com/pycqa/isort
rev: 5.10.1
hooks:
- id: isort
- id: isort
args: [--profile=black, --multi-line=3]

- repo: https://github.com/psf/black
- repo: https://github.com/psf/black
rev: 22.8.0
hooks:
- id: black
- id: black
args: [--line-length=79]

- repo: https://github.com/pycqa/flake8
- repo: https://github.com/pycqa/flake8
rev: 5.0.4
hooks:
- id: flake8
- id: flake8
args: [--ignore=E501]

- repo: https://github.com/snakemake/snakefmt
- repo: https://github.com/snakemake/snakefmt
rev: 0.6.1
hooks:
- id: snakefmt
- id: snakefmt
args: [--include=\.smk$|^Snakefile, --line-length=79]
34 changes: 22 additions & 12 deletions dbsc/config/snakebids.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,22 @@ parse_args:
--freesurfer_dir:
help: The path to the freesurfer directory. If not provided, workflow
assumes the directory exists at <output_dir>/freesurfer.
nargs: "?"
type: Path

--dwi_dir:
help: The path to the directory containing pre-processed dwi data
transformed to subject T1w space. If not provided, workflow assumes
this data exists in <bids_dir>/<subject>/dwi.
nargs: "?"
type: Path

--responsemean_dir:
help: 'Provide directory containing average response functions. If not
provided, one will be computed from the subjects in the input
directory.'
nargs: "?"
type: Path

--shells:
help: '(Mrtrix3) specify one or more b-values to use during processing, as
Expand Down Expand Up @@ -142,29 +153,28 @@ parse_args:

# Workflow specific config
# Spaces available (MNI152, MNINlin2009bAsym)
Space: MNI152
Space: MNI152NLin6Asym

zona_bb_subcortex:
MNI152:
dir: 'resources/MNI152'
T1w: 'resources/MNI152/sub-SNSX32NLin2020Asym_space-MNI152_T1w.nii.gz'
seg: 'resources/MNI152/sub-SNSX32NLin2020Asym_space-MNI152_ZonaBBSubCorSeg.nii.gz'
exclude: 'resources/MNI152/sub-SNSX32NLin2020Asym_space-MNI152_desc-exclude_ROI.nii.gz'
MNI2009:
dir: 'resources/MNI2009b'
T1w: 'resources/MNI2009b/sub-SNSX32NLin2020Asym_space-MNI152_T1w.nii.gz'
seg: 'resources/MNI2009b/sub-SNSX32NLin2020Asym_space-MNINlin2009bAsym_ZonaBBSubCorSeg.nii.gz'
exclude: 'resources/MNI2009b/sub-SNSX32NLin2020Asym_space-MNINlin2009bAsym_desc-exclude_ROI.nii.gz'
tsv: 'resources/zona_bb_subcortex/desc-ZonaBBSubcor_dseg.tsv'
MNI152NLin6Asym:
dir: 'resources/zona_bb_subcortex/MNI152NLin6Asym/'
T1w: 'tpl-MNI152NLin6Asym_res-04_desc-brain_T1w.nii.gz'
seg: 'sub-SNSX32NLin2020Asym_space-MNI152NLin6Asym_desc-ZonaBBSubcor_dseg.nii.gz'
MNI152NLin2009bAsym:
dir: 'resources/zona_bb_subcortex/MNI152NLin2009bAsym/'
seg: 'sub-SNSX32NLin2020Asym_space-MNI152NLin2009bAsym_desc-ZonaBBSubcor_dseg.nii.gz'

# NOTE: This may not be needed with labelmerge
freesurfer:
labels: 'resources/freesurfer/fs_labels.csv'
tsv: 'resources/freesurfer/desc-FreesurferThal_dseg.tsv'

# Containers
# NOTE: Update from latest to use specific tags
singularity:
freesurfer: "docker://pwighton/freesurfer:7.2.0"
neuroglia-core: "docker://khanlab/neuroglia-core:latest"
mrtrix: "docker://brainlife/mrtrix:3.0.3"
labelmerge: "docker://kaitj/labelmerge:v0.1.0"

fs_license: /path/to/fs/license
Loading