Skip to content

Commit

Permalink
Add post-processing plugin for InvenioRDM
Browse files Browse the repository at this point in the history
This might have been parametrized or implemented differently to distinguish between Invenio and InvenioRDM.
However, this way works without further coding headache...
  • Loading branch information
led02 committed Nov 2, 2023
1 parent b778a41 commit 7272069
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ invenio_rdm = "hermes.commands.deposit.invenio_rdm:publish"
file = "hermes.commands.deposit.file:publish"

[tool.poetry.plugins."hermes.postprocess"]
config_record_id = "hermes.commands.postprocess.invenio:config_record_id"
config_invenio_record_id = "hermes.commands.postprocess.invenio:config_record_id"
config_invenio_rdm_record_id = "hermes.commands.postprocess.invenio_rdm:config_record_id"
cff_doi = "hermes.commands.postprocess.invenio:cff_doi"

[tool.taskipy.tasks]
Expand Down
29 changes: 29 additions & 0 deletions src/hermes/commands/postprocess/invenio_rdm.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# SPDX-FileCopyrightText: 2023 German Aerospace Center (DLR)
#
# SPDX-License-Identifier: Apache-2.0

# SPDX-FileContributor: Michael Meinel
# SPDX-FileContributor: Stephan Druskat

import json
import logging

import toml
from ruamel import yaml

from hermes import config


_log = logging.getLogger('deposit.invenio_rdm')


def config_record_id(ctx):
deposition_path = ctx.get_cache('deposit', 'deposit')
with deposition_path.open("r") as deposition_file:
deposition = json.load(deposition_file)
conf = config.get('hermes')
try:
conf['deposit']['invenio_rdm']['record_id'] = deposition['record_id']
toml.dump(conf, open('hermes.toml', 'w'))
except KeyError:
raise RuntimeError("No deposit.invenio configuration available to store record id in") from None

0 comments on commit 7272069

Please sign in to comment.