hermes.commands.deposit.base
============================

.. py:module:: hermes.commands.deposit.base


Classes
-------

.. autoapisummary::

   hermes.commands.deposit.base.HermesDepositPlugin
   hermes.commands.deposit.base.DepositSettings
   hermes.commands.deposit.base.HermesDepositCommand


Module Contents
---------------

.. py:class:: HermesDepositPlugin

   Bases: :py:obj:`hermes.commands.base.HermesPlugin`


   Base class that implements the generic deposition workflow.

   .. attribute:: command

      The command running this plugin.

      :type: HermesCommand

   .. attribute:: metadata

      The loaded curated metadata.

      :type: SoftwareMetadata

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


   .. py:method:: __call__(command: HermesDepositCommand, prov_doc: Optional[hermes.model.provenance.ld_prov.ld_prov_list]) -> None

      Initiate the deposition process.

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

      :param command: The command running this plugin.
      :type command: HermesDepositCommand
      :param prov_doc: The provenance document the provenance information is to be recorded in.
      :type prov_doc: ld_prov_list | None

      :rtype: None

      :raises HermesValidationError: If the metadata from the curation step couldn't be loaded.



   .. py:method:: 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.

      :rtype: None



   .. py:method:: map_metadata() -> dict
      :abstractmethod:


      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.
      :rtype: dict



   .. py:method:: 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
      :meth:`create_initial_version`. ``False`` indicates a new version of an existing publication, leading to a call
      of :meth:`create_new_version`.

      By default, this returns ``True``.

      :returns: Whether or not it is the initial publication.
      :rtype: bool



   .. py:method:: create_initial_version() -> None

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

      :rtype: None



   .. py:method:: create_new_version() -> None

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

      :rtype: None



   .. py:method:: update_metadata() -> dict
      :abstractmethod:


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

      :returns: The updated metadata.
      :rtype: dict



   .. py:method:: delete_artifacts() -> None

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

      :rtype: None



   .. py:method:: upload_artifacts() -> None

      Upload new artifacts to the target platform.

      :rtype: None



   .. py:method:: publish() -> None
      :abstractmethod:


      Publish the newly created deposit on the target platform.

      :rtype: None



.. py:class:: DepositSettings(/, **data: Any)

   Bases: :py:obj:`pydantic.BaseModel`


   Generic deposition settings.

   .. attribute:: target

      The plugin to be executed.

      :type: str


.. py:class:: HermesDepositCommand(parser: argparse.ArgumentParser)

   Bases: :py:obj:`hermes.commands.base.HermesCommand`


   Deposit the curated metadata to repositories.

   .. attribute:: args

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

      :type: Namespace

   .. attribute:: command_name

      (class attribute) The name of the command.

      :type: str

   .. attribute:: settings_class

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

      :type: type


   .. py:method:: init_command_parser(command_parser: argparse.ArgumentParser) -> None

      Add arguments for deposit command.

      :param command_parser: The used argument parser.
      :type command_parser: ArgumentParser

      :rtype: None



   .. py:method:: __call__(args: argparse.Namespace) -> None

      Execute the hermes command `self`.

      :param args: The namespace that was returned by the command line parser when reading the arguments.
      :type args: Namespace

      :rtype: None

      :raises MisconfigurationError: If the deposit plugin wasn't found.
      :raises HermesPluginRunError: If something went wrong in the plugin run.



   .. py:method:: load_prov_doc() -> Optional[hermes.model.provenance.ld_prov.ld_prov_list]

      Loads the provenance document of the curate step.

      :returns: The loaded provenance document or None if the load failed.
      :rtype: ld_prov_list | None



