Skip to content

Commit

Permalink
bump version, merge pull request #24 from AMYPAD/devel
Browse files Browse the repository at this point in the history
  • Loading branch information
casperdcl authored Sep 10, 2021
2 parents 8184923 + ed378ce commit 14ea116
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 49 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/comment-bot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ jobs:
post({
owner: context.repo.owner, repo: context.repo.repo,
comment_id: context.payload.comment.id, content: "eyes"})
github-token: ${{ secrets.GH_TOKEN }}
- name: Tag Commit
run: |
git clone https://${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY} repo
Expand All @@ -48,3 +49,4 @@ jobs:
post({
owner: context.repo.owner, repo: context.repo.repo,
comment_id: context.payload.comment.id, content: "rocket"})
github-token: ${{ secrets.GH_TOKEN }}
59 changes: 21 additions & 38 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,14 @@ name: Test
on: [push, pull_request]
jobs:
check:
if: github.event_name != 'push' || github.ref != 'refs/heads/devel'
if: github.event_name != 'pull_request' || github.head_ref != 'devel'
runs-on: ubuntu-latest
strategy:
matrix:
python: [2.7, 3.6, 3.9]
name: Check py${{ matrix.python }}
name: Check
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python }}
fetch-depth: 0
- uses: actions/setup-python@v2
- name: set PYSHA
run: echo "PYSHA=$(python -VV | sha256sum | cut -d' ' -f1)" >> $GITHUB_ENV
- uses: actions/cache@v1
Expand All @@ -35,8 +32,7 @@ jobs:
env:
REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
EVENT: ${{ github.event_name }}
- if: startsWith(matrix.python, '3')
run: pre-commit run -a --show-diff-on-failure
- run: pre-commit run -a --show-diff-on-failure
test:
if: github.event_name != 'pull_request' || github.head_ref != 'devel'
runs-on: ubuntu-latest
Expand All @@ -57,10 +53,10 @@ jobs:
- if: startsWith(matrix.python, '2')
run: pytest
- run: codecov
matlab:
cuda_matlab:
if: github.event_name != 'pull_request' || github.head_ref != 'devel'
runs-on: [self-hosted, python, cuda, matlab]
name: Test matlab & cuda
name: Test cuda & matlab
steps:
- uses: actions/checkout@v2
with:
Expand All @@ -74,7 +70,7 @@ jobs:
run: setup-python -p3.7 -Dr
if: ${{ always() }}
deploy:
needs: [check, test, matlab]
needs: [check, test, cuda_matlab]
name: PyPI Deploy
runs-on: ubuntu-latest
steps:
Expand All @@ -85,37 +81,24 @@ jobs:
- id: dist
uses: casperdcl/deploy-pypi@v2
with:
requirements: twine setuptools wheel setuptools_scm[toml]
build: true
gpg_key: ${{ secrets.GPG_KEY }}
password: ${{ secrets.PYPI_TOKEN }}
upload: ${{ github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags') }}
- name: Changelog
run: git log --pretty='format:%d%n- %s%n%b---' $(git tag --sort=v:refname | tail -n2 | head -n1)..HEAD > _CHANGES.md
- if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
id: create_release
uses: actions/create-release@v1
upload: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags') }}
- id: meta
name: Changelog
run: |
echo ::set-output name=tag::${GITHUB_REF#refs/tags/}
git log --pretty='format:%d%n- %s%n%b---' $(git tag --sort=v:refname | tail -n2 | head -n1)..HEAD > _CHANGES.md
- if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: miutil ${{ github.ref }} beta
name: miutil ${{ steps.meta.outputs.tag }} beta
body_path: _CHANGES.md
draft: true
- if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: dist/${{ steps.dist.outputs.whl }}
asset_name: ${{ steps.dist.outputs.whl }}
asset_content_type: application/zip
- if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: dist/${{ steps.dist.outputs.whl_asc }}
asset_name: ${{ steps.dist.outputs.whl_asc }}
asset_content_type: text/plain
files: |
dist/${{ steps.dist.outputs.whl }}
dist/${{ steps.dist.outputs.whl_asc }}
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
*.py[cod]
__pycache__/
/miutil/_dist_ver.py
/.eggs/
/*.egg-info/
/*.egg*/
/build/
/dist/
/.coverage*
/coverage.xml
/.pytest_cache/
11 changes: 6 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ default_language_version:
python: python3
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.4.0
rev: v4.0.1
hooks:
- id: check-added-large-files
- id: check-case-conflict
Expand All @@ -21,24 +21,25 @@ repos:
- id: todo
name: Check TODO
language: pygrep
args: [-i]
entry: TODO
types: [text]
exclude: ^(.pre-commit-config.yaml|.github/workflows/test.yml)$
args: [-i]
- repo: https://gitlab.com/pycqa/flake8
rev: 3.8.4
rev: 3.9.2
hooks:
- id: flake8
args: [-j8]
additional_dependencies:
- flake8-bugbear
- flake8-comprehensions
- flake8-debugger
- flake8-string-format
- repo: https://github.com/psf/black
rev: 19.10b0
rev: 21.8b0
hooks:
- id: black
- repo: https://github.com/PyCQA/isort
rev: 5.7.0
rev: 5.9.3
hooks:
- id: isort
4 changes: 3 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ miutil

Medical imaging utilities.

|Version| |Py-Versions| |Tests| |Coverage| |DOI| |LICENCE|
|Version| |Py-Versions| |Conda| |Tests| |Coverage| |DOI| |LICENCE|

Basic functionality needed for `AMYPAD <https://github.com/AMYPAD/AMYPAD>`_
and `NiftyPET <https://github.com/NiftyPET/NiftyPET>`_.
Expand Down Expand Up @@ -50,6 +50,8 @@ use the package name ``miutil[option1,option2]``.
:target: https://github.com/AMYPAD/miutil/releases
.. |Py-Versions| image:: https://img.shields.io/pypi/pyversions/miutil.svg?logo=python&logoColor=white
:target: https://pypi.org/project/miutil
.. |Conda| image:: https://img.shields.io/conda/v/conda-forge/miutil.svg?label=conda&logo=conda-forge
:target: https://anaconda.org/conda-forge/miutil
.. |DOI| image:: https://zenodo.org/badge/DOI/10.5281/zenodo.4281542.svg
:target: https://doi.org/10.5281/zenodo.4281542
.. |LICENCE| image:: https://img.shields.io/pypi/l/miutil.svg
Expand Down
12 changes: 12 additions & 0 deletions miutil/fdio.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import logging
import re
from contextlib import contextmanager
from os import makedirs
from shutil import copyfileobj, rmtree
Expand Down Expand Up @@ -73,3 +74,14 @@ def extractall(fzip, dest, desc="Extracting"):
if mode:
(dest / i.filename).chmod(mode)
log.debug(oct((i.external_attr >> 16) & 0o777))


def nsort(fnames):
"""Sort a file list, automatically detecting embedded numbers"""

def path2parts(fname):
parts = re.split(r"([0-9][0-9.]*e[-+][0-9]+|[0-9]+\.[0-9]+|[0-9]+)", fname)
parts[1::2] = map(float, parts[1::2])
return parts

return sorted(fnames, key=path2parts)
4 changes: 1 addition & 3 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name=miutil
description=Medical imaging utilities for the AMYPAD and NiftyPET projects
long_description=file: README.rst
long_description_content_type=text/x-rst
license=Apache 2.0
license=Apache-2.0
license_file=LICENCE.md
url=https://github.com/AMYPAD/miutil
project_urls=
Expand Down Expand Up @@ -49,8 +49,6 @@ python_requires=>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*
[options.extras_require]
dev=
pre-commit
twine
wheel
pytest
pytest-cov
pytest-timeout
Expand Down
7 changes: 7 additions & 0 deletions tests/test_fdio.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,10 @@ def test_extractall(tmp_path):
"Medical imaging utilities."
in (tmpdir / "miutil-0.6.0" / "README.rst").read_text()
)


def test_nsort():
fnames = ["foo1_bar_21.nii.gz", "foo1_bar_1.2.nii.gz", "foo1_bar_1.nii.gz"]
assert fdio.nsort(fnames) == fnames[::-1]
fnames = [i[9:] for i in fnames]
assert fdio.nsort(fnames) == fnames[::-1]

0 comments on commit 14ea116

Please sign in to comment.