1010from pydantic import BaseModel
1111
1212from hermes .commands .base import HermesCommand , HermesPlugin
13- from hermes .error import HermesPluginRunError
13+ from hermes .error import HermesPluginRunError , MisconfigurationError
1414from hermes .model .api import SoftwareMetadata
1515from hermes .model .context_manager import HermesContext
1616from hermes .model .merge .action import MergeAction
@@ -39,9 +39,21 @@ class HermesProcessCommand(HermesCommand):
3939
4040 def __call__ (self , args : argparse .Namespace ) -> None :
4141 self .log .info ("# Metadata processing" )
42- self .args = args
4342 merged_doc = ld_merge_dict ([{}])
4443
44+ if not self .settings .plugins :
45+ self .log .critical (
46+ "# It was explicitly configured that no process plugin should be used."
47+ " Hint: Do not configure anything to use standard 'codemeta' plugin."
48+ )
49+ raise MisconfigurationError ("Explicit configuration to use no process plugin." )
50+
51+ # Get all harvesters
52+ harvester_names = self .settings .sources if self .settings .sources else self .root_settings .harvest .sources
53+ if not harvester_names :
54+ self .log .critical ("# No harvesters to merge from were configured." )
55+ raise MisconfigurationError ("No harvesters to merge from were configured." )
56+
4557 self .log .info ("## Load and run the plugins" )
4658 any_strategies_loaded = False
4759 # add the strategies from the plugins
@@ -51,15 +63,15 @@ def __call__(self, args: argparse.Namespace) -> None:
5163 try :
5264 plugin_func = self .plugins [plugin_name ]()
5365 except KeyError :
54- self .log .warning (f"Plugin { plugin_name } not found, skipping it now." )
66+ self .log .error (f"### Plugin { plugin_name } not found, skipping it now." )
5567 continue
5668
5769 self .log .info (f"### Run { plugin_name } plugin" )
5870 # run plugin
5971 try :
6072 additional_strategies = plugin_func (self )
6173 except Exception :
62- self .log .warning (f"Unknown error while executing the { plugin_name } plugin, skipping it now." )
74+ self .log .exception (f"### Unknown error while executing the { plugin_name } plugin, skipping it now." )
6375 continue
6476
6577 self .log .info (f"### Add the strategies to the merge document { plugin_name } plugin" )
@@ -68,44 +80,39 @@ def __call__(self, args: argparse.Namespace) -> None:
6880 any_strategies_loaded = True
6981
7082 if not any_strategies_loaded :
71- self .log .error ( " No process plugin was ran successfully." )
72- raise RuntimeError ("No process plugin was ran successfully." )
83+ self .log .critical ( "## No process plugin was ran successfully." )
84+ raise HermesPluginRunError ("No process plugin was ran successfully." )
7385
7486 ctx = HermesContext ()
7587 ctx .prepare_step ('harvest' )
7688
89+ # merge data from harvesters
7790 self .log .info ("## Merge the metadata of the harvesters" )
78- # Get all harvesters
79- harvester_names = self .settings .sources if self .settings .sources else self .root_settings .harvest .sources
8091 merged_any = False
8192 for harvester in harvester_names :
82- self .log .info (f"## Load data from { harvester } plugin" )
93+ self .log .info (f"### Load data from { harvester } plugin" )
8394 # load data from harvester
8495 try :
8596 metadata = SoftwareMetadata .load_from_cache (ctx , harvester )
8697 except Exception :
8798 # skip this harvester when the data is invalid
88- self .log .warning (f"The data from the harvester { harvester } could not be loaded or is invalid." )
89- self .log .info (f"## Aborting merge for { harvester } " )
99+ self .log .exception (
100+ f"### The data from the harvester { harvester } could not be loaded or is invalid, skipping it now."
101+ )
90102 continue
91103
92- self .log .info (f"## Merge data from { harvester } plugin" )
104+ self .log .info (f"### Merge data from { harvester } plugin" )
93105 # merge data into the merge dict
94106 try :
95107 merged_doc .update (metadata )
96108 except Exception as e :
97- self .log .error (f"Merging the data from { harvester } plugin resulted in an error." )
98- raise HermesPluginRunError (f"Merging the data from { harvester } plugin failed." ) from e
109+ self .log .critical (f"### Merging the data from { harvester } plugin resulted in an error." , exc_info = True )
110+ raise RuntimeError (f"Merging the data from { harvester } plugin failed." ) from e
99111 merged_any = True
100112
101113 # error if nothing was merged
102- if harvester_names and not merged_any :
103- self .log .error (
104- f"""No metadata has been merged. {
105- "No harvesters to merge from were supplied" if not harvester_names else
106- "The merging failed for all harvesters."
107- } """
108- )
114+ if not merged_any :
115+ self .log .critical ("No metadata has been merged, the loading of the data failed for all harvesters." )
109116 raise RuntimeError ("No metadata has been merged." )
110117
111118 self .log .info ("## Store processed metadata" )
0 commit comments