Skip to content

Commit 7de8c7d

Browse files
author
notactuallyfinn
committed
applied simple suggestions
1 parent 758dbde commit 7de8c7d

3 files changed

Lines changed: 18 additions & 16 deletions

File tree

docs/source/tutorials/writing-a-plugin-for-hermes.md

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,16 @@ And uses the [schmea.org](https://schema.org/) (with prefix "schema") and the [C
3333
HERMES uses a plugin architecture. Therefore, users are invited to contribute own features.
3434

3535
The structure for every plugin follows the same schema.
36-
Every plugin is a sub class of a sub class of the `HermesPlugin` class.
37-
This class implements one abstract method, `__call__`, which needs to be overwritten by every plugin.
38-
In between the `HermesPlugin` class and the class of a specific plugin there is another class which follows the naming scheme `Hermes{Step}Plugin` where `{Step}` is the step the plugin is for.
36+
Every plugin is a sub class of a sub class of the {py:class}`~hermes.commands.base.HermesPlugin` class.
37+
This class implements one abstract method, {py:meth}`~hermes.commands.base.HermesPlugin.__call__`, which needs to be overwritten by every plugin.
38+
In between the {py:class}`~hermes.commands.base.HermesPlugin` class and the class of a specific plugin there is another class which follows the naming scheme `Hermes{Step}Plugin` where `{Step}` is the step the plugin is for.
3939
These base classes may implement additional (abstract) methods that may have to be implemented by the plugins class.
4040

41-
The first positional attribute of the `__call__` method is an object of class `Hermes{Step}Command` (where `{Step}` is the step the plugin is for), which is a sub class of `HermesCommand`, which triggered this plugin to run.
41+
The first positional attribute of the `__call__` method is an object of class `Hermes{Step}Command` (where `{Step}` is the step the plugin is for), which is a sub class of {py:class}`~hermes.commands.base.HermesCommand`, which triggered this plugin to run.
4242
An exception to this are the deposit plugins. Those don't implement the `__call__` method and instead can implement (and have to implement some) other functions.
4343

44-
The plugin class also uses a derivative of `HermesSettings` to add parameters that can be adapted by the configuration file.
45-
`HermesSettings` is the base class for command specific settings.
44+
The plugin class also uses a derivative of {py:class}`~hermes.commands.base.HermesSettings` to add parameters that can be adapted by the configuration file.
45+
{py:class}`~hermes.commands.base.HermesSettings` is the base class for command specific settings.
4646
It uses [pydantic](https://docs.pydantic.dev/latest/) [settings](https://docs.pydantic.dev/latest/api/pydantic_settings/) to specify and validate the parameters.
4747
The user can either set the parameters in the `hermes.toml` or overwrite them in the command line.
4848
To overwrite a parameter from command line, use the `-O` command line option followed by the dotted parameter name and the value.
@@ -80,7 +80,7 @@ class YourHarvestPlugin(HermesHarvestPlugin):
8080
return data
8181
```
8282

83-
The `__call__` method of harest plugins needs to return a SoftwareMetadata object containing the harvested metadata.
83+
The {py:meth}`~hermes.commands.harvest.base.HermesHarvestPlugin.__call__` method of harest plugins needs to return a {py:class}`~hermes.model.api.SoftwareMetadata` object containing the harvested metadata.
8484
For more information on how to use this object see [here](../dev/data_model.md).
8585

8686
### Process plugin
@@ -110,8 +110,8 @@ class YourProcessPlugin(HermesProcessPlugin):
110110
return strategies
111111
```
112112

113-
The `__call__` method of process plugins needs to return a dictionary mappings strings and/ or `None` to dictionaries mapping strings or `None` to {py:class}`hermes.model.merge.action.MergeAction`.
114-
If `strategies` looked like this (where `Reject` is imported from `hermes.model.merge.action`)
113+
The {py:meth}`~hermes.commands.process.base.HermesProcessPlugin.__call__` method of process plugins needs to return a dictionary mappings strings and/ or `None` to dictionaries mapping strings or `None` to {py:class}`~hermes.model.merge.action.MergeAction`.
114+
If `strategies` looked like this (where {py:class}`~hermes.model.merge.action.Reject` is imported from {py:mod}`hermes.model.merge.action`)
115115
```{code-block} python
116116
strategies = {
117117
full_type_iri: {
@@ -122,7 +122,7 @@ strategies = {
122122
}
123123
```
124124

125-
HERMES would use the `Reject` strategy for merging values of the key `full_property_iri` in objects of type `full_type_iri`. (A key in strategies being `None` instead of a string indicates to HERMES that its value is to be used as a default [i.e. if no more specific entry exists].)
125+
HERMES would use the {py:class}`~hermes.model.merge.action.Reject` strategy for merging values of the key `full_property_iri` in objects of type `full_type_iri`. (A key in strategies being `None` instead of a string indicates to HERMES that its value is to be used as a default [i.e. if no more specific entry exists].)
126126

127127
HERMES will prioritize strategies from other plugins depending on the order of the plugins in the `hermes.toml`. Generally the hierarchy is as follows (first most important):
128128
1. strategies with `full_property_iri` and `full_type_iri` not `None`.
@@ -157,7 +157,7 @@ class YourCuratePlugin(HermesCuratePlugin):
157157
return data
158158
```
159159

160-
The `__call__` method of harest plugins needs to return a SoftwareMetadata object containing the curated metadata.
160+
The {py:meth}`~hermes.commands.curate.base.HermesCuratePlugin.__call__` method of curate plugins needs to return a {py:class}`~hermes.model.api.SoftwareMetadata` object containing the curated metadata.
161161
For more information on how to use this object see [here](../dev/data_model.md).
162162
The returned object may be the object `metadata` passed to `__call__`.
163163

@@ -225,7 +225,7 @@ class YourDepositPlugin(HermesDepositPlugin):
225225
A deposit plugin doesn't implement a `__call__` method like plugins for other steps.
226226
Instead it can (and in some cases has to) implement methods, which will be called in a predefined order.
227227

228-
The plugin still has access to the command (via self.command) and the metadata for the software (via self.metadata).
228+
The plugin still has access to the command (via `self.command`) and the metadata for the software (via `self.metadata`).
229229

230230
### Postprocess plugin
231231
The class structure of a postprocess plugin should look like this:
@@ -259,7 +259,7 @@ with ctx[deposit_plugin_name] as manager:
259259
ctx.finalize_step("deposit")
260260
```
261261

262-
where `deposit_plugin_name` is the name of the deposit plugin the data is loaded from and HermesContext is {py:class}`hermes.model.context_manager.HermesContext`.
262+
where `deposit_plugin_name` is the name of the deposit plugin the data is loaded from and {py:class}`~hermes.model.context_manager.HermesContext` is imported from {py:mod}`hermes.model.context_manager`.
263263
The loaded data is some valid JSON data and has no fixed format.
264264

265265
## Implement and use plugin specific settings
@@ -376,11 +376,13 @@ target = "{plugin_name}"
376376
[postprocess]
377377
run = [ ..., "{plugin_name}", ... ]
378378
...
379+
379380
```
380381
<br><br>
381382
```{admonition} Congratulations!
382383
You can now write plugins for HERMES.
383-
Consider publishing it for others to use following this guide. TODO: add link
384384
```
385385

386+
Consider publishing it to the [HERMES plugin marketplace](../index.md#plugins) for others to use following this guide. TODO: add link
387+
386388
If you have any questions, wishes or requests, feel free to contact us.

src/hermes/commands/deposit/file.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515

1616
class FileDepositSettings(BaseModel):
17-
filename: str = 'codemeta.json'
17+
filename: str = 'hermes.json'
1818

1919

2020
class FileDepositPlugin(BaseDepositPlugin):

test/hermes_test/commands/deposit/test_file_deposit.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def test_file_deposit(tmp_path, monkeypatch, metadata):
4545
if e.code != 0:
4646
raise e
4747
finally:
48-
with open("codemeta.json", "r") as cache:
48+
with open("hermes.json", "r") as cache:
4949
result = SoftwareMetadata(json.load(cache))
5050
sys.argv = orig_argv
5151

0 commit comments

Comments
 (0)