Skip to content

Commit

Permalink
Merge pull request #96 from kaitj/maint/dep-updates
Browse files Browse the repository at this point in the history
Maintenance updates
  • Loading branch information
kaitj authored Jan 23, 2024
2 parents 703521f + a947d96 commit b648e42
Show file tree
Hide file tree
Showing 12 changed files with 1,192 additions and 1,188 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/assign_reviewers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ on:
types: [opened, ready_for_review]
jobs:
assign-reviewer:
uses: khanlab/actions/.github/workflows/workflow-pr_task-assignReviewer.yml@v0.3.0
uses: khanlab/actions/.github/workflows/workflow-pr_task-assignReviewer.yml@v0.3.4
2 changes: 1 addition & 1 deletion .github/workflows/bump_version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ on:
jobs:
bump-version:
if: github.event.pull_request.merged == true
uses: khanlab/actions/.github/workflows/workflow-version_task-semverGithub.yml@v0.3.0
uses: khanlab/actions/.github/workflows/workflow-version_task-semverGithub.yml@v0.3.4
secrets:
BP_PAT: ${{ secrets.BP_PAT_TOKEN }}
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
tags: [v*]
jobs:
deploy_docker:
uses: khanlab/actions/.github/workflows/workflow-release_task-deployDocker.yml@v0.3.0
uses: khanlab/actions/.github/workflows/workflow-release_task-deployDocker.yml@v0.3.4
with:
maximize_space: true
secrets:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
required: false
jobs:
release_package:
uses: khanlab/actions/.github/workflows/workflow-release_task-publishGithub.yml@v0.3.0
uses: khanlab/actions/.github/workflows/workflow-release_task-publishGithub.yml@v0.3.4
with:
comments: ${{ github.event.inputs.comments }}
pipeline-description: true
Expand Down
18 changes: 7 additions & 11 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,34 @@
name: Lint and test workflow
on:
push:
branches: ["*", "!push-action/*"]
branches: ['*', '!push-action/*']
pull_request:
branches: ["*", "!push-action/*"]
branches: ['*', '!push-action/*']
jobs:
quality:
name: Lint code
if: github.event.pull_request.merged == false
runs-on: ubuntu-latest
steps:
- name: Setup Python environment
uses: khanlab/actions/.github/actions/action-setup_task-installPyProject@v0.3.0
uses: khanlab/actions/.github/actions/action-setup_task-installPyProject@v0.3.4
with:
python-version: "3.10"
python-version: '3.10'
- name: yamlfix
run: poetry run poe yamlfix-check
- name: isort
run: poetry run poe isort-check
- name: black
run: poetry run poe black-check
- name: ruff
run: poetry run poe ruff-check
run: poetry run poe ruff-lint-check
- name: snakefmt
run: poetry run poe snakefmt-check
test:
runs-on: ubuntu-latest
needs: [quality]
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10"]
python-version: ['3.8', '3.9', '3.10', '3.11']
steps:
- name: Setup Python environments
uses: khanlab/actions/.github/actions/action-setup_task-installPyProject@v0.3.0
uses: khanlab/actions/.github/actions/action-setup_task-installPyProject@v0.3.4
with:
python-version: ${{ matrix.python-version }}
install-library: true
Expand Down
41 changes: 19 additions & 22 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
---
default_language_version:
python: python3.10
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
Expand All @@ -8,26 +10,21 @@ repos:
- id: trailing-whitespace
- repo: local
hooks:
- id: yamlfix
name: yamlfix
entry: bash -c "poetry run poe yamlfix"
- name: yamlfix
id: yamlfix
entry: poetry run poe yamlfix
language: system
- name: ruff-lint
id: ruff-lint
entry: poetry run poe ruff-lint
language: system
types_or: [cython, pyi, python]
- name: ruff-format
id: ruff-format
entry: poetry run poe ruff-format
language: system
types_or: [cython, pyi, python]
- name: snakefmt
id: snakefmt
entry: poetry run poe snakefmt
language: system
- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: isort
args: [--profile=black, --multi-line=3]
- repo: https://github.com/psf/black
rev: 22.8.0
hooks:
- id: black
args: [--line-length=79]
- repo: https://github.com/pycqa/flake8
rev: 5.0.4
hooks:
- id: flake8
- repo: https://github.com/snakemake/snakefmt
rev: 0.6.1
hooks:
- id: snakefmt
args: [--include=\.smk$|^Snakefile, --line-length=79]
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,4 @@
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ["_static"]
html_static_path = ["_static"]
2,249 changes: 1,138 additions & 1,111 deletions poetry.lock

Large diffs are not rendered by default.

46 changes: 15 additions & 31 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,27 @@ documentation = "https://scattr.readthedocs.io"
packages = [{ include = "scattr" }]

[tool.poetry.dependencies]
python = ">=3.8, <3.11"
snakebids = "^0.9.0"
python = ">=3.8, <3.12"
snakebids = "^0.10.2"
labelmerge = "^0.4.7"
matplotlib = "^3.7.1"
nibabel = "^3.2.2"
nilearn = "^0.10.0"
numpy = "^1.22.3"
scipy = "^1.8.0"
labelmerge = "^v0.4.6"
matplotlib = "^3.7.1"
niworkflows = "^1.7.9"
numpy = "^1.22.3"
pygments = "^2.15.1"
scipy = "^1.8.0"
# Required constraint for compatability with snakebids
pulp = "<2.8.0"

[tool.poetry.group.dev.dependencies]
pytest-console-scripts = "1.2"
pytest = "^7.0.1"
black = "^22.1.0"
isort = "^5.10.1"
poethepoet = "^0.13.1"
pre-commit = "^2.17.0"
snakefmt = "^0.6.1"
yamlfix = "^1.1.0"
ruff = "^0.0.267"
ruff = "^0.1.14"

[tool.poetry.scripts]
scattr = 'scattr.run:main'
Expand All @@ -45,22 +45,13 @@ build-backend = "poetry.core.masonry.api"

[tool.poe.tasks]
setup = "pre-commit install"
isort = "isort scattr"
isort-check = "isort -c scattr"
black = "black scattr"
black-check = "black --check scattr"
ruff = "ruff --fix scattr"
ruff-check = "ruff scattr"
ruff-lint = "ruff check --fix scattr"
ruff-lint-check = "ruff check scattr"
ruff-format = "ruff format ."
snakefmt = "snakefmt scattr"
snakefmt-check = "snakefmt --check scattr"
quality = ["yamlfix", "ruff", "isort", "black", "snakefmt"]
quality-check = [
"ruff-check",
"yamlfix-check",
"isort-check",
"black-check",
"snakefmt-check",
]
quality = ["yamlfix", "ruff-lint", "ruff-format", "snakefmt"]
quality-check = ["yamlfix-check", "ruff-lint-check", "snakefmt-check"]
test = [
"test_base",
"test_freesurfer",
Expand Down Expand Up @@ -144,15 +135,8 @@ find . -type f \\( \
\\) -exec yamlfix --check {} \\;
"""

[tool.isort]
profile = "black"
multi_line_output = 3
line_length = 79

[tool.black]
line-length = 79

[tool.ruff]
select = ["E", "W", "N", "RUF", "I", "UP"]
line-length = 79
builtins = ["snakemake"]

Expand Down
8 changes: 4 additions & 4 deletions scattr/workflow/scripts/mrtpipelines/create_exclude_mask.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ def create_exclude_mask(
Path(out_dir).mkdir(parents=True, exist_ok=True)

# Get number of labels
with open(num_labels, "r") as f:
with open(num_labels) as f:
num_labels = int(f.read().strip())

node_pairs = np.triu_indices(num_labels, k=1)

# Zona labels (currently misisng subjects)
lZI = expand( # noqa: F841 (used in shell call)
lZI = expand( # (used in shell call) # noqa: N806
bids(
root=base_dir,
datatype="roi_masks",
Expand All @@ -37,7 +37,7 @@ def create_exclude_mask(
**wildcards,
)
)
rZI = bids( # noqa: F841 (used in shell call)
rZI = bids( # (used in shell call) # noqa: N806
root=base_dir,
datatype="roi_masks",
desc="22",
Expand All @@ -62,7 +62,7 @@ def create_exclude_mask(

# Create masks - run sequentially due to parallelization errors
for idx, mask in enumerate(out_mask):
in_roi1, in_roi2 = roi1[idx], roi2[idx] # noqa: F841 (used in shell)
in_roi1, in_roi2 = roi1[idx], roi2[idx] # (used in shell)
shell(
"mrcalc -nthreads {threads} "
"{subcortical_seg} 0 -neq {in_roi1} -sub {in_roi2} -sub {lZI} "
Expand Down
6 changes: 3 additions & 3 deletions scattr/workflow/scripts/mrtpipelines/create_roi_mask.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from pathlib import Path

from snakebids import bids
from snakemake.io import expand # noqa: F401 (used in commented command)
from snakemake.io import expand # (used in commented command)
from snakemake.shell import shell


Expand All @@ -19,12 +19,12 @@ def create_roi_mask(
Path(out_dir).mkdir(parents=True, exist_ok=True)

# Read number of labels
with open(num_labels, "r") as f:
with open(num_labels) as f:
num_labels = int(f.read().strip())

# Create masks sequentially (error with trying to do it in parallel)
for idx in range(1, num_labels + 1):
roi = bids( # noqa: F841 (used in shell call)
roi = bids( # (used in shell call)
root=base_dir,
datatype="roi_masks",
desc=f"{idx}",
Expand Down
2 changes: 1 addition & 1 deletion scattr/workflow/scripts/qc/segmentation_qc.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,5 @@ def segmentation_qc(
seg_path=snakemake.input.qc_labels,
output_path_static=snakemake.output.qc_png,
output_path_html=snakemake.output.qc_html,
wildcards=snakemake.wildcards, # noqa:F821
wildcards=snakemake.wildcards,
)

0 comments on commit b648e42

Please sign in to comment.