Skip to content

Commit 436063c

Browse files
authored
Initial commit
0 parents  commit 436063c

27 files changed

+683
-0
lines changed

.coveragerc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[run]
2+
omit = setup.py

.github/dependabot.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# To get started with Dependabot version updates, you'll need to specify which
2+
# package ecosystems to update and where the package manifests are located.
3+
# Please see the documentation for all configuration options:
4+
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5+
6+
version: 2
7+
updates:
8+
- package-ecosystem: "github-actions" # See documentation for possible values
9+
directory: "/" # Location of package manifests
10+
schedule:
11+
interval: "daily"
12+
- package-ecosystem: "pip"
13+
directory: "/"
14+
schedule:
15+
interval: "daily"

.github/rename_project.sh

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/usr/bin/env bash
2+
while getopts a:n:u:d: flag
3+
do
4+
case "${flag}" in
5+
a) author=${OPTARG};;
6+
n) name=${OPTARG};;
7+
u) urlname=${OPTARG};;
8+
d) description=${OPTARG};;
9+
esac
10+
done
11+
12+
echo "Author: $author";
13+
echo "Project Name: $name";
14+
echo "Project URL name: $urlname";
15+
echo "Description: $description";
16+
17+
echo "Renaming project..."
18+
19+
original_author="author_name"
20+
original_name="project_name"
21+
original_urlname="project_urlname"
22+
original_description="project_description"
23+
# for filename in $(find . -name "*.*")
24+
for filename in $(git ls-files)
25+
do
26+
sed -i "s/$original_author/$author/g" $filename
27+
sed -i "s/$original_name/$name/g" $filename
28+
sed -i "s/$original_urlname/$urlname/g" $filename
29+
sed -i "s/$original_description/$description/g" $filename
30+
echo "Renamed $filename"
31+
done
32+
33+
mv project_name $name
34+
mv $name/project_name.json $name/$name.json
35+
36+
# This command runs only once on GHA!
37+
rm -rf .github/template.yml

.github/template.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
author: jernsting
2+
Inspired by https://github.com/rochacbruno/python-project-template

.github/workflows/deploy_to_pypi.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Release deployment on PyPI
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
deploy:
9+
if: ${{ !contains (github.repository, '/photonai_module_template') }}
10+
name: Build and publish to PyPI
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
with:
15+
fetch-depth: 0
16+
- name: Set up Python 3.10
17+
uses: actions/setup-python@v4
18+
with:
19+
python-version: "3.10.8"
20+
- name: Install pypa/build
21+
run: pip install build pbr wheel
22+
- name: Build a binary wheel and a source tarball
23+
run: python -m build -n --sdist --wheel --outdir dist/ .
24+
- name: Publish distribution to Test PyPI
25+
uses: pypa/gh-action-pypi-publish@release/v1
26+
with:
27+
user: __token__
28+
password: ${{ secrets.PYPI_API_TOKEN }}

.github/workflows/lindandtest.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# This workflow will install Python dependencies, run tests and lint with a single version of Python
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
3+
4+
name: Python application
5+
on: push
6+
7+
jobs:
8+
build:
9+
name: Test
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- uses: actions/checkout@v4
14+
- name: Set up Python 3.10
15+
uses: actions/setup-python@v4
16+
with:
17+
python-version: "3.10.8"
18+
- name: Install dependencies
19+
run: |
20+
python -m pip install --upgrade pip
21+
pip install flake8 pytest_cov coveralls
22+
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
23+
- name: Lint with flake8
24+
run: |
25+
# stop the build if there are Python syntax errors or undefined names
26+
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
27+
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
28+
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
29+
- name: Test with pytest
30+
run: |
31+
pytest --cov=. test/
32+
- name: Coveralls
33+
run: coveralls
34+
env:
35+
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
36+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/rename_project.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Rename the project from template
2+
3+
on: [push]
4+
5+
permissions: write-all
6+
7+
jobs:
8+
rename-project:
9+
if: ${{ !contains (github.repository, '/photonai_module_template') }}
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
with:
14+
# by default, it uses a depth of 1
15+
# this fetches all history so that we can read each commit
16+
fetch-depth: 0
17+
ref: ${{ github.head_ref }}
18+
19+
- run: echo "REPOSITORY_NAME=$(echo '${{ github.repository }}' | awk -F '/' '{print $2}' | tr '-' '_' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
20+
shell: bash
21+
22+
- run: echo "REPOSITORY_URLNAME=$(echo '${{ github.repository }}' | awk -F '/' '{print $2}')" >> $GITHUB_ENV
23+
shell: bash
24+
25+
- run: echo "REPOSITORY_OWNER=$(echo '${{ github.repository }}' | awk -F '/' '{print $1}')" >> $GITHUB_ENV
26+
shell: bash
27+
28+
- name: Is this still a template
29+
id: is_template
30+
run: echo "::set-output name=is_template::$(ls .github/template.yml &> /dev/null && echo true || echo false)"
31+
32+
- name: Rename the project
33+
if: steps.is_template.outputs.is_template == 'true'
34+
run: |
35+
echo "Renaming the project with -a(author) ${{ env.REPOSITORY_OWNER }} -n(name) ${{ env.REPOSITORY_NAME }} -u(urlname) ${{ env.REPOSITORY_URLNAME }}"
36+
.github/rename_project.sh -a ${{ env.REPOSITORY_OWNER }} -n ${{ env.REPOSITORY_NAME }} -u ${{ env.REPOSITORY_URLNAME }} -d "Awesome ${{ env.REPOSITORY_NAME }} created by ${{ env.REPOSITORY_OWNER }}"
37+
38+
- uses: stefanzweifel/git-auto-commit-action@v5
39+
with:
40+
commit_message: "✅ Ready to clone and code."
41+
# commit_options: '--amend --no-edit'
42+
push_options: --force
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Update documentation
2+
on: push
3+
4+
jobs:
5+
build:
6+
name: Build docs
7+
runs-on: ubuntu-latest
8+
if: ${{ github.ref != 'refs/heads/main' }}
9+
steps:
10+
- name: Checkout main
11+
uses: actions/checkout@v4
12+
13+
- name: Install Python
14+
uses: actions/setup-python@v4
15+
with:
16+
python-version: '3.10.8'
17+
18+
- name: Install mkdocs requirements
19+
run: pip install mkdocs mkdocs-material pymdown-extensions mkdocstrings-python mkdocs-jupyter jupyter
20+
21+
- name: Install project requirements
22+
run: pip install -r requirements.txt
23+
24+
- name: Install project
25+
run: pip install .
26+
27+
- name: Build docs
28+
run: |
29+
mkdocs build
30+
deploy:
31+
name: Deploy docs
32+
runs-on: ubuntu-latest
33+
if: ${{ github.ref == 'refs/heads/main' }}
34+
steps:
35+
- name: Checkout main
36+
uses: actions/checkout@v4
37+
38+
- name: Install Python
39+
uses: actions/setup-python@v4
40+
with:
41+
python-version: '3.10.8'
42+
43+
- name: Install mkdocs requirements
44+
run: pip install mkdocs mkdocs-material pymdown-extensions mkdocstrings-python mkdocs-jupyter jupyter
45+
46+
- name: Install project requirements
47+
run: pip install -r requirements.txt
48+
49+
- name: Install project
50+
run: pip install .
51+
52+
- name: Deploy docs
53+
run: |
54+
mkdocs gh-deploy --force

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
.idea/
3+
4+
project_name/registered
5+
6+
*.pyc

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2020 Medical Machine Learning Lab at the University of Münster
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
[![Python application](https://github.com/wwu-mmll/photonai_module_template/actions/workflows/lindandtest.yml/badge.svg)](https://github.com/wwu-mmll/photonai_module_template/actions/workflows/lindandtest.yml)
2+
[![Coverage Status](https://coveralls.io/repos/github/wwu-mmll/photonai_module_template/badge.svg?branch=master)](https://coveralls.io/github/wwu-mmll/photonai_module_template?branch=master)
3+
![GitHub](https://img.shields.io/github/license/wwu-mmll/photonai_module_template)
4+
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=wwu-mmll_photonai_module_template&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=wwu-mmll_photonai_module_template)
5+
6+
# How to use this template
7+
This repository is a quick start template for new photonai modules. To get started simply follow these steps:
8+
1. Klick "Use this template" button
9+
2. Fill in details for the new photonai module
10+
3. Wait for the repository to be created
11+
4. Wait for the Github Actions to run once
12+
5. As soon as the "✅ Ready to clone and code." commit appears in your repository you are ready to start coding
13+
6. (optional) Remove "rename_project.yml" workflow from .github/workflows
14+
7. (optional) Remove "rename_project.sh" from .github
15+
8. Remove this how to section from readme
16+
17+
## Included features
18+
- [X] Code testing and coverage calculation (if coveralls secret **COVERALLS_REPO_TOKEN** is set)
19+
- [X] Continous Integration for testing and documentation updates based on Github Actions.
20+
- [X] MkDocs-Material based documentation template
21+
- [X] Photonai compatible **init.py** with boilerplate code for registration of new module
22+
- [X] pbr based auto-versioning for python releases
23+
- [X] blueprint action for pypi publishing (on github release)
24+
25+
# How to implement a photonai module
26+
27+
Take a look at some of our modules like [photonai neuro](https://github.com/wwu-mmll/photonai_neuro)
28+
or [photonai graph](https://github.com/wwu-mmll/photonai_graph).
29+
Most importantly: Feel free to reach out via issues in case of problems, e.g. by creating an issue at the [photonai repo](https://github.com/wwu-mmll/photonai)
30+
31+
## Development workflow: Add new algorithms
32+
In order to add a new Algorithm / Feature to your project you can follow the steps below. By providing unit tests, a documentation and an example you maximize code quality and usability of your module.
33+
- [ ] Develop your learning algorithm / transformer / utility code (remember to adhere to the scikit-learn object API as [documented here](https://wwu-mmll.github.io/photonai/getting_started/custom_algorithm/))
34+
- [ ] Test your algorithms in a respective test file in the `test` folder
35+
- [ ] Document algorithms in the `docs` folder by copying and adapting the provided .md file
36+
- [ ] Provide an example on how to use your algorithms in an appropriately named file in the examples folder.
37+
- [ ] Expose the algorithm to photonai by adding it to the the `project_name/project_name.json` file with the full path. An example is provided within this repository. Thereby, the algorithm can be imported via its name, as defined in the json file. Make sure to pick a unique name.
38+
39+
**In order to access your algorithms and functions in photonai you have to import your module once in your final script. This triggers the registration process in the photonai core module!**
40+
41+
## Release a version of your software (on pypi)
42+
We suggest releasing via the github website. Simply create a release and an according tag.
43+
The tag is then used as version number and (if configured) the desired version is immediately build and released on pypi.
44+
45+
Documentation avaiable at: [Documentation](https://wwu-mmll.github.io/photonai_module_template/)

docs/api/DummyTransformer.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# DummyTransformer
2+
3+
A module for performing dummy transformations
4+
5+
!!! info
6+
This is only a dummy transformer
7+
8+
::: project_name.dummy.DummyTransformer.DummyTransformer.__init__
9+
rendering:
10+
show_root_toc_entry: False

docs/examples

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../examples

docs/index.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
[![Python application](https://github.com/wwu-mmll/photonai_module_template/actions/workflows/lindandtest.yml/badge.svg)](https://github.com/wwu-mmll/photonai_module_template/actions/workflows/lindandtest.yml)
2+
[![Coverage Status](https://coveralls.io/repos/github/wwu-mmll/photonai_module_template/badge.svg?branch=master)](https://coveralls.io/github/wwu-mmll/photonai_module_template?branch=master)
3+
![GitHub](https://img.shields.io/github/license/wwu-mmll/photonai_module_template)
4+
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=wwu-mmll_photonai_module_template&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=wwu-mmll_photonai_module_template)
5+
# How to use this template
6+
This repository is a quick start template for new photonai modules. To get started simply follow these steps:
7+
8+
1. Klick "Use this template" button
9+
2. Fill in details for the new photonai module
10+
3. Wait for the repository to be created
11+
4. Wait for the Github Actions to run once
12+
5. As soon as the "✅ Ready to clone and code." commit appears in your repository you are ready to start coding
13+
6. (optional) Remove "rename_project.yml" workflow from .github/workflows
14+
7. (optional) Remove "rename_project.sh" from .github
15+
8. Remove this how to section from readme
16+
17+
## Included features
18+
19+
- Code testing and coverage calculation (if coveralls secret **COVERALLS_REPO_TOKEN** is set)
20+
- Continous Integration for testing and documentation updates based on Github Actions.
21+
- MkDocs-Material based documentation template
22+
- Photonai compatible **init.py** with boilerplate code for registration of new module
23+
24+
# How to implement a photonai module
25+
26+
Take a look at some of our modules like [photonai neuro](https://github.com/wwu-mmll/photonai_neuro)
27+
or [photonai graph](https://github.com/wwu-mmll/photonai_graph).
28+
Most importantly: Feel free to reach out via issues in case of problems, e.g. by creating an issue at the [photonai repo](https://github.com/wwu-mmll/photonai)
29+
30+
## Development workflow: Add new algorithms
31+
32+
In order to add a new Algorithm / Feature to your project you can follow the steps below. By providing unit tests, a documentation and an example you maximize code quality and usability of your module.
33+
34+
- Develop your learning algorithm / transformer / utility code (remember to adhere to the scikit-learn object API as [documented here](https://wwu-mmll.github.io/photonai/getting_started/custom_algorithm/))
35+
- Test your algorithms in a respective test file in the `test` folder
36+
- Document algorithms in the `docs` folder by copying and adapting the provided .md file
37+
- Provide an example on how to use your algorithms in an appropriately named file in the examples folder.
38+
- Expose the algorithm to photonai by adding it to the the `project_name/project_name.json` file with the full path. An example is provided within this repository. Thereby, the algorithm can be imported via its name, as defined in the json file. Make sure to pick a unique name.
39+
40+
**In order to access your algorithms and functions in photonai you have to import your module once in your final script. This triggers the registration process in the photonai core module!**

0 commit comments

Comments
 (0)