hermes.commands.deposit.base

Classes

HermesDepositPlugin

Base class that implements the generic deposition workflow.

DepositSettings

Generic deposition settings.

HermesDepositCommand

Deposit the curated metadata to repositories.

Module Contents

class hermes.commands.deposit.base.HermesDepositPlugin

Bases: hermes.commands.base.HermesPlugin

Base class that implements the generic deposition workflow.

command

The command running this plugin.

Type:

HermesCommand

metadata

The loaded curated metadata.

Type:

SoftwareMetadata

TODO: describe workflow… needs refactoring to be less stateful!

__call__(command: HermesDepositCommand, prov_doc: hermes.model.provenance.ld_prov.ld_prov_list | None) None

Initiate the deposition process.

This calls a list of additional methods on the class, none of which need to be implemented.

Parameters:
  • command (HermesDepositCommand) – The command running this plugin.

  • prov_doc (ld_prov_list | None) – The provenance document the provenance information is to be recorded in.

Return type:

None

Raises:

HermesValidationError – If the metadata from the curation step couldn’t be loaded.

prepare() None

Prepare the deposition.

This method may be implemented to check whether config and context match some initial conditions.

If no exceptions are raised, execution continues.

Return type:

None

abstractmethod map_metadata() dict

Map the given metadata to the target schema of the deposition platform and return it.

When mapping metadata, make sure to add traces to the HERMES software, e.g. via DataCite’s relatedIdentifier using the isCompiledBy relation. Ideally, the value of the relation target should be of the respective type for DOIs in your metadata schema, with the value itself being the DOI for the version of the HERMES software you are using.

Returns:

The mapped metadata.

Return type:

dict

is_initial_publication() bool

Decide whether to do an initial publication or publish a new version.

Returning True indicates that publication of an initial version will be executed, resulting in a call of create_initial_version(). False indicates a new version of an existing publication, leading to a call of create_new_version().

By default, this returns True.

Returns:

Whether or not it is the initial publication.

Return type:

bool

create_initial_version() None

Create an initial version of the publication on the target platform.

Return type:

None

create_new_version() None

Create a new version of an existing publication on the target platform.

Return type:

None

abstractmethod update_metadata() dict

Update the metadata of the newly created version and return it even if it hasn’t changed.

Returns:

The updated metadata.

Return type:

dict

delete_artifacts() None

Delete any superfluous artifacts taken from the previous version of the publication.

Return type:

None

upload_artifacts() None

Upload new artifacts to the target platform.

Return type:

None

abstractmethod publish() None

Publish the newly created deposit on the target platform.

Return type:

None

class hermes.commands.deposit.base.DepositSettings(/, **data: Any)

Bases: pydantic.BaseModel

Generic deposition settings.

target

The plugin to be executed.

Type:

str

class hermes.commands.deposit.base.HermesDepositCommand(parser: argparse.ArgumentParser)

Bases: hermes.commands.base.HermesCommand

Deposit the curated metadata to repositories.

args

The namespace that was returned by the command line parser when reading the arguments.

Type:

Namespace

command_name

(class attribute) The name of the command.

Type:

str

settings_class

(class attribute) The settings class for general deposit settings.

Type:

type

init_command_parser(command_parser: argparse.ArgumentParser) None

Add arguments for deposit command.

Parameters:

command_parser (ArgumentParser) – The used argument parser.

Return type:

None

__call__(args: argparse.Namespace) None

Execute the hermes command self.

Parameters:

args (Namespace) – The namespace that was returned by the command line parser when reading the arguments.

Return type:

None

Raises:
load_prov_doc() hermes.model.provenance.ld_prov.ld_prov_list | None

Loads the provenance document of the curate step.

Returns:

The loaded provenance document or None if the load failed.

Return type:

ld_prov_list | None