Skip to content

Commit

Permalink
Merge pull request #35 from nipype/src-dir
Browse files Browse the repository at this point in the history
Adds fileformats sub-packages and refactors pyproject and github actions
  • Loading branch information
tclose authored Mar 16, 2024
2 parents 34a9a7b + ff5b628 commit e364a8f
Show file tree
Hide file tree
Showing 14 changed files with 329 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# For deployment, it will be necessary to create a PyPI API token and store it as a secret
# https://docs.github.com/en/actions/reference/encrypted-secrets

name: Python package
name: CI/CD

on:
push:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ __pycache__/
.Python
build/
develop-eggs/
_version.py
dist/
downloads/
eggs/
Expand Down
16 changes: 9 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,18 @@ All tasks will be inserted into the `pydra.tasks.<yourtaskpackagename>` namespac
1. Give your repo a name.
1. Once the repo is created and cloned, search for CHANGEME (`grep -rn CHANGEME . `) and
replace with appropriate name.
1. One of the folders is called CHANGEME. This should also be renamed to your package
name.
1. Rename the following folders to replace `CHANGEME` with the name of the package:
* `src/pydra/tasks/CHANGEME`
* `fileformats/fileformats/medimage_CHANGEME`
* `fileformats/fileformats/extras/medimage_CHANGEME`
1. Under the newly renamed package (i.e. formerly CHANGEME) there is a directory named "v1",
`pydra/tasks/<package-name>/v1`, change this to valid Python package name starting with
`src/pydra/tasks/<package-name>/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 `pydra/tasks/fsl/v6` or `pydra/tasks/fsl/v6_0` depending on
e.g. FSL v6.0.2 could be `src/pydra/tasks/fsl/v6` or `src/pydra/tasks/fsl/v6_0` depending on
how stable the CLI of the tool is between minor versions.
1. Edit `pydra/tasks/<package-name>/latest.py` to update references to `v1` to the
1. Edit `src/pydra/tasks/<package-name>/latest.py` to update references to `v1` to the
tool target version
1. Add tasks to the `pydra/tasks/<package-name>/v<package-version>` folder.
1. Add tasks to the `src/pydra/tasks/<package-name>/v<package-version>` 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.
Expand All @@ -40,7 +42,7 @@ python -m build
twine upload dist/*
```

Note that uploading to PyPI is done via [Continuous integration](#continuous-integration)) when
Note that uploading to PyPI is done via [Continuous integration](#continuous-integration) when
a tag is pushed to the repository, so only the first step needs to be donne manually.

Note also that we assume tags will be version numbers and not be prefixed with `v` or some other
Expand Down
7 changes: 5 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,17 @@ requires = ["hatchling", "hatch-vcs"]
build-backend = "hatchling.build"

[project]
name = "pydra-tasks-CHANGEME"
name = "pydra-CHANGEME"
description = "Pydra tasks package for CHANGEME"
readme = "README.md"
requires-python = ">=3.8"
dependencies = [
"pydra >=0.22",
"fileformats >=0.8.3",
"fileformats-datascience >=0.1",
"fileformats-medimage >=0.4.1"]
"fileformats-medimage >=0.4.1",
"fileformats-medimage-CHANGEME"
]
license = {file = "LICENSE"}
authors = [{name = "Nipype developers", email = "[email protected]"}]
maintainers = [{name = "Nipype developers", email = "[email protected]"}]
Expand Down Expand Up @@ -51,6 +53,7 @@ test = [
"fileformats-extras",
"fileformats-datascience-extras",
"fileformats-medimage-extras",
"fileformats-medimage-CHANGEME-extras"
]

[tool.hatch.version]
Expand Down
37 changes: 37 additions & 0 deletions related-packages/conftest.py
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)
13 changes: 13 additions & 0 deletions related-packages/fileformats-extras/LICENSE
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.
29 changes: 29 additions & 0 deletions related-packages/fileformats-extras/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
FileFormats-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 <https://github.com/nipype/pydra-freesurfer/>`__
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...


Quick Installation
------------------

This extension can be installed for Python 3 using *pip*::

$ pip3 install fileformats-CHANGEME-extras

This will install the core package and any other dependencies

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__
87 changes: 87 additions & 0 deletions related-packages/fileformats-extras/pyproject.toml
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']
13 changes: 13 additions & 0 deletions related-packages/fileformats/LICENSE
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.
39 changes: 39 additions & 0 deletions related-packages/fileformats/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
How to customise this template
==============================

#. 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 <https://github.com/ArcanaFramework/fileformats-core>`__ package


Quick Installation
------------------

This extension can be installed for Python 3 using *pip*::

$ pip3 install fileformats-CHANGEME

This will install the core package and any other dependencies

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__
84 changes: 84 additions & 0 deletions related-packages/fileformats/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
[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 = "[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",
"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']
Loading

0 comments on commit e364a8f

Please sign in to comment.