The intent of this repository is to help you get started with creating Pydra tasks.
All tasks will be inserted into the pydra.tasks.<yourtaskpackagename>
namespace.
- Click on new repo.
- Select this template from the repository template drop down list.
- Give your repo a name.
- Once the repo is created and cloned, search for TODO (
grep -rn TODO .
) and replace with appropriate name. - One of the folders is called TODO. This should also be renamed to your package name.
- Add tasks to the
pydra/tasks/<yourpackagename>
folder. - An example subpackage is found in
pydra/tasks/<yourpackagename>/utils
. You may wish to add tools to it or delete it. - You may want to initialize a Sphinx docs directory.
- Review the workflow in
.github/workflows/pythonpackage.yml
. Testing editable installations is probably not useful unless you are reconfiguring namespace packages. - Update this README after creating the new repository.
The setuptools_scm tool allows for versioning based on the most recent git tag. The release process can thus be:
git tag -a 1.0.0
python -m build
twine upload dist/*
Note that uploading to PyPI is done via 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
string. See setuptools_scm
documentation for alternative configurations.
Namespace packages allow multiple packages to be installed in such a way that they can be
imported from a common namespace. In this case, the base namespace is pydra.tasks
, and each
task package installs a new module, such as pydra.tasks.afni
.
To do correctly, task packages must not interfere with files higher in the hierarchy.
This includes adding __init__.py
files in either pydra
or pydra/tasks
.
This package comes with a default set of test modules, and we encourage users to use pytest. Tests can be discovered and run using:
pytest --doctest-modules pydra/tasks/*
This template uses GitHub Actions to run tests. To simulate several plausible development or installation environments, we test over all Python versions supported by Pydra, and install Pydra and the current package in both standard and editable modes.
The combination of standard/editable is in particular designed to ensure that namespace packaging does not break. We strongly recommend keeping these tests in place for this reason, as one non-compliant package can potentially affect Pydra or other task packages.
In addition to verifying installations do not break or conflict, pytest is run on the package,
including all tests found in test/
directories and doctests.
Finally, packages are built and uploaded as artifacts for inspection. When a tag is pushed, the packages are uploaded to PyPI if a valid API token is placed in the repository secrets.
This template repository is periodically updated as we establish and best practices for task packages. We welcome contributions from the community to help set a solid baseline for all task packages.
Install repo in developer mode from the source directory. It is also useful to install pre-commit to take care of styling via black:
pip install -e .[dev]
pre-commit install