From e238ad3d139e7ed717b323b7f5052c8eb6a0be5a Mon Sep 17 00:00:00 2001 From: Tom Close Date: Tue, 19 Mar 2024 18:50:27 +1100 Subject: [PATCH 1/8] added _version.py to generated files --- .gitignore | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index de08422..dd54be1 100644 --- a/.gitignore +++ b/.gitignore @@ -10,7 +10,6 @@ __pycache__/ .Python build/ develop-eggs/ -_version.py dist/ downloads/ eggs/ @@ -140,3 +139,8 @@ dmypy.json # Mac garbarge .DS_store + +# Generated files +/pydra/tasks/CHANGEME/_version.py +/related-packages/fileformats/fileformats/medimage_CHANGEME/_version.py +/related-packages/fileformats-extras/fileformats/extras/medimage_CHANGEME/_version.py \ No newline at end of file From d239e755c783486fe1a6e402ea6daa1a70375a14 Mon Sep 17 00:00:00 2001 From: Tom Close Date: Wed, 20 Mar 2024 07:47:51 +1100 Subject: [PATCH 2/8] updated actions --- .github/workflows/ci-cd.yaml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci-cd.yaml b/.github/workflows/ci-cd.yaml index 2a7da3b..7b1545e 100644 --- a/.github/workflows/ci-cd.yaml +++ b/.github/workflows/ci-cd.yaml @@ -25,9 +25,9 @@ jobs: - '--editable git+https://github.com/nipype/pydra.git#egg=pydra' steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Install build dependencies @@ -50,9 +50,9 @@ jobs: python-version: [3.7, 3.8, 3.9, '3.10'] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Install build dependencies @@ -78,12 +78,12 @@ jobs: matrix: python-version: [3.9] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: submodules: recursive fetch-depth: 0 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Install build tools From 7d0a621be95ccf0f37e889c15f633e7f245a562e Mon Sep 17 00:00:00 2001 From: Tom Close Date: Wed, 20 Mar 2024 07:48:07 +1100 Subject: [PATCH 3/8] edited readme --- .github/workflows/fileformats-ci-cd.yaml | 132 ------------------ .../fileformats-extras/README.rst | 15 +- related-packages/fileformats/README.rst | 23 +-- 3 files changed, 15 insertions(+), 155 deletions(-) delete mode 100644 .github/workflows/fileformats-ci-cd.yaml diff --git a/.github/workflows/fileformats-ci-cd.yaml b/.github/workflows/fileformats-ci-cd.yaml deleted file mode 100644 index 58b80a8..0000000 --- a/.github/workflows/fileformats-ci-cd.yaml +++ /dev/null @@ -1,132 +0,0 @@ -name: CI/CD - -on: - push: - branches: [ main, develop ] - pull_request: - branches: [ main, develop ] - release: - types: [published] - -defaults: - run: - shell: bash - -jobs: - test: - strategy: - matrix: - os: [ubuntu-latest] - python-version: ["3.8", "3.12"] - fail-fast: false - runs-on: ${{ matrix.os }} - defaults: - run: - shell: bash -l {0} - steps: - - name: Checkout - uses: actions/checkout@v2 - - name: Unset header - # checkout@v2 adds a header that makes branch protection report errors - # because the Github action bot is not a collaborator on the repo - run: git config --local --unset http.https://github.com/.extraheader - - name: Fetch tags - run: git fetch --prune --unshallow - - name: Disable etelemetry - run: echo "NO_ET=TRUE" >> $GITHUB_ENV - - name: Set up Python ${{ matrix.python-version }} on ${{ matrix.os }} - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.python-version }} - - name: Update build tools - run: python3 -m pip install --upgrade pip - - name: Install Package - run: python3 -m pip install -e related-packages/fileformats[test] -e related-packages/fileformats-extras[test] - - name: Pytest - run: pytest -vvs --cov fileformats.medimage_CHANGEME --cov-config .coveragerc --cov-report xml . - - name: Upload coverage to Codecov - uses: codecov/codecov-action@v2 - with: - fail_ci_if_error: true - token: ${{ secrets.CODECOV_TOKEN }} - - build: - needs: [test] - runs-on: ubuntu-latest - strategy: - matrix: - pkg: - - ["main", "related-packages/fileformats"] - - ["extras", "related-packages/fileformats-extras"] - steps: - - uses: actions/checkout@v3 - with: - submodules: recursive - fetch-depth: 0 - - name: Unset header - # checkout@v2 adds a header that makes branch protection report errors - # because the Github action bot is not a collaborator on the repo - run: git config --local --unset http.https://github.com/.extraheader - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: '3.12' - - name: Install build tools - run: python3 -m pip install build twine - - name: Build source and wheel distributions - run: python3 -m build ${{ matrix.pkg[1] }} - - name: Check distributions - run: twine check ${{ matrix.pkg[1] }}/dist/* - - uses: actions/upload-artifact@v3 - with: - name: built-${{ matrix.pkg[0] }} - path: ${{ matrix.pkg[1] }}/dist - - deploy: - needs: [build] - runs-on: ubuntu-latest - steps: - - name: Download build - uses: actions/download-artifact@v3 - with: - name: built-main - path: dist - - name: Check for PyPI token on tag - id: deployable - if: github.event_name == 'release' - env: - PYPI_API_TOKEN: "${{ secrets.FILEFORMATS_PYPI_API_TOKEN }}" - run: if [ -n "$PYPI_API_TOKEN" ]; then echo "DEPLOY=true" >> $GITHUB_OUTPUT; fi - - name: Upload to PyPI - if: steps.deployable.outputs.DEPLOY - uses: pypa/gh-action-pypi-publish@release/v1 - with: - user: __token__ - password: ${{ secrets.FILEFORMATS_PYPI_API_TOKEN }} - - deploy-extras: - needs: [build, deploy] - runs-on: ubuntu-latest - steps: - - name: Download build - uses: actions/download-artifact@v3 - with: - name: built-extras - path: dist - - name: Check for PyPI token on tag - id: deployable - if: github.event_name == 'release' - env: - EXTRAS_PYPI_API_TOKEN: "${{ secrets.FILEFORMATS_EXTRAS_PYPI_API_TOKEN }}" - run: if [ -n "$EXTRAS_PYPI_API_TOKEN" ]; then echo "DEPLOY=true" >> $GITHUB_OUTPUT; fi - - name: Upload to PyPI - if: steps.deployable.outputs.DEPLOY - uses: pypa/gh-action-pypi-publish@release/v1 - with: - user: __token__ - password: ${{ secrets.FILEFORMATS_EXTRAS_PYPI_API_TOKEN }} - -# Deploy on tags if PYPI_API_TOKEN is defined in the repository secrets. -# Secrets are not accessible in the if: condition [0], so set an output variable [1] -# [0] https://github.community/t/16928 -# [1] https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-output-parameter diff --git a/related-packages/fileformats-extras/README.rst b/related-packages/fileformats-extras/README.rst index 4e12d62..4aa206c 100644 --- a/related-packages/fileformats-extras/README.rst +++ b/related-packages/fileformats-extras/README.rst @@ -1,12 +1,14 @@ -FileFormats-CHANGEME Extras -====================================== +FileFormats-medimage-CHANGEME Extras +==================================== + .. image:: https://github.com/nipype/pydra-freesurfer/actions/workflows/ci-cd.yaml/badge.svg :target: https://github.com/nipype/pydra-freesurfer/actions/workflows/ci-cd.yaml -This is a extras module for the `fileformats-CHANGEME `__ +This is a extras module for the `fileformats-medimage-CHANGEME `__ fileformats extension package, which provides additional functionality to format classes (i.e. aside -from basic identification and validation), such as conversion tools, metadata parsers, test data generators, etc... +from basic identification and validation), such as conversion tools, metadata parsers, +sample data generators, etc... Quick Installation @@ -14,9 +16,10 @@ Quick Installation This extension can be installed for Python 3 using *pip*:: - $ pip3 install fileformats-CHANGEME-extras + $ pip3 install fileformats-medimage-CHANGEME-extras -This will install the core package and any other dependencies +This will install the package, base packages, and any other dependencies required to +implement the extra functionality. License ------- diff --git a/related-packages/fileformats/README.rst b/related-packages/fileformats/README.rst index 8e4c9b2..1d07e92 100644 --- a/related-packages/fileformats/README.rst +++ b/related-packages/fileformats/README.rst @@ -1,22 +1,11 @@ -How to customise this template -============================== +FileFormats-medimage-CHANGEME +============================= -#. Rename the `related-packages/fileformats/CHANGEME` directory to the name of the fileformats subpackage (e.g. `medimage_fsl`) -#. Search and replace "CHANGEME" with the name of the fileformats subpackage the extras are to be added -#. Replace name + email placeholders in `pyproject.toml` for developers and maintainers -#. Add the extension file-format classes -#. Ensure that all the extension file-format classes are imported into the extras package root, i.e. `fileformats/CHANGEME` -#. Delete these instructions - -... - -FileFormats Extension - CHANGEME -==================================== .. image:: https://github.com/nipype/pydra-CHANGEME/actions/workflows/ci-cd.yml/badge.svg :target: https://github.com/nipype/pydra-CHANGEME/actions/workflows/ci-cd.yml -This is the "CHANGEME" extension module for the -`fileformats `__ package +This is an extension module of the `fileformats `__ +package for defining file formats that are specific to the CHANGME software toolkit. Quick Installation @@ -24,9 +13,9 @@ Quick Installation This extension can be installed for Python 3 using *pip*:: - $ pip3 install fileformats-CHANGEME + $ pip3 install fileformats-medimage-CHANGEME -This will install the core package and any other dependencies +This will install the format extensions and dependent base packages. License ------- From c1cfe3bd1b269138ad35f633623d8b064622f7fa Mon Sep 17 00:00:00 2001 From: Tom Close Date: Wed, 20 Mar 2024 08:45:07 +1100 Subject: [PATCH 4/8] dropped fileformats related-packages (will be generated in nipype2pydra) --- README.md | 7 -- related-packages/conftest.py | 37 -------- related-packages/fileformats-extras/LICENSE | 13 --- .../fileformats-extras/README.rst | 32 ------- .../extras/medimage_CHANGEME/__init__.py | 1 - .../fileformats-extras/pyproject.toml | 87 ------------------- related-packages/fileformats/LICENSE | 13 --- related-packages/fileformats/README.rst | 28 ------ .../fileformats/medimage_CHANGEME/__init__.py | 1 - related-packages/fileformats/pyproject.toml | 84 ------------------ 10 files changed, 303 deletions(-) delete mode 100644 related-packages/conftest.py delete mode 100644 related-packages/fileformats-extras/LICENSE delete mode 100644 related-packages/fileformats-extras/README.rst delete mode 100644 related-packages/fileformats-extras/fileformats/extras/medimage_CHANGEME/__init__.py delete mode 100644 related-packages/fileformats-extras/pyproject.toml delete mode 100644 related-packages/fileformats/LICENSE delete mode 100644 related-packages/fileformats/README.rst delete mode 100644 related-packages/fileformats/fileformats/medimage_CHANGEME/__init__.py delete mode 100644 related-packages/fileformats/pyproject.toml diff --git a/README.md b/README.md index e3d17bc..303ac2d 100644 --- a/README.md +++ b/README.md @@ -12,13 +12,6 @@ All tasks will be inserted into the `pydra.tasks.` namespac replace with appropriate name. 1. Rename the namespace package root directory to replace `CHANGEME` with the name of the package: * `src/pydra/tasks/CHANGEME` -1. If you are planning to define [fileformats](https://arcanaframework.github.io/fileformats/) classes specific - to the tools defined in the task package, then rename the base and "extras" packages using a - matching name to the package (if the tool is from in another field other than medical imaging, - also replace the `medimage` part). If you don't need to define and tool-specific fileformats you can delete - these packages and the .github/workflows/fileformats-ci-cd.yaml - * `related-packages/fileformats/fileformats/medimage_CHANGEME` - * `related-packages/fileformats-extras/fileformats/extras/medimage_CHANGEME` 1. Under the newly renamed package (i.e. formerly CHANGEME) there is a directory named "v1", `src/pydra/tasks//v1`, change this to valid Python package name starting with 'v' to indicate the version of the tool the Pydra interfaces will be designed for, diff --git a/related-packages/conftest.py b/related-packages/conftest.py deleted file mode 100644 index 2a703c0..0000000 --- a/related-packages/conftest.py +++ /dev/null @@ -1,37 +0,0 @@ -import os -import logging -from pathlib import Path -import tempfile -import pytest - -# Set DEBUG logging for unittests - -log_level = logging.WARNING - -logger = logging.getLogger("fileformats") -logger.setLevel(log_level) - -sch = logging.StreamHandler() -sch.setLevel(log_level) -formatter = logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s") -sch.setFormatter(formatter) -logger.addHandler(sch) - - -# For debugging in IDE's don't catch raised exceptions and let the IDE -# break at it -if os.getenv("_PYTEST_RAISE", "0") != "0": - - @pytest.hookimpl(tryfirst=True) - def pytest_exception_interact(call): - raise call.excinfo.value - - @pytest.hookimpl(tryfirst=True) - def pytest_internalerror(excinfo): - raise excinfo.value - - -@pytest.fixture -def work_dir(): - work_dir = tempfile.mkdtemp() - return Path(work_dir) diff --git a/related-packages/fileformats-extras/LICENSE b/related-packages/fileformats-extras/LICENSE deleted file mode 100644 index e00bcb3..0000000 --- a/related-packages/fileformats-extras/LICENSE +++ /dev/null @@ -1,13 +0,0 @@ - Copyright 2021 Nipype developers - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/related-packages/fileformats-extras/README.rst b/related-packages/fileformats-extras/README.rst deleted file mode 100644 index 4aa206c..0000000 --- a/related-packages/fileformats-extras/README.rst +++ /dev/null @@ -1,32 +0,0 @@ -FileFormats-medimage-CHANGEME Extras -==================================== - -.. image:: https://github.com/nipype/pydra-freesurfer/actions/workflows/ci-cd.yaml/badge.svg - :target: https://github.com/nipype/pydra-freesurfer/actions/workflows/ci-cd.yaml - - -This is a extras module for the `fileformats-medimage-CHANGEME `__ -fileformats extension package, which provides additional functionality to format classes (i.e. aside -from basic identification and validation), such as conversion tools, metadata parsers, -sample data generators, etc... - - -Quick Installation ------------------- - -This extension can be installed for Python 3 using *pip*:: - - $ pip3 install fileformats-medimage-CHANGEME-extras - -This will install the package, base packages, and any other dependencies required to -implement the extra functionality. - -License -------- - -This work is licensed under a -`Creative Commons Attribution 4.0 International License `_ - -.. image:: https://i.creativecommons.org/l/by/4.0/88x31.png - :target: http://creativecommons.org/licenses/by/4.0/ - :alt: Creative Commons Attribution 4.0 International License diff --git a/related-packages/fileformats-extras/fileformats/extras/medimage_CHANGEME/__init__.py b/related-packages/fileformats-extras/fileformats/extras/medimage_CHANGEME/__init__.py deleted file mode 100644 index 8dee4bf..0000000 --- a/related-packages/fileformats-extras/fileformats/extras/medimage_CHANGEME/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from ._version import __version__ diff --git a/related-packages/fileformats-extras/pyproject.toml b/related-packages/fileformats-extras/pyproject.toml deleted file mode 100644 index fbb1237..0000000 --- a/related-packages/fileformats-extras/pyproject.toml +++ /dev/null @@ -1,87 +0,0 @@ -[build-system] -requires = ["hatchling", "hatch-vcs"] -build-backend = "hatchling.build" - -[project] -name = "fileformats-medimage-CHANGEME-extras" -description = "Extensions to add functionality to tool-specific *fileformats* classes" -readme = "README.rst" -requires-python = ">=3.8" -dependencies = [ - "fileformats", - "fileformats-medimage-CHANGEME", - "pydra >= 0.23.0a" -] -license = {file = "LICENSE"} -authors = [ - {name = "Thomas G. Close", email = "tom.g.close@gmail.com"}, -] -maintainers = [ - {name = "Thomas G. Close", email = "tom.g.close@gmail.com"}, -] -keywords = [ - "file formats", - "data", -] -classifiers = [ - "Development Status :: 3 - Alpha", - "Environment :: Console", - "Intended Audience :: Science/Research", - "License :: OSI Approved :: Apache Software License", - "Operating System :: MacOS :: MacOS X", - "Operating System :: Microsoft :: Windows", - "Operating System :: POSIX :: Linux", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - "Topic :: Scientific/Engineering", -] -dynamic = ["version"] - -[project.optional-dependencies] -dev = [ - "black", - "pre-commit", - "codespell", - "flake8", - "flake8-pyproject", -] -test = [ - "pytest >=6.2.5", - "pytest-env>=0.6.2", - "pytest-cov>=2.12.1", - "codecov", -] - -converters = [ -] - -[project.urls] -repository = "https://github.com/nipype/pydra-CHANGEME" - -[tool.hatch.version] -source = "vcs" -raw-options = { root = "../.." } - -[tool.hatch.build.hooks.vcs] -version-file = "fileformats/extras/medimage_CHANGEME/_version.py" - -[tool.hatch.build.targets.wheel] -packages = ["fileformats"] - -[tool.black] -target-version = ['py38'] -exclude = "fileformats/extras/medimage_CHANGEME/_version.py" - -[tool.codespell] -ignore-words = ".codespell-ignorewords" - -[tool.flake8] -doctests = true -per-file-ignores = [ - "__init__.py:F401" -] -max-line-length = 88 -select = "C,E,F,W,B,B950" -extend-ignore = ['E203', 'E501', 'E129'] diff --git a/related-packages/fileformats/LICENSE b/related-packages/fileformats/LICENSE deleted file mode 100644 index e00bcb3..0000000 --- a/related-packages/fileformats/LICENSE +++ /dev/null @@ -1,13 +0,0 @@ - Copyright 2021 Nipype developers - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/related-packages/fileformats/README.rst b/related-packages/fileformats/README.rst deleted file mode 100644 index 1d07e92..0000000 --- a/related-packages/fileformats/README.rst +++ /dev/null @@ -1,28 +0,0 @@ -FileFormats-medimage-CHANGEME -============================= - -.. image:: https://github.com/nipype/pydra-CHANGEME/actions/workflows/ci-cd.yml/badge.svg - :target: https://github.com/nipype/pydra-CHANGEME/actions/workflows/ci-cd.yml - -This is an extension module of the `fileformats `__ -package for defining file formats that are specific to the CHANGME software toolkit. - - -Quick Installation ------------------- - -This extension can be installed for Python 3 using *pip*:: - - $ pip3 install fileformats-medimage-CHANGEME - -This will install the format extensions and dependent base packages. - -License -------- - -This work is licensed under a -`Creative Commons Attribution 4.0 International License `_ - -.. image:: https://i.creativecommons.org/l/by/4.0/88x31.png - :target: http://creativecommons.org/licenses/by/4.0/ - :alt: Creative Commons Attribution 4.0 International License diff --git a/related-packages/fileformats/fileformats/medimage_CHANGEME/__init__.py b/related-packages/fileformats/fileformats/medimage_CHANGEME/__init__.py deleted file mode 100644 index 8dee4bf..0000000 --- a/related-packages/fileformats/fileformats/medimage_CHANGEME/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from ._version import __version__ diff --git a/related-packages/fileformats/pyproject.toml b/related-packages/fileformats/pyproject.toml deleted file mode 100644 index b070d1f..0000000 --- a/related-packages/fileformats/pyproject.toml +++ /dev/null @@ -1,84 +0,0 @@ -[build-system] -requires = ["hatchling", "hatch-vcs"] -build-backend = "hatchling.build" - -[project] -name = "fileformats-medimage-CHANGEME" -description = "Classes for representing different file formats in Python classes for use in type hinting in data workflows" -readme = "README.rst" -requires-python = ">=3.8" -dependencies = [ - "fileformats", - "fileformats-medimage" -] -license = {file = "LICENSE"} -authors = [ - {name = "Thomas G. Close", email = "tom.g.close@gmail.com"}, -] -maintainers = [ - {name = "Thomas G. Close", email = "tom.g.close@gmail.com"}, -] -keywords = [ - "file formats", - "data", -] -classifiers = [ - "Development Status :: 3 - Alpha", - "Environment :: Console", - "Intended Audience :: Science/Research", - "License :: OSI Approved :: Apache Software License", - "Operating System :: MacOS :: MacOS X", - "Operating System :: Microsoft :: Windows", - "Operating System :: POSIX :: Linux", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - "Topic :: Scientific/Engineering", -] -dynamic = ["version"] - -[project.optional-dependencies] -dev = [ - "black", - "pre-commit", - "codespell", - "flake8", - "flake8-pyproject", -] -test = [ - "pytest >=6.2.5", - "pytest-env>=0.6.2", - "pytest-cov>=2.12.1", - "codecov", - "fileformats-medimage-CHANGME-extras", -] - -[project.urls] -repository = "https://github.com/nipype/pydra-CHANGEME" - -[tool.hatch.version] -source = "vcs" -raw-options = { root = "../.." } - -[tool.hatch.build.hooks.vcs] -version-file = "fileformats/medimage_CHANGEME/_version.py" - -[tool.hatch.build.targets.wheel] -packages = ["fileformats"] - -[tool.black] -target-version = ['py38'] -exclude = "fileformats/medimage_CHANGEME/_version.py" - -[tool.codespell] -ignore-words = ".codespell-ignorewords" - -[tool.flake8] -doctests = true -per-file-ignores = [ - "__init__.py:F401" -] -max-line-length = 88 -select = "C,E,F,W,B,B950" -extend-ignore = ['E203', 'E501', 'E129'] From 9392a5a34bccb62148fc68e433c3fe0d7f408ab6 Mon Sep 17 00:00:00 2001 From: Tom Close Date: Fri, 22 Mar 2024 11:17:19 +1100 Subject: [PATCH 5/8] added tool to increment the tool version supported by the package --- pydra/tasks/CHANGEME/{v1 => v1_0}/__init__.py | 0 tools/increment_tool_version.py | 69 +++++++++++++++++++ tools/rename_template.py | 5 +- tools/requirements.txt | 3 + 4 files changed, 74 insertions(+), 3 deletions(-) rename pydra/tasks/CHANGEME/{v1 => v1_0}/__init__.py (100%) create mode 100755 tools/increment_tool_version.py create mode 100644 tools/requirements.txt diff --git a/pydra/tasks/CHANGEME/v1/__init__.py b/pydra/tasks/CHANGEME/v1_0/__init__.py similarity index 100% rename from pydra/tasks/CHANGEME/v1/__init__.py rename to pydra/tasks/CHANGEME/v1_0/__init__.py diff --git a/tools/increment_tool_version.py b/tools/increment_tool_version.py new file mode 100755 index 0000000..e6d56ed --- /dev/null +++ b/tools/increment_tool_version.py @@ -0,0 +1,69 @@ +#!/usr/bin/env python3 +from pathlib import Path +import inspect +from importlib import import_module +import click +from looseversion import LooseVersion +from pydra.engine.core import TaskBase + + +PKG_DIR = Path(__file__).parent.parent +TASKS_DIR = PKG_DIR / "pydra" / "tasks" / "ants" +VERSION_GRANULARITY = ( + 2 # Number of version parts to include: 1 - major, 2 - minor, 3 - micro +) + + +@click.command( + help="""Increment the latest version or create a new sub-package for interfaces for +a new release of AFNI depending on whether one already exists or not. + +NEW_VERSION the version of AFNI to create a new sub-package for +""" +) +@click.argument("new_version", type=LooseVersion) +def increment_tool_version(new_version: LooseVersion): + + # Get the name of the sub-package, e.g. "v2_5" + new_subpkg_name = "_".join(str(p) for p in new_version.version[:VERSION_GRANULARITY]) # type: ignore + if not new_subpkg_name.startswith("v"): + new_subpkg_name = "v" + new_subpkg_name + sub_pkg_dir = TASKS_DIR / new_subpkg_name + if not sub_pkg_dir.exists(): + + prev_version = sorted( + ( + p.name + for p in TASKS_DIR.iterdir() + if p.is_dir() and p.name.startswith("v") + ), + key=lambda x: LooseVersion(".".join(x.split("_"))).version, + )[-1] + prev_ver_mod = import_module(f"pydra.tasks.ants.{prev_version}") + + mod_attrs = [getattr(prev_ver_mod, a) for a in dir(prev_ver_mod)] + task_classes = [ + a for a in mod_attrs if inspect.isclass(a) and issubclass(a, TaskBase) + ] + + code_str = ( + f"from pydra.tasks.ants import {prev_version}\n" + "from . import _tool_version\n" + ) + + for task_cls in task_classes: + code_str += ( + f"\n\nclass {task_cls.__name__}({prev_version}.{task_cls.__name__}):\n" + " TOOL_VERSION = _tool_version.TOOL_VERSION\n" + ) + + sub_pkg_dir.mkdir(exist_ok=True) + with open(sub_pkg_dir / "__init__.py", "w") as f: + f.write(code_str) + + with open(sub_pkg_dir / "_tool_version.py", "w") as f: + f.write(f'TOOL_VERSION = "{new_version}"\n') + + +if __name__ == "__main__": + increment_tool_version() diff --git a/tools/rename_template.py b/tools/rename_template.py index ef1889c..05055bb 100755 --- a/tools/rename_template.py +++ b/tools/rename_template.py @@ -24,14 +24,14 @@ def load_gitignore(repo): cmd, new_name, *_ = sys.argv -for root, dirs, files in os.walk(PACKAGE_ROOT): +for root_, dirs, files in os.walk(PACKAGE_ROOT): ignore = load_gitignore(PACKAGE_ROOT).search for d in [d for d in dirs if ignore(f"{d}/")]: dirs.remove(d) for f in [f for f in files if ignore(f)]: files.remove(f) - root = Path(root) + root = Path(root_) for src in list(dirs): if "CHANGEME" in src: dst = src.replace("CHANGEME", new_name) @@ -40,7 +40,6 @@ def load_gitignore(repo): dirs.remove(src) dirs.append(dst) for fname in files: - f = root / fname text = Path.read_text(root / fname) if "CHANGEME" in text: print(f"Rewriting: {root / fname}") diff --git a/tools/requirements.txt b/tools/requirements.txt new file mode 100644 index 0000000..3b7ccec --- /dev/null +++ b/tools/requirements.txt @@ -0,0 +1,3 @@ +click >= 8.1.3 +looseversion >= 1.1 +pydra >= 0.23 \ No newline at end of file From f62935cacd458d2dc6c285683f337c7d745681eb Mon Sep 17 00:00:00 2001 From: Tom Close Date: Mon, 25 Mar 2024 12:03:26 +1100 Subject: [PATCH 6/8] updated github artifacts --- .github/workflows/ci-cd.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-cd.yaml b/.github/workflows/ci-cd.yaml index 7b1545e..2f5fd40 100644 --- a/.github/workflows/ci-cd.yaml +++ b/.github/workflows/ci-cd.yaml @@ -92,7 +92,7 @@ jobs: run: python -m build - name: Check distributions run: twine check dist/* - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: name: distributions path: dist/ From 033b7ccdf33b7e1ca9d8e48f7591077f77f9e518 Mon Sep 17 00:00:00 2001 From: Tom Close Date: Sat, 18 May 2024 19:32:01 +1000 Subject: [PATCH 7/8] updated ci-cd github action workflow --- .github/workflows/ci-cd.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci-cd.yaml b/.github/workflows/ci-cd.yaml index 2f5fd40..020c966 100644 --- a/.github/workflows/ci-cd.yaml +++ b/.github/workflows/ci-cd.yaml @@ -8,17 +8,17 @@ name: CI/CD on: push: - branches: [ main ] + branches: [ main, develop ] tags: [ '*' ] pull_request: - branches: [ main ] + branches: [ main, develop ] jobs: devcheck: runs-on: ubuntu-latest strategy: matrix: - python-version: [3.7, '3.10'] # Check oldest and newest versions + python-version: ['3.8', '3.12'] # Check oldest and newest versions pip-flags: ['', '--editable'] pydra: - 'pydra' From 9ed32a0ba841ace4f10a39656e2e56abe172b14c Mon Sep 17 00:00:00 2001 From: Tom Close Date: Mon, 7 Apr 2025 11:06:45 +1000 Subject: [PATCH 8/8] upped pydra dep to 1.0a --- README.md | 10 +++++----- docs/conf.py | 2 +- pyproject.toml | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 303ac2d..7241818 100644 --- a/README.md +++ b/README.md @@ -11,15 +11,15 @@ All tasks will be inserted into the `pydra.tasks.` namespac 1. Once the repo is created and cloned, search for CHANGEME (`grep -rn CHANGEME . `) and replace with appropriate name. 1. Rename the namespace package root directory to replace `CHANGEME` with the name of the package: - * `src/pydra/tasks/CHANGEME` + * `pydra/tasks/CHANGEME` 1. Under the newly renamed package (i.e. formerly CHANGEME) there is a directory named "v1", - `src/pydra/tasks//v1`, change this to valid Python package name starting with + `pydra/tasks//v1`, change this to valid Python package name starting with 'v' to indicate the version of the tool the Pydra interfaces will be designed for, - e.g. FSL v6.0.2 could be `src/pydra/tasks/fsl/v6` or `src/pydra/tasks/fsl/v6_0` depending on + e.g. FSL v6.0.2 could be `pydra/tasks/fsl/v6` or `pydra/tasks/fsl/v6_0` depending on how stable the CLI of the tool is between minor versions. -1. Edit `src/pydra/tasks//latest.py` to update references to `v1` to the +1. Edit `pydra/tasks//latest.py` to update references to `v1` to the tool target version -1. Add tasks to the `src/pydra/tasks//v` folder. +1. Add tasks to the `pydra/tasks//v` folder. 1. You may want to initialize a [Sphinx] docs directory. 1. Review the workflow in `.github/workflows/pythonpackage.yml`. Testing editable installations is probably not useful unless you are reconfiguring namespace packages. diff --git a/docs/conf.py b/docs/conf.py index c8338f4..954c63b 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -17,7 +17,7 @@ # -- Project information ----------------------------------------------------- -project = "pydra-CHANGEME" +project = "pydra-tasks-CHANGEME" copyright = "2020, Xihe Xie" author = "Xihe Xie" diff --git a/pyproject.toml b/pyproject.toml index a5ea6c7..b6b3605 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,13 +3,13 @@ requires = ["hatchling", "hatch-vcs"] build-backend = "hatchling.build" [project] -name = "pydra-CHANGEME" +name = "pydra-tasks-CHANGEME" description = "Pydra tasks package for CHANGEME" readme = "README.md" requires-python = ">=3.8" dependencies = [ - "pydra >=0.22", - "fileformats >=0.8.3", + "pydra >=1.0a", + "fileformats >=0.15.0", "fileformats-datascience >=0.1", "fileformats-medimage >=0.4.1", "fileformats-medimage-CHANGEME"