-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add snakemake reporter plugin skeleton
Created a new reporter from the Snakemake plugin template Added some documentation to README
- Loading branch information
Showing
12 changed files
with
409 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,84 @@ | ||
# ro-crate_snakemake_tooling | ||
Collection of python tools for processing snakemake metadata for RO-Crate creation | ||
|
||
|
||
## Snakemake reporter plugin | ||
|
||
Documentation how the wrroc reporter plugin is built. | ||
|
||
### Setup poetry | ||
|
||
Poetry is used for setting up a new plugin from a template. | ||
In my experience, the Python version used here has to match the Python version used with Snakemake environment, otherwise the plugin does not work. | ||
But this should be a solvable problem. | ||
|
||
``` | ||
conda create --name poetry python=3.12 | ||
conda activate poetry | ||
pip install poetry | ||
``` | ||
|
||
### Create new plugin from the template | ||
|
||
Note: The poetry project was added to this repository. | ||
You only have to install the poetry plugin and can use the project in this repository. | ||
|
||
``` | ||
# Install poetry plugin via | ||
poetry self add poetry-snakemake-plugin | ||
# Create a new poetry project via | ||
poetry new snakemake-report-plugin-wrroc | ||
cd snakemake-report-plugin-wrroc | ||
# Scaffold the project as a snakemake report plugin | ||
poetry scaffold-snakemake-report-plugin | ||
# Next, edit the scaffolded code according to your needs, and publish | ||
# the resulting plugin into a github repository. The scaffold command also | ||
# creates github actions workflows that will immediately start to check and test | ||
# the plugin. | ||
``` | ||
|
||
### Implement plugin | ||
|
||
Implement the report `render` method here: | ||
|
||
``` | ||
snakemake-report-plugin-wrroc/snakemake_report_plugin_wrroc/__init__.py | ||
``` | ||
|
||
For plugin development one can take a look what information the base class [ReporterBase](https://github.com/snakemake/snakemake-interface-report-plugins/blob/main/snakemake_interface_report_plugins/reporter.py) provides. | ||
|
||
### Build and install plugin | ||
|
||
Build wheel and tar.gz: | ||
|
||
``` | ||
poetry build | ||
``` | ||
|
||
Install the plugin. | ||
|
||
``` | ||
pip install --force-reinstall dist/snakemake_report_plugin_wrroc-0.1.0-py3-none-any.whl | ||
``` | ||
|
||
Snakemake should find the plugin! Note that there are many copy&paste errors for the reporter plugin, even in the poetry template repository. Most of the time the term `executor plugin` is used instead of `reporter plugin`. | ||
|
||
``` | ||
snakemake -h | ||
[...] | ||
wrroc executor settings: | ||
--report-wrroc-myparam VALUE | ||
Some help text (default: <dataclasses._MISSING_TYPE object at 0x7f0091b3f140>) | ||
``` | ||
|
||
### Create a report | ||
|
||
Test the reporter plugin in the skim2mt directory, where the `.snakemake/metadata` resides: | ||
|
||
``` | ||
snakemake --reporter wrroc | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
name: CI | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
|
||
env: | ||
PYTHON_VERSION: 3.11 | ||
|
||
jobs: | ||
formatting: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out the code | ||
uses: actions/checkout@v3 | ||
|
||
- uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ env.PYTHON_VERSION }} | ||
|
||
- name: Install poetry | ||
run: pip install poetry | ||
|
||
- name: Determine dependencies | ||
run: poetry lock | ||
|
||
- uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ env.PYTHON_VERSION }} | ||
cache: poetry | ||
|
||
- name: Install Dependencies using Poetry | ||
run: poetry install | ||
|
||
- name: Check formatting | ||
run: poetry run black --check . | ||
|
||
linting: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out the code | ||
uses: actions/checkout@v3 | ||
|
||
- uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ env.PYTHON_VERSION }} | ||
|
||
- name: Install poetry | ||
run: pip install poetry | ||
|
||
- name: Determine dependencies | ||
run: poetry lock | ||
|
||
- uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ env.PYTHON_VERSION }} | ||
cache: poetry | ||
|
||
- name: Install Dependencies using Poetry | ||
run: poetry install | ||
|
||
- name: Check code | ||
run: poetry run flake8 | ||
|
||
testing: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ env.PYTHON_VERSION }} | ||
|
||
- name: Install poetry | ||
run: pip install poetry | ||
|
||
- name: Determine dependencies | ||
run: poetry lock | ||
|
||
- uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ env.PYTHON_VERSION }} | ||
cache: poetry | ||
|
||
- name: Install dependencies | ||
run: poetry install | ||
|
||
- name: Run pytest | ||
run: poetry run coverage run -m pytest tests/tests.py | ||
|
||
- name: Run Coverage | ||
run: poetry run coverage report -m |
16 changes: 16 additions & 0 deletions
16
snakemake-report-plugin-wrroc/.github/workflows/conventional-prs.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
name: PR | ||
on: | ||
pull_request_target: | ||
types: | ||
- opened | ||
- reopened | ||
- edited | ||
- synchronize | ||
|
||
jobs: | ||
title-format: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: amannn/[email protected] | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
53 changes: 53 additions & 0 deletions
53
snakemake-report-plugin-wrroc/.github/workflows/release-please.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
name: release-please | ||
|
||
env: | ||
PYTHON_VERSION: 3.11 | ||
|
||
jobs: | ||
release-please: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
release_created: ${{ steps.release.outputs.release_created }} | ||
steps: | ||
- uses: GoogleCloudPlatform/release-please-action@v3 | ||
id: release | ||
with: | ||
release-type: python | ||
package-name: snakemake-report-plugin-wrroc | ||
|
||
publish: | ||
runs-on: ubuntu-latest | ||
needs: release-please | ||
if: ${{ needs.release-please.outputs.release_created }} | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ env.PYTHON_VERSION }} | ||
|
||
- name: Install poetry | ||
run: pip install poetry | ||
|
||
- name: Determine dependencies | ||
run: poetry lock | ||
|
||
- uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ env.PYTHON_VERSION }} | ||
cache: poetry | ||
|
||
- name: Install Dependencies using Poetry | ||
run: | | ||
poetry install | ||
- name: Publish to PyPi | ||
env: | ||
PYPI_USERNAME: __token__ | ||
PYPI_PASSWORD: ${{ secrets.PYPI_TOKEN }} | ||
run: poetry publish --build --username $PYPI_USERNAME --password $PYPI_PASSWORD |
Empty file.
Binary file added
BIN
+2.5 KB
snakemake-report-plugin-wrroc/dist/snakemake_report_plugin_wrroc-0.1.0-py3-none-any.whl
Binary file not shown.
Binary file added
BIN
+2 KB
snakemake-report-plugin-wrroc/dist/snakemake_report_plugin_wrroc-0.1.0.tar.gz
Binary file not shown.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
[build-system] | ||
requires = [ "poetry-core",] | ||
build-backend = "poetry.core.masonry.api" | ||
|
||
[tool.poetry] | ||
name = "snakemake-report-plugin-wrroc" | ||
version = "0.1.0" | ||
description = "" | ||
authors = [ "fbartusch <[email protected]>",] | ||
readme = "README.md" | ||
repository = "https://github.com/your/plugin" | ||
documentation = "https://snakemake.github.io/snakemake-plugin-catalog/plugins/report/wrroc.html" | ||
|
||
[tool.poetry.dependencies] | ||
python = "^3.12" | ||
snakemake-interface-common = "^1.17.2" | ||
snakemake-interface-report-plugins = "^1.0.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[flake8] | ||
# Recommend matching the black line length (default 88), | ||
# rather than using the flake8 default of 79: | ||
max-line-length = 88 | ||
extend-ignore = | ||
# See https://github.com/PyCQA/pycodestyle/issues/373 | ||
E203, |
Oops, something went wrong.