Skip to content

Commit

Permalink
[MAINT] update packaging (#65)
Browse files Browse the repository at this point in the history
* update packaging(

* move cli

* un example during tests

* typo

* lint and format

* run test by default with tox

* drop python 3.7 and test on 3.12

* rely on hacthling vcs for versioning

* use pyproject for codespell config

* add load to init

* bump action version

* add other packages for testing
  • Loading branch information
Remi-Gau authored Feb 20, 2024
1 parent a8814de commit d482b20
Show file tree
Hide file tree
Showing 25 changed files with 345 additions and 169 deletions.
4 changes: 0 additions & 4 deletions .codespellrc

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/codespell.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Codespell
uses: codespell-project/actions-codespell@v2
16 changes: 3 additions & 13 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,31 +13,21 @@ concurrency:

jobs:
test:

runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macOS-latest, windows-latest]
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11']
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
fail-fast: false

steps:

- name: Clone repo
uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
pip install --upgrade setuptools
pip install -r requirements.txt
python setup.py install # install nidmresults from sources
pip install ddt
run: pip install tox
- name: Run tests
run: python test/test_reader.py
run: tox run -e tests

53 changes: 53 additions & 0 deletions .github/workflows/update_precommit_hooks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
---
name: update precommit hooks


on:

# Uses the cron schedule for github actions
#
# https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows#scheduled-events
#
# ┌───────────── minute (0 - 59)
# │ ┌───────────── hour (0 - 23)
# │ │ ┌───────────── day of the month (1 - 31)
# │ │ │ ┌───────────── month (1 - 12 or JAN-DEC)
# │ │ │ │ ┌───────────── day of the week (0 - 6 or SUN-SAT)
# │ │ │ │ │
# │ │ │ │ │
# │ │ │ │ │
# * * * * *
schedule:
- cron: 0 0 1 1,4,7,10 * # every 3 months

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

jobs:
update_precommit_hooks:

# only run on upstream repo
if: github.repository_owner == 'neuropower'

runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
allow-prereleases: false
- name: Install pre-commit
run: pip install pre-commit
- name: Update pre-commit hooks
run: pre-commit autoupdate
- name: Create Pull Request
uses: peter-evans/create-pull-request@v6
with:
commit-message: pre-commit hooks auto-update
base: main
token: ${{ secrets.GITHUB_TOKEN }}
delete-branch: true
title: '[BOT] update pre-commit hooks'
body: done via this [GitHub Action](https://github.com/${{ github.repository_owner }}/neurodesign/blob/master/.github/workflows/update_precommit_hooks.yml)
21 changes: 17 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,24 @@
*.bak

build/*
*egg*/*
dist/*
.DS_Store

.vscode

*egg*/*
*.pyc
build/
dist/

env/
venv/

# handled by hatch
nidmresults/_version.py

*.nidm.zip

test/data
debug.log

test/data

.tox
73 changes: 73 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
---
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks

repos:
# - repo: https://github.com/pre-commit/pre-commit-hooks
# rev: v4.5.0
# hooks:
# - id: check-ast
# - id: check-case-conflict
# - id: check-json
# - id: check-merge-conflict
# - id: check-toml
# - id: check-yaml
# - id: end-of-file-fixer
# - id: mixed-line-ending
# - id: trailing-whitespace

# - repo: https://github.com/pycqa/isort
# rev: 5.13.2
# hooks:
# - id: isort
# args: [--profile, black, --settings-path, pyproject.toml]

# - repo: https://github.com/asottile/pyupgrade
# rev: v3.15.0
# hooks:
# - id: pyupgrade
# args: [--py38-plus]

# - repo: https://github.com/psf/black-pre-commit-mirror
# rev: 24.1.1
# hooks:
# - id: black
# args: [--config, pyproject.toml]

# - repo: https://github.com/adamchainz/blacken-docs
# rev: 1.16.0
# hooks:
# - id: blacken-docs
# additional_dependencies:
# - black==23.9.1

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

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

- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
rev: v2.12.0
hooks:
- id: pretty-format-toml
args: [--autofix, --indent, '4']

# - repo: https://github.com/pre-commit/pygrep-hooks
# rev: v1.10.0
# hooks:
# - id: rst-backticks

# - repo: https://github.com/pyCQA/flake8
# rev: 7.0.0
# hooks:
# - id: flake8
# args: [--config, .flake8, --verbose, nilearn, examples, maint_tools]
# additional_dependencies: [flake8-docstrings, flake8-use-fstring, flake8-functions]
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# nidmresults
A Python library to read and write [NIDM-Results](http://nidm.nidash.org/specs/nidm-results.html) packs.

specification: http://nidm.nidash.org/specs/nidm-results.html
manuscript: https://dx.doi.org/10.1038/sdata.2016.102

You are free to copy, modify, and distribute nidmresults with attribution under the terms of the MIT license. See the [LICENSE file](LICENSE.md) for details.

## Install
Expand Down
8 changes: 0 additions & 8 deletions README.rst

This file was deleted.

1 change: 0 additions & 1 deletion __init__.py

This file was deleted.

39 changes: 0 additions & 39 deletions bin/nidmreader

This file was deleted.

19 changes: 0 additions & 19 deletions bin/nidmresults

This file was deleted.

4 changes: 1 addition & 3 deletions examples/ex_read_nidm.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# Example: reading a NIDM pack available on NeuroVault
import os
import json
import shutil
import tempfile
import nidmresults as nidm
import urllib.request

Expand All @@ -11,7 +9,7 @@
nidmpack = "2210_fsl_default_130.nidm.zip"

if not os.path.isfile(nidmpack):
print('Downloading ' + nidmpack)
print(f'Downloading {nidmpack}')
urllib.request.urlretrieve(nidm_url, nidmpack)

# Known issues with NIDM packs in collection 2210
Expand Down
7 changes: 4 additions & 3 deletions nidmresults/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import os
from pkg_resources import get_distribution

from .load import load
from nidmresults.load import load

from nidmresults._version import __version__

latest_owlfile = os.path.join(
os.path.dirname(os.path.dirname(__file__)), 'nidmresults', 'owl',
"nidm-results_130.owl")

__version__ = get_distribution('nidmresults').version
__all__ = ["load"]
Empty file added nidmresults/cli/__init__.py
Empty file.
48 changes: 29 additions & 19 deletions bin/nidm_mkda_convert → nidmresults/cli/nidm_mkda_convert.py
Original file line number Diff line number Diff line change
@@ -1,33 +1,38 @@
#!/usr/bin/python
"""
Create a database suitable for use with MKDA toolbox
"""Create a database suitable for use with MKDA toolbox.
@author: Camille Maumet <c.m.j.maumet@warwick.ac.uk>
@copyright: University of Warwick 2013-2014
"""

from __future__ import division, print_function, absolute_import
import os
from __future__ import absolute_import, division, print_function

import argparse
from nidmresults.graph import Graph
import os
import sys

from nidmresults import __version__
from nidmresults.graph import Graph

if __name__ == "__main__":

def main(argv=sys.argv):
parser = argparse.ArgumentParser(
description='Convert a set of NIDM-Results packs to an MKDA-compliant \
csv file.')
description="Convert a set of NIDM-Results packs to an MKDA-compliant \
csv file."
)
parser.add_argument(
'-o', '--outfile',
help='Name of the csv file.', default="mkda.csv")
"-o", "--outfile", help="Name of the csv file.", default="mkda.csv"
)
parser.add_argument(
'nidmpacks',
help='Path to NIDM-Results packs (.nidm.zip) separated by spaces.',
nargs="+")
"nidmpacks",
help="Path to NIDM-Results packs (.nidm.zip) separated by spaces.",
nargs="+",
)
parser.add_argument(
'--version', action='version',
version='{version}'.format(version=__version__))
"--version", action="version", version="{version}".format(version=__version__)
)

args = parser.parse_args()
args = parser.parse_args(argv[1:])

nidmpacks = args.nidmpacks

Expand All @@ -47,8 +52,13 @@
first = False

if not os.path.isfile(nidmpack):
raise Exception("Unknown file: "+str(nidmpack))
raise Exception("Unknown file: " + str(nidmpack))

nidmgraph = Graph(nidm_zip=nidmpack)
con_ids = nidmgraph.serialize(outfile, "mkda", overwrite=overwrite,
last_used_con_id=max(con_ids.values()))
con_ids = nidmgraph.serialize(
outfile, "mkda", overwrite=overwrite, last_used_con_id=max(con_ids.values())
)


if __name__ == "__main__":
main()
Loading

0 comments on commit d482b20

Please sign in to comment.