Skip to content

Commit

Permalink
Add docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
zyzzyxdonta committed Oct 17, 2024
1 parent ed6c4bf commit 3a1c5e7
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions src/hermes/commands/deposit/rodare.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,33 @@


class RodareDepositSettings(InvenioDepositSettings):
"""Settings for Rodare deposit plugin.
This extends the base class by the Robis publication identifier that is required
when creating deposits on Rodare.
The ``site_url`` is overridden as it will be the same for all users.
"""

site_url: str = "https://rodare.hzdr.de"
robis_pub_id: str = None


class RodareClient(InvenioClient):
"""Custom Rodare client with updated ``platform_name`` for correct config access."""

platform_name = "rodare"


class RodareResolver(InvenioResolver):
"""Custom Rodare resolver using custom client."""

invenio_client_class = RodareClient


class RodareDepositPlugin(InvenioDepositPlugin):
"""Deposit plugin for the HZDR data repository Rodare (https://rodare.hzdr.de)."""

platform_name = "rodare"
settings_class = RodareDepositSettings
invenio_client_class = RodareClient
Expand All @@ -35,6 +49,7 @@ class RodareDepositPlugin(InvenioDepositPlugin):
robis_publication_url = "https://www.hzdr.de/publications/Publ-{pub_id}"

def prepare(self) -> None:
"""Update the context with the Robis identifier from the config."""
super().prepare()

if not self.config.robis_pub_id:
Expand All @@ -49,12 +64,37 @@ def prepare(self) -> None:
)

def create_initial_version(self) -> None:
"""Disallow creation of initial versions using HERMES.
HZDR publications must all be registered in Robis (https://www.hzdr.de/robis).
There is a workflow in place that guides users from Robis to Rodare and
automatically transfers metadata for them. Starting the publication workflow in
Rodare is discouraged.
Subsequent releases of the software may be published on Rodare directly as the
connection to Robis is in place by then.
This code should never be reached. So, raising a ``RuntimeError`` is just a
precaution.
"""
raise RuntimeError(
"Please initiate the publication process in Robis. "
f"HERMES may be used for subsequent releases. {self.robis_url}"
)

def _codemeta_to_invenio_deposition(self) -> dict:
"""Update the deposition metadata from the parent class.
Deposits on Rodare require a connection to the publication database Robis. To
make this connection, the deposit metadata has to contain the field ``pub_id``
which can be used to find the publication at
``https://www.hzdr.de/publications/Publ-{pub_id}``.
Additionally (this is not required by Rodare), we make a connection via related
identifiers.
An example publication on Rodare: https://rodare.hzdr.de/api/records/2
"""
pub_id = self.config.robis_pub_id
deposition_metadata = super()._codemeta_to_invenio_deposition()

Expand Down

0 comments on commit 3a1c5e7

Please sign in to comment.