Skip to content

Commit

Permalink
bump version, merge pull request #32 from NiftyPET/devel
Browse files Browse the repository at this point in the history
  • Loading branch information
casperdcl authored Sep 30, 2021
2 parents 4f0121d + e7d9cfd commit b1c3799
Show file tree
Hide file tree
Showing 63 changed files with 9,250 additions and 10,409 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 }}
95 changes: 52 additions & 43 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,44 +1,58 @@
name: Test
on:
- push
on: [push, pull_request]
jobs:
check:
if: github.event_name != 'pull_request' || github.repository_owner != 'NiftyPET'
runs-on: ubuntu-latest
strategy:
matrix:
python: [3.6, 3.9]
name: Check py${{ matrix.python }}
name: Check
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python }}
- name: set PYSHA
run: echo "PYSHA=$(python -VV | sha256sum | cut -d' ' -f1)" >> $GITHUB_ENV
- uses: actions/cache@v1
with:
path: ~/.cache/pre-commit
key: pre-commit|${{ env.PYSHA }}|${{ hashFiles('.pre-commit-config.yaml') }}
- run: pip install -U pre-commit twine setuptools wheel setuptools_scm[toml] ninst scikit-build
- run: HMUDIR=$HOME python setup.py sdist
- run: twine check dist/*
- name: dependencies
run: |
pip install -U pre-commit
sudo apt-get install -yqq clang-format
- uses: reviewdog/action-setup@v1
- if: github.event_name == 'push' || github.event_name == 'pull_request'
name: comment
run: |
if [[ $EVENT == pull_request ]]; then
REPORTER=github-pr-review
else
REPORTER=github-check
fi
pre-commit run -a todo | reviewdog -efm="%f:%l: %m" -name=TODO -tee -reporter=$REPORTER -filter-mode nofilter
pre-commit run -a flake8 | reviewdog -f=pep8 -name=flake8 -tee -reporter=$REPORTER -filter-mode nofilter
env:
REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
EVENT: ${{ github.event_name }}
- run: pre-commit run -a --show-diff-on-failure
test:
runs-on: [self-hosted, cuda]
name: Test
if: github.event_name != 'pull_request' || github.repository_owner != 'NiftyPET'
name: Test py${{ matrix.python }}
runs-on: [self-hosted, python, cuda, matlab]
strategy:
matrix:
python: [3.6, 3.9]
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- run: pip install -U -e .[dev]
- name: Run setup-python
run: setup-python -p${{ matrix.python }}
- run: pip install -U --no-binary nimpa -e .[dev]
- run: pytest
- run: codecov
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
- uses: codecov/codecov-action@v1
- name: Post Run setup-python
run: setup-python -p${{ matrix.python }} -Dr
if: ${{ always() }}
deploy:
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
needs: [check, test]
name: PyPI Deploy
runs-on: ubuntu-latest
Expand All @@ -47,35 +61,30 @@ jobs:
with:
fetch-depth: 0
- uses: actions/setup-python@v2
- id: dist
uses: casperdcl/deploy-pypi@v2
with:
python-version: '3.x'
- run: pip install -U twine setuptools wheel setuptools_scm[toml] ninst scikit-build
- run: HMUDIR=$HOME python setup.py sdist
- run: twine upload dist/*
requirements: twine setuptools wheel setuptools_scm[toml] ninst scikit-build
build: sdist
gpg_key: ${{ secrets.GPG_KEY }}
password: ${{ secrets.PYPI_TOKEN }}
upload: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags') }}
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
skip_existing: true
- id: collect_assets
name: Collect assets
PATHTOOLS: ${{ github.workspace }}/NiftyPET_tools
HMUDIR: ${{ github.workspace }}
- id: meta
name: Changelog
run: |
echo "::set-output name=asset_path::$(ls dist/*.tar.gz)"
echo "::set-output name=asset_name::$(basename dist/*.tar.gz)"
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
- id: create_release
uses: actions/create-release@v1
- 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: ninst ${{ github.ref }} beta
name: nipet ${{ steps.meta.outputs.tag }} stable
body_path: _CHANGES.md
draft: true
- uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ${{ steps.collect_assets.outputs.asset_path }}
asset_name: ${{ steps.collect_assets.outputs.asset_name }}
asset_content_type: application/gzip
files: |
dist/${{ steps.dist.outputs.targz }}
dist/${{ steps.dist.outputs.targz_asc }}
17 changes: 7 additions & 10 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
*.py[co]
__pycache__/

# build
MANIFEST
*.so
__pycache__/
/_skbuild/
/_cmake_test_compile/
/niftypet/nipet/cmake/
/niftypet/nipet/_dist_ver.py
MANIFEST
/*.egg*/
/build/
/dist/
/_skbuild/
/_cmake_test_compile/
/*.egg*/
/.eggs/

/.coverage
/.coverage*
/coverage.xml
/.pytest_cache/
41 changes: 37 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,51 @@ default_language_version:
python: python3
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.3.0
rev: v4.0.1
hooks:
- id: check-added-large-files
- id: check-case-conflict
- id: check-docstring-first
- id: check-executables-have-shebangs
- id: check-toml
- id: check-merge-conflict
- id: check-yaml
- id: debug-statements
- id: end-of-file-fixer
- id: mixed-line-ending
- id: sort-simple-yaml
- id: trailing-whitespace
- hooks:
- repo: local
hooks:
- id: todo
name: Check TODO
language: pygrep
args: [-i]
entry: TODO
types: [text]
exclude: ^(.pre-commit-config.yaml|.github/workflows/test.yml)$
- repo: https://gitlab.com/pycqa/flake8
rev: 3.9.2
hooks:
- id: flake8
args: [-j8]
additional_dependencies:
- flake8-bugbear
- flake8-comprehensions
- flake8-debugger
- flake8-string-format
- repo: https://github.com/google/yapf
rev: v0.31.0
hooks:
- id: yapf
args: [-i]
- repo: https://github.com/PyCQA/isort
rev: 5.9.3
hooks:
- id: isort
repo: https://github.com/timothycrosley/isort
rev: 5.6.4
- repo: https://github.com/doublify/pre-commit-clang-format
rev: '6230247'
hooks:
- id: clang-format
files: \.(cc?|cuh?|cxx|cpp|h|hpp|hxx|java|js)$
args: ['-fallback-style=none', '-style={BasedOnStyle: LLVM, ColumnLimit: 99, AllowShortBlocksOnASingleLine: true, AllowShortIfStatementsOnASingleLine: true, AllowShortLoopsOnASingleLine: true}']
4 changes: 2 additions & 2 deletions examples/demo.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -234,9 +234,9 @@
"## Scatter\n",
"\n",
"# One OSEM iteration estimate (implicitly using voxel-driven scatter model)\n",
"eim = nipet.mmrchain(datain, mMRpars, mu_h=mu_h, mu_o=mu_o, itr=1, outpath=opth)['im']\n",
"eim = nipet.mmrchain(datain, mMRpars, mu_h=mu_h, mu_o=mu_o, itr=1, histo=m, outpath=opth)['im']\n",
"# Recalculate scatter\n",
"s = nipet.vsm(datain, (mu_h['im'], mu_o['im']), eim, m, r, mMRpars)\n",
"s = nipet.vsm(datain, (mu_h['im'], mu_o['im']), eim, mMRpars, histo=m, rsino=r)\n",
"print(\"Scatter: %.3g%%\" % (s.sum() / m['psino'].sum() * 100))\n",
"\n",
"## Attenuation, Normalisation & Sensitivity\n",
Expand Down
28 changes: 25 additions & 3 deletions niftypet/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.18 FATAL_ERROR)
if("${NIPET_BUILD_VERSION}" STREQUAL "")
set(NIPET_BUILD_VERSION 2 CACHE STRING "version" FORCE)
set(NIPET_BUILD_VERSION 2 CACHE STRING "version" FORCE)
endif()
project(nipet LANGUAGES C CXX CUDA VERSION "${NIPET_BUILD_VERSION}")

Expand All @@ -9,17 +9,39 @@ cmake_policy(SET CMP0074 NEW) # <PackageName>_ROOT hints for find_package
cmake_policy(SET CMP0104 NEW) # CMAKE_CUDA_ARCHITECTURES
find_package(Python3 COMPONENTS Interpreter Development NumPy REQUIRED)
find_package(CUDAToolkit REQUIRED)
execute_process(
COMMAND "${Python3_EXECUTABLE}" -c "import cuvec; print(cuvec.include_path)"
OUTPUT_VARIABLE CUVEC_INCLUDE_DIRS
OUTPUT_STRIP_TRAILING_WHITESPACE)
if("${CUVEC_INCLUDE_DIRS}" STREQUAL "")
message(WARNING "Could not find cuvec includes")
else()
message(STATUS "Found cuvec includes: ${CUVEC_INCLUDE_DIRS}")
endif()
if(SKBUILD)
find_package(PythonExtensions REQUIRED)
find_package(PythonExtensions REQUIRED)
set(LIB_TYPE "MODULE")
else()
set(LIB_TYPE "SHARED")
endif()
cmake_policy(POP)

message(STATUS "CUDA architectures: ${CMAKE_CUDA_ARCHITECTURES}")
if("${CMAKE_BUILD_TYPE}" STREQUAL "")
set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type" FORCE)
set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type" FORCE)
endif()
message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")

option(CUVEC_DEBUG "Print out CUDA malloc & free operations" OFF)
if(CUVEC_DEBUG)
add_compile_definitions(CUVEC_DEBUG)
endif(CUVEC_DEBUG)
message(STATUS "cuvec debugging: ${CUVEC_DEBUG}")
if("${NIPET_CU_THREADS}" STREQUAL "")
set(NIPET_CU_THREADS 1024 CACHE STRING
"Maximum number of CUDA threads per block (should be less than cudaDeviceProp::maxThreadsDim)" FORCE)
endif()
add_compile_definitions(NIPET_CU_THREADS=${NIPET_CU_THREADS})
add_subdirectory(nipet)

include(CMakePackageConfigHelpers)
Expand Down
2 changes: 1 addition & 1 deletion niftypet/nipet/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ add_library(NiftyPET::${PROJECT_NAME} ALIAS ${PROJECT_NAME})
target_include_directories(${PROJECT_NAME} PUBLIC
"$<BUILD_INTERFACE:${${CMAKE_PROJECT_NAME}_INCLUDE_DIRS}>"
"$<INSTALL_INTERFACE:niftypet/${CMAKE_PROJECT_NAME}/include>")
target_link_libraries(${PROJECT_NAME} ${Python3_LIBRARIES} ${CUDA_LIBRARIES})
target_link_libraries(${PROJECT_NAME} ${Python3_LIBRARIES} CUDA::cudart_static)

if(SKBUILD)
python_extension_module(${PROJECT_NAME})
Expand Down
Loading

0 comments on commit b1c3799

Please sign in to comment.