hermes.model.provenance.ld_prov
===============================

.. py:module:: hermes.model.provenance.ld_prov


Classes
-------

.. autoapisummary::

   hermes.model.provenance.ld_prov.ld_prov_list


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

.. py:class:: ld_prov_list(data: hermes.model.types.ld_container.EXPANDED_JSON_LD_VALUE = [{'@graph': []}], *, parent: Optional[Union[hermes.model.types.ld_dict, hermes.model.types.ld_list]] = None, key: Optional[str] = PROV_DOC_IRI, index: Optional[int] = None, context: Optional[list[Union[str, hermes.model.types.ld_container.JSON_LD_CONTEXT_DICT]]] = ALL_CONTEXTS)

   Bases: :py:obj:`hermes.model.types.ld_list`


   ld_list with special features for internal provenance collection.

   .. attribute:: NODE_IRI_FORMAT

      (class attribute) The id format of normal nodes.

      :type: str

   .. attribute:: HERMES_ID

      (class attribute) The id of the hermes agent.

      :type: str

   .. attribute:: HERMES_CACHE_ID

      (class attribute) The id of the hermes cache.

      :type: str

   .. attribute:: HERMES_COMMAND_ID_FORMAT

      (class attribute) The id format of hermes commands.

      :type: str

   .. attribute:: HERMES_PLUGIN_ID_FORMAT

      (class attribute) The id format of hermes plugins.

      :type: str

   .. attribute:: HERMES_BASE_PLUGIN_ID_FORMAT

      (class attribute) The id format of hermes base plugins.

      :type: str

   .. attribute:: PROV_DOC_IRI

      (class attribute) The JSON-LD type of the prov_doc itself.

      :type: str

   .. attribute:: INDICES

      (class attribute) The counters of the different types of nodes.

      :type: dict[str, int]


   .. py:method:: load_ld_prov_list(data: hermes.model.types.ld_container.EXPANDED_JSON_LD_VALUE) -> ld_prov_list
      :classmethod:


      Create a new instance of an ld_merge_dict. See also :meth:`ld_dict.__init__`.

      :param data: The expanded json-ld data from which an ld_prov_list is restored.
      :type data: EXPANDED_JSON_LD_VALUE

      :returns: The ld_prov_list loaded from the provided data.
      :rtype: ld_prov_list

      :raises RuntimeError: If an ld_prov_list has/ had been loaded before.



   .. py:method:: next_node_iri(type: str) -> str

      Create an iri for a new node of the given type.

      :param type: The type of the new node
      :type type: str

      :returns: The generated iri.
      :rtype: str



   .. py:method:: add_activity(*, data: hermes.model.types.ld_container.JSON_LD_VALUE = {}) -> hermes.model.types.ld_dict

      Add a new provenance activity to the ld_prov_list using the provided additional data.

      Hint: If no id was specified, one will be generated. Additionaly the types 'prov:Activity' and
      'schema:Action' will be added.

      :param data: The additional data for the activity.
      :type data: JSON_LD_VALUE

      :returns: The provenance activity as an ld_dict (can be used to update the data in the ld_prov_list).
      :rtype: ld_dict



   .. py:method:: add_agent(*, data: hermes.model.types.ld_container.JSON_LD_VALUE = {}) -> hermes.model.types.ld_dict

      Add a new provenance agent to the ld_prov_list using the provided additional data.

      Hint: If no id was specified, one will be generated. Additionaly the types 'prov:Agent' and
      'schema:SoftwareApplication' will be added.

      :param data: The additional data for the agent.
      :type data: JSON_LD_VALUE

      :returns: The provenance agent as an ld_dict (can be used to update the data in the ld_prov_list).
      :rtype: ld_dict



   .. py:method:: add_entity(*, data: hermes.model.types.ld_container.JSON_LD_VALUE = {}) -> hermes.model.types.ld_dict

      Add a new provenance entity to the ld_prov_list using the provided additional data.

      Hint: If no id was specified, one will be generated. Additionaly the types 'prov:Entity' and
      'schema:Thing' will be added.

      :param data: The additional data for the entity.
      :type data: JSON_LD_VALUE

      :returns: The provenance entity as an ld_dict (can be used to update the data in the ld_prov_list).
      :rtype: ld_dict



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

      Initialize the hermes agents for provenance collection.

      :rtype: None



   .. py:method:: add_hermes_settings(command: hermes.commands.base.HermesCommand) -> None

      Add general settings of a hermes command run from the command object.

      :param command: The command object containing information on the run.
      :type command: HermesCommand

      :rtype: None



   .. py:method:: add_settings_to_command(step: str, command: hermes.commands.base.HermesCommand) -> None

      Add settings specific to the ran command from the command object.
      :meth:`ld_prov_list.add_hermes_settings` must be run before this function.

      :param step: The step of the settings should be recorded for.
      :type step: str
      :param command: The command object containing information on the run.
      :type command: HermesCommand

      :rtype: None



   .. py:method:: add_hermes_plugin(step: str, name: str, plugin: hermes.commands.base.HermesPlugin, command: hermes.commands.base.HermesCommand) -> hermes.model.types.ld_dict

      Add a new hermes plugin to the ld_prov_list using the provided additional data.

      :param step: The step of the plugin.
      :type step: str
      :param name: The name of the plugin.
      :type name: str
      :param plugin: The object of the plugin that will be executed.
      :type plugin: HermesPlugin
      :param command: The command object containing information on the run.
      :type command: HermesCommand

      :returns: The provenance entity of the plugin (can be used to update the data in the ld_prov_list).
      :rtype: ld_dict



   .. py:method:: shallow_search(query: Callable[[hermes.model.types.ld_dict], Any]) -> list[hermes.model.types.ld_dict]

      Search the objects in the ld_prov_list for objects for which the query evaluates to True.

      :param query: The query used for evaluating the objects.
      :type query: Callable[[ld_dict], Any]

      :returns: The objects in the ld_prov_list for which `query` evalutes to True.
      :rtype: list[ld_dict]



   .. py:method:: get_hermes() -> hermes.model.types.ld_dict

      Returns the hermes agent in the ld_prov_list.

      :returns: The object representing the hermes agent.
      :rtype: ld_dict



   .. py:method:: get_hermes_cache() -> hermes.model.types.ld_dict

      Returns the hermes cache agent in the ld_prov_list.

      :returns: The object representing the hermes cache agent.
      :rtype: ld_dict



   .. py:method:: get_hermes_base_plugin(step: str) -> hermes.model.types.ld_dict

      Returns the base plugin agent in the ld_prov_list of the given step.

      :param step: The step of which the base plugin agent should be returned.
      :type step: str

      :returns: The object representing the base plugin agent of the given step.
      :rtype: ld_dict



   .. py:method:: get_hermes_plugin(step: str, name: str) -> Union[hermes.model.types.ld_dict, None]

      Returns the plugin agent in the ld_prov_list of the given step with the given name.

      :param step: The step of which the plugin agent should be returned.
      :type step: str
      :param name: The name of the plugin agent that should be returned.
      :type name: str

      :returns: The object representing the plugin agent of the given step with the given name.
      :rtype: ld_dict | None



   .. py:method:: get_hermes_command(step) -> hermes.model.types.ld_dict

      Returns the hermes command agent in the ld_prov_list of the given step.

      :param step: The step of which the hermes command agent should be returned.
      :type step: str

      :returns: The object representing the hermes command agent of the given step.
      :rtype: ld_dict



