Skip to content

Commit e364a8f

Browse files
authored
Merge pull request #35 from nipype/src-dir
Adds fileformats sub-packages and refactors pyproject and github actions
2 parents 34a9a7b + ff5b628 commit e364a8f

File tree

14 files changed

+329
-17
lines changed

14 files changed

+329
-17
lines changed

.github/workflows/pythonpackage.yaml renamed to .github/workflows/ci-cd.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# For deployment, it will be necessary to create a PyPI API token and store it as a secret
55
# https://docs.github.com/en/actions/reference/encrypted-secrets
66

7-
name: Python package
7+
name: CI/CD
88

99
on:
1010
push:

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ __pycache__/
1010
.Python
1111
build/
1212
develop-eggs/
13+
_version.py
1314
dist/
1415
downloads/
1516
eggs/

README.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,18 @@ All tasks will be inserted into the `pydra.tasks.<yourtaskpackagename>` namespac
1010
1. Give your repo a name.
1111
1. Once the repo is created and cloned, search for CHANGEME (`grep -rn CHANGEME . `) and
1212
replace with appropriate name.
13-
1. One of the folders is called CHANGEME. This should also be renamed to your package
14-
name.
13+
1. Rename the following folders to replace `CHANGEME` with the name of the package:
14+
* `src/pydra/tasks/CHANGEME`
15+
* `fileformats/fileformats/medimage_CHANGEME`
16+
* `fileformats/fileformats/extras/medimage_CHANGEME`
1517
1. Under the newly renamed package (i.e. formerly CHANGEME) there is a directory named "v1",
16-
`pydra/tasks/<package-name>/v1`, change this to valid Python package name starting with
18+
`src/pydra/tasks/<package-name>/v1`, change this to valid Python package name starting with
1719
'v' to indicate the version of the tool the Pydra interfaces will be designed for,
18-
e.g. FSL v6.0.2 could be `pydra/tasks/fsl/v6` or `pydra/tasks/fsl/v6_0` depending on
20+
e.g. FSL v6.0.2 could be `src/pydra/tasks/fsl/v6` or `src/pydra/tasks/fsl/v6_0` depending on
1921
how stable the CLI of the tool is between minor versions.
20-
1. Edit `pydra/tasks/<package-name>/latest.py` to update references to `v1` to the
22+
1. Edit `src/pydra/tasks/<package-name>/latest.py` to update references to `v1` to the
2123
tool target version
22-
1. Add tasks to the `pydra/tasks/<package-name>/v<package-version>` folder.
24+
1. Add tasks to the `src/pydra/tasks/<package-name>/v<package-version>` folder.
2325
1. You may want to initialize a [Sphinx] docs directory.
2426
1. Review the workflow in `.github/workflows/pythonpackage.yml`. Testing editable installations
2527
is probably not useful unless you are reconfiguring namespace packages.
@@ -40,7 +42,7 @@ python -m build
4042
twine upload dist/*
4143
```
4244

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

4648
Note also that we assume tags will be version numbers and not be prefixed with `v` or some other

pyproject.toml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,17 @@ requires = ["hatchling", "hatch-vcs"]
33
build-backend = "hatchling.build"
44

55
[project]
6-
name = "pydra-tasks-CHANGEME"
6+
name = "pydra-CHANGEME"
77
description = "Pydra tasks package for CHANGEME"
88
readme = "README.md"
99
requires-python = ">=3.8"
1010
dependencies = [
1111
"pydra >=0.22",
1212
"fileformats >=0.8.3",
1313
"fileformats-datascience >=0.1",
14-
"fileformats-medimage >=0.4.1"]
14+
"fileformats-medimage >=0.4.1",
15+
"fileformats-medimage-CHANGEME"
16+
]
1517
license = {file = "LICENSE"}
1618
authors = [{name = "Nipype developers", email = "[email protected]"}]
1719
maintainers = [{name = "Nipype developers", email = "[email protected]"}]
@@ -51,6 +53,7 @@ test = [
5153
"fileformats-extras",
5254
"fileformats-datascience-extras",
5355
"fileformats-medimage-extras",
56+
"fileformats-medimage-CHANGEME-extras"
5457
]
5558

5659
[tool.hatch.version]

related-packages/conftest.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import os
2+
import logging
3+
from pathlib import Path
4+
import tempfile
5+
import pytest
6+
7+
# Set DEBUG logging for unittests
8+
9+
log_level = logging.WARNING
10+
11+
logger = logging.getLogger("fileformats")
12+
logger.setLevel(log_level)
13+
14+
sch = logging.StreamHandler()
15+
sch.setLevel(log_level)
16+
formatter = logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s")
17+
sch.setFormatter(formatter)
18+
logger.addHandler(sch)
19+
20+
21+
# For debugging in IDE's don't catch raised exceptions and let the IDE
22+
# break at it
23+
if os.getenv("_PYTEST_RAISE", "0") != "0":
24+
25+
@pytest.hookimpl(tryfirst=True)
26+
def pytest_exception_interact(call):
27+
raise call.excinfo.value
28+
29+
@pytest.hookimpl(tryfirst=True)
30+
def pytest_internalerror(excinfo):
31+
raise excinfo.value
32+
33+
34+
@pytest.fixture
35+
def work_dir():
36+
work_dir = tempfile.mkdtemp()
37+
return Path(work_dir)
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Copyright 2021 Nipype developers
2+
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
7+
http://www.apache.org/licenses/LICENSE-2.0
8+
9+
Unless required by applicable law or agreed to in writing, software
10+
distributed under the License is distributed on an "AS IS" BASIS,
11+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
See the License for the specific language governing permissions and
13+
limitations under the License.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
FileFormats-CHANGEME Extras
2+
======================================
3+
.. image:: https://github.com/nipype/pydra-freesurfer/actions/workflows/ci-cd.yaml/badge.svg
4+
:target: https://github.com/nipype/pydra-freesurfer/actions/workflows/ci-cd.yaml
5+
6+
7+
This is a extras module for the `fileformats-CHANGEME <https://github.com/nipype/pydra-freesurfer/>`__
8+
fileformats extension package, which provides additional functionality to format classes (i.e. aside
9+
from basic identification and validation), such as conversion tools, metadata parsers, test data generators, etc...
10+
11+
12+
Quick Installation
13+
------------------
14+
15+
This extension can be installed for Python 3 using *pip*::
16+
17+
$ pip3 install fileformats-CHANGEME-extras
18+
19+
This will install the core package and any other dependencies
20+
21+
License
22+
-------
23+
24+
This work is licensed under a
25+
`Creative Commons Attribution 4.0 International License <http://creativecommons.org/licenses/by/4.0/>`_
26+
27+
.. image:: https://i.creativecommons.org/l/by/4.0/88x31.png
28+
:target: http://creativecommons.org/licenses/by/4.0/
29+
:alt: Creative Commons Attribution 4.0 International License
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from ._version import __version__
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
[build-system]
2+
requires = ["hatchling", "hatch-vcs"]
3+
build-backend = "hatchling.build"
4+
5+
[project]
6+
name = "fileformats-medimage-CHANGEME-extras"
7+
description = "Extensions to add functionality to tool-specific *fileformats* classes"
8+
readme = "README.rst"
9+
requires-python = ">=3.8"
10+
dependencies = [
11+
"fileformats",
12+
"fileformats-medimage-CHANGEME",
13+
"pydra >= 0.23.0a"
14+
]
15+
license = {file = "LICENSE"}
16+
authors = [
17+
{name = "Thomas G. Close", email = "[email protected]"},
18+
]
19+
maintainers = [
20+
{name = "Thomas G. Close", email = "[email protected]"},
21+
]
22+
keywords = [
23+
"file formats",
24+
"data",
25+
]
26+
classifiers = [
27+
"Development Status :: 3 - Alpha",
28+
"Environment :: Console",
29+
"Intended Audience :: Science/Research",
30+
"License :: OSI Approved :: Apache Software License",
31+
"Operating System :: MacOS :: MacOS X",
32+
"Operating System :: Microsoft :: Windows",
33+
"Operating System :: POSIX :: Linux",
34+
"Programming Language :: Python :: 3.8",
35+
"Programming Language :: Python :: 3.9",
36+
"Programming Language :: Python :: 3.10",
37+
"Programming Language :: Python :: 3.11",
38+
"Topic :: Scientific/Engineering",
39+
]
40+
dynamic = ["version"]
41+
42+
[project.optional-dependencies]
43+
dev = [
44+
"black",
45+
"pre-commit",
46+
"codespell",
47+
"flake8",
48+
"flake8-pyproject",
49+
]
50+
test = [
51+
"pytest >=6.2.5",
52+
"pytest-env>=0.6.2",
53+
"pytest-cov>=2.12.1",
54+
"codecov",
55+
]
56+
57+
converters = [
58+
]
59+
60+
[project.urls]
61+
repository = "https://github.com/nipype/pydra-CHANGEME"
62+
63+
[tool.hatch.version]
64+
source = "vcs"
65+
raw-options = { root = "../.." }
66+
67+
[tool.hatch.build.hooks.vcs]
68+
version-file = "fileformats/extras/medimage_CHANGEME/_version.py"
69+
70+
[tool.hatch.build.targets.wheel]
71+
packages = ["fileformats"]
72+
73+
[tool.black]
74+
target-version = ['py38']
75+
exclude = "fileformats/extras/medimage_CHANGEME/_version.py"
76+
77+
[tool.codespell]
78+
ignore-words = ".codespell-ignorewords"
79+
80+
[tool.flake8]
81+
doctests = true
82+
per-file-ignores = [
83+
"__init__.py:F401"
84+
]
85+
max-line-length = 88
86+
select = "C,E,F,W,B,B950"
87+
extend-ignore = ['E203', 'E501', 'E129']

related-packages/fileformats/LICENSE

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Copyright 2021 Nipype developers
2+
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
7+
http://www.apache.org/licenses/LICENSE-2.0
8+
9+
Unless required by applicable law or agreed to in writing, software
10+
distributed under the License is distributed on an "AS IS" BASIS,
11+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
See the License for the specific language governing permissions and
13+
limitations under the License.

0 commit comments

Comments
 (0)