hermes.commands.process.base

Attributes

TypeIRI

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

PropertyStrategies

Type description for mapping PropertyTypeIRIs to MergeActions

ObjectStrategies

Type description for mapping ObjectTypeIRIs to PropertyStrategies

Classes

HermesProcessPlugin

Base plugin that defines additional merge strategies.

ProcessSettings

Generic deposition settings.

HermesProcessCommand

Process the collected metadata into a common dataset.

Module Contents

type hermes.commands.process.base.TypeIRI = str | None

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

type hermes.commands.process.base.PropertyStrategies = dict[TypeIRI, MergeAction]

Type description for mapping PropertyTypeIRIs to MergeActions

type hermes.commands.process.base.ObjectStrategies = dict[TypeIRI, PropertyStrategies]

Type description for mapping ObjectTypeIRIs to PropertyStrategies

class hermes.commands.process.base.HermesProcessPlugin

Bases: hermes.commands.base.HermesPlugin

Base plugin that defines additional merge strategies.

__call__(command: HermesProcessCommand) dict[str | None, dict[str | None, hermes.model.merge.action.MergeAction]]

Execute the hermes process plugin self.

Parameters:

command (HermesProcessCommand) – The command being executed.

Returns:

The merge strategies.

Return type:

dict[str | None, dict[str | None, MergeAction]]

class hermes.commands.process.base.ProcessSettings(/, **data: Any)

Bases: pydantic.BaseModel

Generic deposition settings.

sources

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

Type:

list[str]

plugins

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

Type:

list[str]

class hermes.commands.process.base.HermesProcessCommand(parser: argparse.ArgumentParser)

Bases: hermes.commands.base.HermesCommand

Process the collected metadata into a common dataset.

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

Type:

type

__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:
add_strategies_to_merge_doc(merge_doc: hermes.model.merge.container.ld_merge_dict, prov_doc: hermes.model.provenance.ld_prov.ld_prov_list | None) tuple[hermes.model.types.ld_dict | None, hermes.model.types.ld_dict | None]

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

Parameters:
  • merge_doc (ld_merge_dict) – The merge_doc the strategies are to be added to.

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

Returns:

The object of the last merge of strategies and the object of the

merged strategies.

Return type:

tuple[ld_dict | None, ld_dict | None]

Raises:

HermesPluginRunError – If all plugin runs failed.

merge_data_from_harvesters(merge_doc: hermes.model.merge.container.ld_merge_dict, harvester_names: list[str], prov_doc: hermes.model.provenance.ld_prov.ld_prov_list | None, strategy_action: hermes.model.types.ld_dict | None, merged_strategies: hermes.model.types.ld_dict | None) tuple[hermes.model.types.ld_dict | None, hermes.model.types.ld_dict | None]

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

Parameters:
  • merge_doc (ld_merge_dict) – The merge_doc the strategies are to be added to.

  • harvester_names (list[str]) – The harvesters whoose data is to be loaded and merged.

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

  • strategy_action (ld_dict | None) – The last action merging strategies (prov object).

  • merged_strategies (ld_dict | None) – The result of the strategy merges (prov object).

Returns:

The object of the last merge and the object of the merged data.

Return type:

tuple[ld_dict | None, ld_dict | None]

Raises:
  • RuntimeError – If a merge failed.

  • RuntimeError – If data from all harvesters couldn’t be loaded.

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

Loads the provenance document of the harvest step.

Returns:

The loaded provenance document or None if the load failed.

Return type:

ld_prov_list | None