From 142f8281a674e82e623891e6baf64d2f3220792f Mon Sep 17 00:00:00 2001 From: sarthakpati Date: Wed, 28 May 2025 15:56:41 -0400 Subject: [PATCH 1/5] Update Python package workflow and dependencies - Upgrade actions/checkout to v4 - Set Python version to 3.12 - Update numpy requirement to version 1.19.2 or higher - Increment package version to 1.0.15 - Adjust python_requires to >=3.9 - Add support for Python 3.11 and 3.12 in classifiers --- .github/workflows/publish-on-pypi.yml | 6 +++--- setup.py | 11 +++++++---- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/.github/workflows/publish-on-pypi.yml b/.github/workflows/publish-on-pypi.yml index 81a25d1..e5bef32 100644 --- a/.github/workflows/publish-on-pypi.yml +++ b/.github/workflows/publish-on-pypi.yml @@ -22,11 +22,11 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Python uses: actions/setup-python@v4 with: - python-version: '3.8' + python-version: '3.12' # This second step is unnecessary but highly recommended because # It will cache database and saves time re-downloading it if database isn't stale. - name: Cache pip @@ -45,7 +45,7 @@ jobs: - name: Build package run: python -m build - name: Publish package - uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29 + uses: pypa/gh-action-pypi-publish@master with: user: __token__ password: ${{ secrets.PYPI_API_TOKEN }} diff --git a/setup.py b/setup.py index 514f380..7756a89 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ readme = readme_file.read() requirements = [ - "numpy", + "numpy>=1.19.2", "SimpleITK!=2.0.*", "SimpleITK!=2.2.1", # https://github.com/mlcommons/GaNDLF/issues/536 "setuptools", @@ -16,14 +16,16 @@ "twine", "keyring", "black", + "psutil", + "requests", ] setup( name="LabelFusion", - version="1.0.14", # dev: development release; this should be changed when tagging + version="1.0.15", # dev: development release; this should be changed when tagging author="Megh Bhalerao, Sarthak Pati", author_email="admin@fets.ai", - python_requires=">=3.8", + python_requires=">=3.9", packages=find_packages(), scripts=["fusion_run"], classifiers=[ @@ -32,9 +34,10 @@ "License :: OSI Approved :: Apache Software License", "Natural Language :: English", "Operating System :: OS Independent", - "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", ], description=("Label fusion strategies for multi-class labels."), url="https://github.com/FETS-AI/LabelFusion", From 776ce911b86a6e9abb2324b6a07d5eca2c238bbd Mon Sep 17 00:00:00 2001 From: sarthakpati Date: Wed, 28 May 2025 15:57:20 -0400 Subject: [PATCH 2/5] Update copyright contact email in fusion_run script --- fusion_run | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fusion_run b/fusion_run index 3a35ca5..142ad96 100644 --- a/fusion_run +++ b/fusion_run @@ -13,7 +13,7 @@ from LabelFusion.utils import * from LabelFusion.wrapper import * def main(): - copyrightMessage = 'Contact: software@cbica.upenn.edu\n\n' + 'This program is NOT FDA/CE approved and NOT intended for clinical use.\nCopyright (c) ' + str(date.today().year) + ' University of Pennsylvania. All rights reserved.' + copyrightMessage = 'Contact: admin@fets.ai\n\n' + 'This program is NOT FDA/CE approved and NOT intended for clinical use.\nCopyright (c) ' + str(date.today().year) + ' University of Pennsylvania. All rights reserved.' parser = argparse.ArgumentParser(prog='LabelFusion', formatter_class=argparse.RawTextHelpFormatter, description = "Fusion of different labels together.\n\n" + copyrightMessage) parser.add_argument('-inputs', type=str, help = 'The absolute, comma-separated paths of labels that need to be fused', required=True) parser.add_argument('-classes', type=str, help = 'The expected labels; for example, for BraTS, this should be \'0,1,2,4\'; this is not needed for STAPLE|ITKVoting', default='0,1') From dc124ea7b18c595096d6e0e4288d3d08d84f38f3 Mon Sep 17 00:00:00 2001 From: sarthakpati Date: Wed, 28 May 2025 16:02:07 -0400 Subject: [PATCH 3/5] Add GitHub Actions workflow for testing and dependency installation --- .azure-pipelines/steps.yml | 31 -------------------- .github/workflows/test.yml | 58 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+), 31 deletions(-) delete mode 100644 .azure-pipelines/steps.yml create mode 100644 .github/workflows/test.yml diff --git a/.azure-pipelines/steps.yml b/.azure-pipelines/steps.yml deleted file mode 100644 index 6180808..0000000 --- a/.azure-pipelines/steps.yml +++ /dev/null @@ -1,31 +0,0 @@ -steps: -- script: | - conda create -n venv_fusion python=3.6.5 -y - source activate venv_fusion - pip install -e . - displayName: 'Install dependencies' - -- script: | - source activate venv_fusion - python fusion_run -inputs ./data/unet.nii.gz,./data/resunet.nii.gz -output ./data/test_staple.nii.gz -classes 0,1,2,4 -method staple - python -c "from LabelFusion.itkUtils import *; sys.exit('fail') if(not (imageComparision('./data/baseline_staple.nii.gz', './data/test_staple.nii.gz'))) else print('pass')" - displayName: 'Run through staple' - -- script: | - source activate venv_fusion - python fusion_run -inputs ./data/unet.nii.gz,./data/resunet.nii.gz -output ./data/test_itkvoting.nii.gz -classes 0,1,2,4 -method itkvoting - python -c "from LabelFusion.itkUtils import *; sys.exit('fail') if(not (imageComparision('./data/baseline_itkvoting.nii.gz', './data/test_itkvoting.nii.gz'))) else print('pass')" - displayName: 'Run through itkvoting' - -- script: | - source activate venv_fusion - python fusion_run -inputs ./data/unet.nii.gz,./data/resunet.nii.gz -output ./data/test_majorityvoting.nii.gz -classes 0,1,2,4 -method majorityvoting - python -c "from LabelFusion.itkUtils import *; sys.exit('fail') if(not (imageComparision('./data/baseline_majorityvoting.nii.gz', './data/test_majorityvoting.nii.gz'))) else print('pass')" - displayName: 'Run through majorityvoting' - -- script: | - source activate venv_fusion - python fusion_run -inputs ./data/unet.nii.gz,./data/resunet.nii.gz -output ./data/test_simple.nii.gz -classes 0,1,2,4 -method simple - python -c "from LabelFusion.itkUtils import *; sys.exit('fail') if(not (imageComparision('./data/baseline_simple.nii.gz', './data/test_simple.nii.gz'))) else print('pass')" - displayName: 'Run through simple' - \ No newline at end of file diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..b4ed51f --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,58 @@ +# This workflow will install Python dependencies, run tests and lint with a variety of Python versions +# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions + +name: Build & Tests + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + build: + + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + python-version: ["3.9", "3.10", "3.11", "3.12"] + + steps: + - 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: | + python -m pip install --upgrade pip + python -m pip install flake8 pytest build wheel coverage pytest-cov + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + pip install -e . + - name: Run through staple + run: | + python fusion_run -inputs ./data/unet.nii.gz,./data/resunet.nii.gz -output ./data/test_staple.nii.gz -classes 0,1,2,4 -method staple + python -c "from LabelFusion.itkUtils import *; sys.exit('fail') if(not (imageComparision('./data/baseline_staple.nii.gz', './data/test_staple.nii.gz'))) else print('pass')" + - name: Run through itkvoting + run: | + python fusion_run -inputs ./data/unet.nii.gz,./data/resunet.nii.gz -output ./data/test_itkvoting.nii.gz -classes 0,1,2,4 -method itkvoting + python -c "from LabelFusion.itkUtils import *; sys.exit('fail') if(not (imageComparision('./data/baseline_itkvoting.nii.gz', './data/test_itkvoting.nii.gz'))) else print('pass')" + - name: Run through majorityvoting + run: | + python fusion_run -inputs ./data/unet.nii.gz,./data/resunet.nii.gz -output ./data/test_majorityvoting.nii.gz -classes 0,1,2,4 -method majorityvoting + python -c "from LabelFusion.itkUtils import *; sys.exit('fail') if(not (imageComparision('./data/baseline_majorityvoting.nii.gz', './data/test_majorityvoting.nii.gz'))) else print('pass')" + - name: Run through simple + run: | + python fusion_run -inputs ./data/unet.nii.gz,./data/resunet.nii.gz -output ./data/test_simple.nii.gz -classes 0,1,2,4 -method simple + python -c "from LabelFusion.itkUtils import *; sys.exit('fail') if(not (imageComparision('./data/baseline_simple.nii.gz', './data/test_simple.nii.gz'))) else print('pass')" + + - name: Build distributions + run: python setup.py sdist + + - name: Publish package to PyPI + if: github.repository == 'CBICA/FigureGenerator' && github.event_name == 'push' && startsWith(github.ref, 'refs/tags') + uses: pypa/gh-action-pypi-publish@master + with: + user: __token__ + password: ${{ secrets.pypi_password }} From 8a54b7649a9078d1a4f22c8b3ad35767b03f4bcb Mon Sep 17 00:00:00 2001 From: sarthakpati Date: Wed, 28 May 2025 16:04:20 -0400 Subject: [PATCH 4/5] Update dependency installation in workflows to use 'uv' for pip commands --- .github/workflows/publish-on-pypi.yml | 6 +++--- .github/workflows/test.yml | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/publish-on-pypi.yml b/.github/workflows/publish-on-pypi.yml index e5bef32..1dcec39 100644 --- a/.github/workflows/publish-on-pypi.yml +++ b/.github/workflows/publish-on-pypi.yml @@ -39,9 +39,9 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install scikit-build - pip install -e . - pip install build + pip install uv + uv pip install scikit-build build + uv pip install -e . - name: Build package run: python -m build - name: Publish package diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b4ed51f..541c915 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -27,9 +27,9 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - python -m pip install flake8 pytest build wheel coverage pytest-cov - if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - pip install -e . + pip install uv + uv pip install scikit-build build + uv pip install -e . - name: Run through staple run: | python fusion_run -inputs ./data/unet.nii.gz,./data/resunet.nii.gz -output ./data/test_staple.nii.gz -classes 0,1,2,4 -method staple From 5a821570722be58b35ca32a2184fb13d23a69681 Mon Sep 17 00:00:00 2001 From: sarthakpati Date: Wed, 28 May 2025 16:06:20 -0400 Subject: [PATCH 5/5] Update dependency installation in workflows to use '--system' flag for pip commands --- .github/workflows/publish-on-pypi.yml | 4 ++-- .github/workflows/test.yml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/publish-on-pypi.yml b/.github/workflows/publish-on-pypi.yml index 1dcec39..c3ae464 100644 --- a/.github/workflows/publish-on-pypi.yml +++ b/.github/workflows/publish-on-pypi.yml @@ -40,8 +40,8 @@ jobs: run: | python -m pip install --upgrade pip pip install uv - uv pip install scikit-build build - uv pip install -e . + uv pip install scikit-build build --system + uv pip install -e . --system - name: Build package run: python -m build - name: Publish package diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 541c915..cce1cf8 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -28,8 +28,8 @@ jobs: run: | python -m pip install --upgrade pip pip install uv - uv pip install scikit-build build - uv pip install -e . + uv pip install scikit-build build --system + uv pip install -e . --system - name: Run through staple run: | python fusion_run -inputs ./data/unet.nii.gz,./data/resunet.nii.gz -output ./data/test_staple.nii.gz -classes 0,1,2,4 -method staple