hermes.commands.process.base
============================

.. py:module:: hermes.commands.process.base


Attributes
----------

.. autoapisummary::

   hermes.commands.process.base.TypeIRI
   hermes.commands.process.base.PropertyStrategies
   hermes.commands.process.base.ObjectStrategies


Classes
-------

.. autoapisummary::

   hermes.commands.process.base.HermesProcessPlugin
   hermes.commands.process.base.ProcessSettings
   hermes.commands.process.base.HermesProcessCommand


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

.. py:type:: TypeIRI
   :canonical: Union[str, None]


   Type description for the iri of a JSON-LD property or object type (or None indicating a 'joker')

.. py:type:: PropertyStrategies
   :canonical: dict[TypeIRI, MergeAction]


   Type description for mapping PropertyTypeIRIs to MergeActions

.. py:type:: ObjectStrategies
   :canonical: dict[TypeIRI, PropertyStrategies]


   Type description for mapping ObjectTypeIRIs to PropertyStrategies

.. py:class:: HermesProcessPlugin

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


   Base plugin that defines additional merge strategies.


   .. py:method:: __call__(command: HermesProcessCommand) -> dict[Optional[str], dict[Optional[str], hermes.model.merge.action.MergeAction]]

      Execute the hermes process plugin `self`.

      :param command: The command being executed.
      :type command: HermesProcessCommand

      :returns: The merge strategies.
      :rtype: dict[str | None, dict[str | None, MergeAction]]



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

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


   Generic deposition settings.

   .. attribute:: sources

      (class attribute) A list of harvest plugins whoose results should be processed.

      :type: list[str]

   .. attribute:: plugins

      (class attribute) A list of plugins to be executed.

      :type: list[str]


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

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


   Process the collected metadata into a common dataset.

   .. 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 process settings.

      :type: type


   .. 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 it was explicitly configured that no process plugin should be run.
      :raises MisconfigurationError: If no harvesters have been configured to be used.



   .. py:method:: add_strategies_to_merge_doc(merge_doc: hermes.model.merge.container.ld_merge_dict, prov_doc: Optional[hermes.model.provenance.ld_prov.ld_prov_list]) -> tuple[Optional[hermes.model.types.ld_dict], Optional[hermes.model.types.ld_dict]]

      Adds strategies to the merge doc that are generated by the process plugins and add provenance information to the
      prov_doc.

      :param merge_doc: The merge_doc the strategies are to be added to.
      :type merge_doc: ld_merge_dict
      :param prov_doc: The provenance document where the information is to be recorded.
      :type prov_doc: ld_prov_list | None

      :returns:

                The object of the last merge of strategies and the object of the
                    merged strategies.
      :rtype: tuple[ld_dict | None, ld_dict | None]

      :raises HermesPluginRunError: If all plugin runs failed.



   .. py:method:: merge_data_from_harvesters(merge_doc: hermes.model.merge.container.ld_merge_dict, harvester_names: list[str], prov_doc: Optional[hermes.model.provenance.ld_prov.ld_prov_list], strategy_action: Optional[hermes.model.types.ld_dict], merged_strategies: Optional[hermes.model.types.ld_dict]) -> tuple[Optional[hermes.model.types.ld_dict], Optional[hermes.model.types.ld_dict]]

      Load data from the harvest plugins and merge it and then add provenance information to the prov_doc.

      :param merge_doc: The merge_doc the strategies are to be added to.
      :type merge_doc: ld_merge_dict
      :param harvester_names: The harvesters whoose data is to be loaded and merged.
      :type harvester_names: list[str]
      :param prov_doc: The provenance document where the information is to be recorded.
      :type prov_doc: ld_prov_list | None
      :param strategy_action: The last action merging strategies (prov object).
      :type strategy_action: ld_dict | None
      :param merged_strategies: The result of the strategy merges (prov object).
      :type merged_strategies: ld_dict | None

      :returns: The object of the last merge and the object of the merged data.
      :rtype: tuple[ld_dict | None, ld_dict | None]

      :raises RuntimeError: If a merge failed.
      :raises RuntimeError: If data from all harvesters couldn't be loaded.



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

      Loads the provenance document of the harvest step.

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



