Skip to content

Commit

Permalink
Merge pull request #387 from monarch-initiative/386-add-new-link-to-c…
Browse files Browse the repository at this point in the history
…ookiecutter-template-to-docs

386 add new link to cookiecutter template to docs
  • Loading branch information
yaseminbridges authored Jan 20, 2025
2 parents d2aeac0 + aedbd25 commit af598eb
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 25 deletions.
43 changes: 18 additions & 25 deletions docs/developing_a_pheval_plugin.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ The plugin goal is to be flexible through custom runner implementations. This pl
## Step-by-Step Plugin Development Process

The plugin structure is derived from a [cookiecutter](https://cookiecutter.readthedocs.io/en/stable/) template, [Sphintoxetry-cookiecutter](https://github.com/hrshdhgd/sphintoxetry-cookiecutter), and it uses [Sphinx](https://www.sphinx-doc.org/en/master/), [tox](https://tox.wiki/en/latest/) and [poetry](https://python-poetry.org) as core dependencies.
This allows PhEval extensibility to be standardized in terms of documentation and dependency management.
This allows PhEval extensibility to be standardised in terms of documentation and dependency management.

### 1. Sphintoxetry-cookiecutter scaffold

Expand All @@ -36,7 +36,7 @@ pip install cruft
Next, create a project using the sphintoxetry-cookiecutter template.

```
cruft create https://github.com/monarch-initiative/monarch-project-template
cruft create https://github.com/monarch-initiative/pheval-runner-template
```

### 2. Further setup
Expand All @@ -53,12 +53,6 @@ pip install poetry
poetry install
```

#### Add PhEval dependency

```
poetry add pheval
```

#### Run tox to see if the setup works

```
Expand All @@ -67,22 +61,19 @@ poetry run tox

### 3. Implement PhEval Custom Runner

_The runner name is arbitrary and custom Runner name was chose by demonstrative purposes_

Create a runner file inside the plugin project, e.g:

![a](./imgs/plugin_example_folder_structure.png)

In the project structure generated by Cookiecutter, you'll find `runner.py` located in the `src` directory. This is where you'll define the methods required to develop the plugin. Specifically, you'll implement the prepare, run, and post-process methods, which are essential for executing the pheval run command.
```python
"""Custom Pheval Runner."""
"""Runner."""

from dataclasses import dataclass
from pathlib import Path

from pheval.runners.runner import PhEvalRunner


@dataclass
class CustomPhevalRunner(PhEvalRunner):
"""CustomPhevalRunner Class."""
class CustomRunner(PhEvalRunner):
"""Runner class implementation."""

input_dir: Path
testdata_dir: Path
Expand All @@ -92,29 +83,31 @@ class CustomPhevalRunner(PhEvalRunner):
version: str

def prepare(self):
"""prepare method."""
"""Prepare."""
print("preparing")

def run(self):
"""run method."""
print("running with custom pheval runner")
"""Run."""
print("running")

def post_process(self):
"""post_process method."""
"""Post Process."""
print("post processing")

```

### 4. Add PhEval Plugins section to the pyproject.toml file

The Cookiecutter will automatically populate the plugins section in the `pyproject.toml` file. If you decide to modify the path of `runner.py` or rename its class, be sure to update the corresponding entries in this section accordingly:

```toml
[tool.poetry.plugins."pheval.plugins"]
customrunner = "pheval_plugin_example.runner:CustomPhevalRunner"
customrunner = "pheval_plugin_example.runner:CustomRunner"
```

==Replace the value above with the path to your custom runner plugin==
> Please Note that the path here and naming of the class is case sensitive.

### 5. Implementing PhEval helper methods
### 4. Implementing PhEval helper methods

Streamlining the creation of your custom PhEval runner can be facilitated by leveraging PhEval's versatile helper methods, where applicable.

Expand Down
Binary file removed docs/imgs/plugin_example_folder_structure.png
Binary file not shown.

0 comments on commit af598eb

Please sign in to comment.