Skip to content

Commit

Permalink
added fileformats packages to template resources
Browse files Browse the repository at this point in the history
  • Loading branch information
tclose committed Mar 19, 2024
1 parent 16d53ad commit 788b7dc
Show file tree
Hide file tree
Showing 12 changed files with 346 additions and 17 deletions.
26 changes: 25 additions & 1 deletion nipype2pydra/pkg_gen/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -641,9 +641,33 @@ def copy_ignore(_, names):
gh_workflows_dir / "ci-cd.yaml",
)

related_pkgs_dir = pkg_dir / "related-packages"
shutil.copytree(TEMPLATES_DIR / "related-packages", related_pkgs_dir)

# Add modified README
os.unlink(pkg_dir / "README.md")
shutil.copy(TEMPLATES_DIR / "README.rst", pkg_dir / "README.rst")
with open(TEMPLATES_DIR / "README.rst") as f:
readme_rst = f.read()
readme_rst = readme_rst.replace("=" * 31, "=" * (23 + len(pkg)))
with open(pkg_dir / "README.rst", "w") as f:
f.write(readme_rst)

fileformat_readme_path = related_pkgs_dir / "fileformats" / "README.rst"
with open(fileformat_readme_path) as f:
ff_readme_rst = f.read()
ff_readme_rst = ff_readme_rst.replace("=" * 29, "=" * (27 + len(pkg)))
with open(fileformat_readme_path, "w") as f:
f.write(ff_readme_rst)

fileformat_extras_readme_path = (
related_pkgs_dir / "fileformats-extras" / "README.rst"
)
with open(fileformat_extras_readme_path) as f:
ffe_readme_rst = f.read()
ffe_readme_rst = ffe_readme_rst.replace("=" * 36, "=" * (34 + len(pkg)))
with open(fileformat_extras_readme_path, "w") as f:
f.write(ffe_readme_rst)

with open(pkg_dir / "pyproject.toml") as f:
pyproject_toml = f.read()
pyproject_toml = pyproject_toml.replace("README.md", "README.rst")
Expand Down
13 changes: 11 additions & 2 deletions nipype2pydra/pkg_gen/resources/templates/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,22 @@ Contributing to this package
Developer installation
~~~~~~~~~~~~~~~~~~~~~~

Install the `fileformats <https://arcanaframework.github.io/fileformats/>`__ packages
corresponding to AFNI specific file formats


.. code-block::
$ pip install -e ./related-packages/fileformats[dev]
$ pip install -e ./related-packages/fileformats-extras[dev]
Install repo in developer mode from the source directory and install pre-commit to
ensure consistent code-style and quality.

.. code-block::
$ pip install -e .[test,dev]
$ pre-commit install
$ pre-commit install
Next install the requirements for running the auto-conversion script and generate the
Pydra task interfaces from their Nipype counterparts
Expand All @@ -93,7 +101,8 @@ The run the conversion script to convert Nipype interfaces to Pydra
$ nipype-auto-conv/generate
## Methodology
Methodology
~~~~~~~~~~~

The development of this package is expected to have two phases

Expand Down
28 changes: 14 additions & 14 deletions nipype2pydra/pkg_gen/resources/templates/gh_workflows/ci-cd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Revert version to most recent tag on upstream update
if: github.event_name == 'repository_dispatch'
run: git checkout $(git tag -l | tail -n 1 | awk -F post '{print $1}')
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
- name: Install build dependencies
run: python -m pip install --upgrade pip
- name: Install requirements
Expand All @@ -50,7 +50,7 @@ jobs:
- '--editable git+https://github.com/nipype/pydra.git#egg=pydra'
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Revert version to most recent tag on upstream update
if: github.event_name == 'repository_dispatch'
run: git checkout $(git tag -l | tail -n 1 | awk -F post '{print $1}')
Expand All @@ -63,7 +63,7 @@ jobs:
run: |
sed -i '/\/pydra\/tasks\/CHANGEME\/auto/d' .gitignore
- 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
Expand All @@ -90,12 +90,12 @@ jobs:
matrix:
python-version: ['3.8', '3.11']
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Revert version to most recent tag on upstream update
if: github.event_name == 'repository_dispatch'
run: git checkout $(git tag -l | tail -n 1 | awk -F post '{print $1}')
- 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
Expand Down Expand Up @@ -149,7 +149,7 @@ jobs:
source $FREESURFER_HOME/SetUpFreeSurfer.sh
echo $FREESURFER_LICENCE > $FREESURFER_HOME/license.txt
export PATH=$FREESURFER_HOME/bin:$PATH
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Revert version to most recent tag on upstream update
if: github.event_name == 'repository_dispatch'
run: git checkout $(git tag -l | tail -n 1 | awk -F post '{print $1}')
Expand All @@ -162,7 +162,7 @@ jobs:
run: |
sed -i '/\/src\/pydra\/tasks\/CHANGEME\/auto/d' .gitignore
- 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
Expand All @@ -187,12 +187,12 @@ jobs:
needs: [devcheck, test]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install build tools
Expand All @@ -219,12 +219,12 @@ jobs:
needs: [deploy-fileformats]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install build tools
Expand All @@ -251,7 +251,7 @@ jobs:
needs: [deploy-fileformats-extras]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
Expand All @@ -270,7 +270,7 @@ jobs:
git commit -am"added auto-generated version to make new tag for package version"
git tag ${TAG}post${POST}
- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install build tools
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
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)
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
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.
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
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 <https://github.com/nipype/pydra-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 <http://creativecommons.org/licenses/by/4.0/>`_

.. 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
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from ._version import __version__
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
[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 = "[email protected]"},
]
maintainers = [
{name = "Thomas G. Close", email = "[email protected]"},
]
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']
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
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.
Loading

0 comments on commit 788b7dc

Please sign in to comment.