Skip to content

Commit

Permalink
Merge pull request #42 from bids-apps/lint
Browse files Browse the repository at this point in the history
[ENH] reformat, refactor and implement some bids app 2.0 features
  • Loading branch information
Remi-Gau authored May 9, 2024
2 parents 37b2e3d + 32d679c commit a648781
Show file tree
Hide file tree
Showing 11 changed files with 269 additions and 99 deletions.
24 changes: 8 additions & 16 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,42 +50,34 @@ jobs:

- run: mkdir -p ${HOME}/outputs<< parameters.dataset >>

- run: sudo apt-get install tree

- run:
name: print version
command: |
docker run -ti --rm --read-only \
-v /tmp/workspace/data/ds114_test1:/bids_dataset \
bids/${CIRCLE_PROJECT_REPONAME,,} --version
# participant level tests for single session dataset
- run:
command: |
docker run -ti --rm --read-only \
-v /tmp/workspace/data/ds114_test<< parameters.dataset >>:/bids_dataset \
-v ${HOME}/outputs<< parameters.dataset >>:/outputs \
bids/${CIRCLE_PROJECT_REPONAME,,} /bids_dataset /outputs participant --participant_label 01
no_output_timeout: 6h
- run:
name: participant level test
command: |
docker run -ti --rm --read-only \
-v /tmp/workspace/data/ds114_test<< parameters.dataset >>:/bids_dataset \
-v ${HOME}/outputs<< parameters.dataset >>:/outputs \
bids/${CIRCLE_PROJECT_REPONAME,,} /bids_dataset /outputs participant --participant_label 02
no_output_timeout: 6h
bids/${CIRCLE_PROJECT_REPONAME,,} /bids_dataset /outputs participant
tree ${HOME}/outputs<< parameters.dataset >>
- run:
name: group level test
command: |
docker run -ti --rm --read-only \
-v /tmp/workspace/data/ds114_test<< parameters.dataset >>:/bids_dataset \
-v ${HOME}/outputs1:/outputs \
-v ${HOME}/outputs<< parameters.dataset >>:/outputs \
bids/${CIRCLE_PROJECT_REPONAME,,} /bids_dataset /outputs group
no_output_timeout: 6h

- store_artifacts:
path: ~/output<< parameters.dataset >>
tree ${HOME}/outputs<< parameters.dataset >>
deploy:

machine:
image: ubuntu-2204:2022.10.2

Expand Down
28 changes: 28 additions & 0 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
name: validate boutiques descriptor

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

on:
push:
branches: [master]
pull_request:
branches: ['*']

jobs:
validate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.12
- name: Install
run: pip install boutiques
- name: Validate
run: bosh validate boutiques/descriptor.json
23 changes: 21 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,12 @@ repos:
- id: check-case-conflict
- id: check-merge-conflict


- repo: https://github.com/jumanjihouse/pre-commit-hook-yamlfmt
rev: 0.2.3
hooks:
- id: yamlfmt
args: [--mapping, '2', --sequence, '2', --offset, '0']


- repo: https://github.com/hadolint/hadolint
rev: v2.13.0-beta
hooks:
Expand All @@ -32,5 +30,26 @@ repos:
types: [dockerfile]
entry: ghcr.io/hadolint/hadolint hadolint

- repo: https://github.com/pycqa/isort
rev: 5.13.2
hooks:
- id: isort

# Aplly black formatting to python code
# https://github.com/psf/black
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 24.4.2
hooks:
- id: black
args: [--config, pyproject.toml]

# Checks for spelling errors
- repo: https://github.com/codespell-project/codespell
rev: v2.2.6
hooks:
- id: codespell
args: [--toml, pyproject.toml]
additional_dependencies: [tomli]

ci:
skip: [hadolint-docker]
5 changes: 3 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
FROM bids/base_fsl:6.0.1
FROM bids/base_fsl:6.0.1@sha256:b92b9b4a0642dfbe011c3827384f781ba7d377686e82edaf14f406d3eb906783

ARG DEBIAN_FRONTEND="noninteractive"

COPY requirements.txt /requirements.txt

RUN apt-get update -qq && \
apt-get install -q -y --no-install-recommends \
python3 \
python3-pip && \
pip3 install nibabel==5.1.0 && \
pip3 install -r /requirements.txt && \
apt-get remove -y python3-pip && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

Expand Down
4 changes: 2 additions & 2 deletions Singularity
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ Bootstrap: docker
From: bids/example

%help
You are in the BIDS-example container. To see help run
singularity run BIDS-example.simg -h
You are in the BIDS-example container.
To see help run singularity run: BIDS-example.simg -h

%runscript
exec /run.py "$@"
10 changes: 7 additions & 3 deletions boutiques/bids-app-example.json → boutiques/descriptor.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
{
"author": "chrisfilo and others",
"custom": {
"BIDSApplicationVersion": "2.0"
},
"command-line": "mkdir -p OUTPUT_DIR; /run.py BIDS_DIR OUTPUT_DIR ANALYSIS_LEVEL PARTICIPANT_LABEL SESSION_LABEL",
"container-image": {
"image": "bids/example",
"type": "docker"
},
"description": "See https://github.com/BIDS-Apps/example",
"descriptor-url": "https://github.com/BIDS-Apps/example/blob/master/boutiques/bids-app-example.json",
"descriptor-url": "https://github.com/BIDS-Apps/example/blob/master/boutiques/descriptor.json",
"groups": [
{
"description": "For a participants analysis, an output directory name must be specified. For a group analysis, a directory containing the output of participant-level analyses must be selected. ",
"description": "For a participants analysis, an output directory name must be specified. For a group analysis, a directory containing the output of participant-level analyses must be selected.",
"id": "output_directory",
"members": [
"output_dir_name",
Expand Down Expand Up @@ -54,7 +57,8 @@
"participant",
"group"
],
"value-key": "ANALYSIS_LEVEL"
"value-key": "ANALYSIS_LEVEL",
"optional": false
},
{
"command-line-flag": "--participant_label",
Expand Down
10 changes: 10 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[tool.black]
line-length = 79

[tool.codespell]

[tool.isort]
combine_as_imports = true
line_length = 79
profile = "black"
skip_gitignore = true
1 change: 1 addition & 0 deletions requirements.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nibabel
12 changes: 12 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#
# This file is autogenerated by pip-compile with Python 3.11
# by the following command:
#
# pip-compile --strip-extras requirements.in
#
nibabel==5.2.1
# via -r requirements.in
numpy==1.26.4
# via nibabel
packaging==24.0
# via nibabel
Loading

0 comments on commit a648781

Please sign in to comment.