amd-node-scraper 0.0.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (197) hide show
  1. amd_node_scraper-0.0.1.dist-info/LICENSE +21 -0
  2. amd_node_scraper-0.0.1.dist-info/METADATA +424 -0
  3. amd_node_scraper-0.0.1.dist-info/RECORD +197 -0
  4. amd_node_scraper-0.0.1.dist-info/WHEEL +5 -0
  5. amd_node_scraper-0.0.1.dist-info/entry_points.txt +2 -0
  6. amd_node_scraper-0.0.1.dist-info/top_level.txt +1 -0
  7. nodescraper/__init__.py +32 -0
  8. nodescraper/base/__init__.py +34 -0
  9. nodescraper/base/inbandcollectortask.py +118 -0
  10. nodescraper/base/inbanddataplugin.py +39 -0
  11. nodescraper/base/regexanalyzer.py +120 -0
  12. nodescraper/cli/__init__.py +29 -0
  13. nodescraper/cli/cli.py +511 -0
  14. nodescraper/cli/constants.py +27 -0
  15. nodescraper/cli/dynamicparserbuilder.py +171 -0
  16. nodescraper/cli/helper.py +517 -0
  17. nodescraper/cli/inputargtypes.py +129 -0
  18. nodescraper/configbuilder.py +123 -0
  19. nodescraper/configregistry.py +66 -0
  20. nodescraper/configs/node_status.json +19 -0
  21. nodescraper/connection/__init__.py +25 -0
  22. nodescraper/connection/inband/__init__.py +46 -0
  23. nodescraper/connection/inband/inband.py +171 -0
  24. nodescraper/connection/inband/inbandlocal.py +93 -0
  25. nodescraper/connection/inband/inbandmanager.py +151 -0
  26. nodescraper/connection/inband/inbandremote.py +173 -0
  27. nodescraper/connection/inband/sshparams.py +43 -0
  28. nodescraper/constants.py +26 -0
  29. nodescraper/enums/__init__.py +40 -0
  30. nodescraper/enums/eventcategory.py +89 -0
  31. nodescraper/enums/eventpriority.py +42 -0
  32. nodescraper/enums/executionstatus.py +44 -0
  33. nodescraper/enums/osfamily.py +34 -0
  34. nodescraper/enums/systeminteraction.py +41 -0
  35. nodescraper/enums/systemlocation.py +33 -0
  36. nodescraper/generictypes.py +36 -0
  37. nodescraper/interfaces/__init__.py +44 -0
  38. nodescraper/interfaces/connectionmanager.py +143 -0
  39. nodescraper/interfaces/dataanalyzertask.py +138 -0
  40. nodescraper/interfaces/datacollectortask.py +185 -0
  41. nodescraper/interfaces/dataplugin.py +356 -0
  42. nodescraper/interfaces/plugin.py +127 -0
  43. nodescraper/interfaces/resultcollator.py +56 -0
  44. nodescraper/interfaces/task.py +164 -0
  45. nodescraper/interfaces/taskresulthook.py +39 -0
  46. nodescraper/models/__init__.py +48 -0
  47. nodescraper/models/analyzerargs.py +93 -0
  48. nodescraper/models/collectorargs.py +30 -0
  49. nodescraper/models/connectionconfig.py +34 -0
  50. nodescraper/models/datamodel.py +171 -0
  51. nodescraper/models/datapluginresult.py +39 -0
  52. nodescraper/models/event.py +158 -0
  53. nodescraper/models/pluginconfig.py +38 -0
  54. nodescraper/models/pluginresult.py +39 -0
  55. nodescraper/models/systeminfo.py +44 -0
  56. nodescraper/models/taskresult.py +185 -0
  57. nodescraper/models/timerangeargs.py +38 -0
  58. nodescraper/pluginexecutor.py +274 -0
  59. nodescraper/pluginregistry.py +152 -0
  60. nodescraper/plugins/__init__.py +25 -0
  61. nodescraper/plugins/inband/__init__.py +25 -0
  62. nodescraper/plugins/inband/amdsmi/__init__.py +28 -0
  63. nodescraper/plugins/inband/amdsmi/amdsmi_analyzer.py +821 -0
  64. nodescraper/plugins/inband/amdsmi/amdsmi_collector.py +1313 -0
  65. nodescraper/plugins/inband/amdsmi/amdsmi_plugin.py +43 -0
  66. nodescraper/plugins/inband/amdsmi/amdsmidata.py +1002 -0
  67. nodescraper/plugins/inband/amdsmi/analyzer_args.py +50 -0
  68. nodescraper/plugins/inband/amdsmi/cper.py +65 -0
  69. nodescraper/plugins/inband/bios/__init__.py +29 -0
  70. nodescraper/plugins/inband/bios/analyzer_args.py +64 -0
  71. nodescraper/plugins/inband/bios/bios_analyzer.py +93 -0
  72. nodescraper/plugins/inband/bios/bios_collector.py +93 -0
  73. nodescraper/plugins/inband/bios/bios_plugin.py +43 -0
  74. nodescraper/plugins/inband/bios/biosdata.py +30 -0
  75. nodescraper/plugins/inband/cmdline/__init__.py +25 -0
  76. nodescraper/plugins/inband/cmdline/analyzer_args.py +80 -0
  77. nodescraper/plugins/inband/cmdline/cmdline_analyzer.py +113 -0
  78. nodescraper/plugins/inband/cmdline/cmdline_collector.py +77 -0
  79. nodescraper/plugins/inband/cmdline/cmdline_plugin.py +43 -0
  80. nodescraper/plugins/inband/cmdline/cmdlinedata.py +30 -0
  81. nodescraper/plugins/inband/device_enumeration/__init__.py +29 -0
  82. nodescraper/plugins/inband/device_enumeration/analyzer_args.py +73 -0
  83. nodescraper/plugins/inband/device_enumeration/device_enumeration_analyzer.py +81 -0
  84. nodescraper/plugins/inband/device_enumeration/device_enumeration_collector.py +176 -0
  85. nodescraper/plugins/inband/device_enumeration/device_enumeration_plugin.py +45 -0
  86. nodescraper/plugins/inband/device_enumeration/deviceenumdata.py +36 -0
  87. nodescraper/plugins/inband/dimm/__init__.py +25 -0
  88. nodescraper/plugins/inband/dimm/collector_args.py +31 -0
  89. nodescraper/plugins/inband/dimm/dimm_collector.py +151 -0
  90. nodescraper/plugins/inband/dimm/dimm_plugin.py +40 -0
  91. nodescraper/plugins/inband/dimm/dimmdata.py +30 -0
  92. nodescraper/plugins/inband/dkms/__init__.py +25 -0
  93. nodescraper/plugins/inband/dkms/analyzer_args.py +85 -0
  94. nodescraper/plugins/inband/dkms/dkms_analyzer.py +106 -0
  95. nodescraper/plugins/inband/dkms/dkms_collector.py +76 -0
  96. nodescraper/plugins/inband/dkms/dkms_plugin.py +43 -0
  97. nodescraper/plugins/inband/dkms/dkmsdata.py +33 -0
  98. nodescraper/plugins/inband/dmesg/__init__.py +28 -0
  99. nodescraper/plugins/inband/dmesg/analyzer_args.py +33 -0
  100. nodescraper/plugins/inband/dmesg/collector_args.py +39 -0
  101. nodescraper/plugins/inband/dmesg/dmesg_analyzer.py +503 -0
  102. nodescraper/plugins/inband/dmesg/dmesg_collector.py +164 -0
  103. nodescraper/plugins/inband/dmesg/dmesg_plugin.py +44 -0
  104. nodescraper/plugins/inband/dmesg/dmesgdata.py +116 -0
  105. nodescraper/plugins/inband/fabrics/__init__.py +28 -0
  106. nodescraper/plugins/inband/fabrics/fabrics_collector.py +726 -0
  107. nodescraper/plugins/inband/fabrics/fabrics_plugin.py +37 -0
  108. nodescraper/plugins/inband/fabrics/fabricsdata.py +140 -0
  109. nodescraper/plugins/inband/journal/__init__.py +28 -0
  110. nodescraper/plugins/inband/journal/collector_args.py +33 -0
  111. nodescraper/plugins/inband/journal/journal_collector.py +107 -0
  112. nodescraper/plugins/inband/journal/journal_plugin.py +40 -0
  113. nodescraper/plugins/inband/journal/journaldata.py +44 -0
  114. nodescraper/plugins/inband/kernel/__init__.py +25 -0
  115. nodescraper/plugins/inband/kernel/analyzer_args.py +64 -0
  116. nodescraper/plugins/inband/kernel/kernel_analyzer.py +91 -0
  117. nodescraper/plugins/inband/kernel/kernel_collector.py +129 -0
  118. nodescraper/plugins/inband/kernel/kernel_plugin.py +43 -0
  119. nodescraper/plugins/inband/kernel/kerneldata.py +32 -0
  120. nodescraper/plugins/inband/kernel_module/__init__.py +25 -0
  121. nodescraper/plugins/inband/kernel_module/analyzer_args.py +59 -0
  122. nodescraper/plugins/inband/kernel_module/kernel_module_analyzer.py +211 -0
  123. nodescraper/plugins/inband/kernel_module/kernel_module_collector.py +264 -0
  124. nodescraper/plugins/inband/kernel_module/kernel_module_data.py +60 -0
  125. nodescraper/plugins/inband/kernel_module/kernel_module_plugin.py +43 -0
  126. nodescraper/plugins/inband/memory/__init__.py +25 -0
  127. nodescraper/plugins/inband/memory/analyzer_args.py +45 -0
  128. nodescraper/plugins/inband/memory/memory_analyzer.py +98 -0
  129. nodescraper/plugins/inband/memory/memory_collector.py +330 -0
  130. nodescraper/plugins/inband/memory/memory_plugin.py +43 -0
  131. nodescraper/plugins/inband/memory/memorydata.py +90 -0
  132. nodescraper/plugins/inband/network/__init__.py +28 -0
  133. nodescraper/plugins/inband/network/network_collector.py +1828 -0
  134. nodescraper/plugins/inband/network/network_plugin.py +37 -0
  135. nodescraper/plugins/inband/network/networkdata.py +319 -0
  136. nodescraper/plugins/inband/nvme/__init__.py +28 -0
  137. nodescraper/plugins/inband/nvme/nvme_collector.py +167 -0
  138. nodescraper/plugins/inband/nvme/nvme_plugin.py +37 -0
  139. nodescraper/plugins/inband/nvme/nvmedata.py +45 -0
  140. nodescraper/plugins/inband/os/__init__.py +25 -0
  141. nodescraper/plugins/inband/os/analyzer_args.py +64 -0
  142. nodescraper/plugins/inband/os/os_analyzer.py +73 -0
  143. nodescraper/plugins/inband/os/os_collector.py +131 -0
  144. nodescraper/plugins/inband/os/os_plugin.py +43 -0
  145. nodescraper/plugins/inband/os/osdata.py +31 -0
  146. nodescraper/plugins/inband/package/__init__.py +25 -0
  147. nodescraper/plugins/inband/package/analyzer_args.py +48 -0
  148. nodescraper/plugins/inband/package/package_analyzer.py +253 -0
  149. nodescraper/plugins/inband/package/package_collector.py +273 -0
  150. nodescraper/plugins/inband/package/package_plugin.py +43 -0
  151. nodescraper/plugins/inband/package/packagedata.py +41 -0
  152. nodescraper/plugins/inband/pcie/__init__.py +29 -0
  153. nodescraper/plugins/inband/pcie/analyzer_args.py +63 -0
  154. nodescraper/plugins/inband/pcie/pcie_analyzer.py +1081 -0
  155. nodescraper/plugins/inband/pcie/pcie_collector.py +690 -0
  156. nodescraper/plugins/inband/pcie/pcie_data.py +2017 -0
  157. nodescraper/plugins/inband/pcie/pcie_plugin.py +43 -0
  158. nodescraper/plugins/inband/process/__init__.py +25 -0
  159. nodescraper/plugins/inband/process/analyzer_args.py +45 -0
  160. nodescraper/plugins/inband/process/collector_args.py +31 -0
  161. nodescraper/plugins/inband/process/process_analyzer.py +91 -0
  162. nodescraper/plugins/inband/process/process_collector.py +115 -0
  163. nodescraper/plugins/inband/process/process_plugin.py +46 -0
  164. nodescraper/plugins/inband/process/processdata.py +34 -0
  165. nodescraper/plugins/inband/rocm/__init__.py +25 -0
  166. nodescraper/plugins/inband/rocm/analyzer_args.py +66 -0
  167. nodescraper/plugins/inband/rocm/rocm_analyzer.py +100 -0
  168. nodescraper/plugins/inband/rocm/rocm_collector.py +205 -0
  169. nodescraper/plugins/inband/rocm/rocm_plugin.py +43 -0
  170. nodescraper/plugins/inband/rocm/rocmdata.py +62 -0
  171. nodescraper/plugins/inband/storage/__init__.py +25 -0
  172. nodescraper/plugins/inband/storage/analyzer_args.py +38 -0
  173. nodescraper/plugins/inband/storage/collector_args.py +31 -0
  174. nodescraper/plugins/inband/storage/storage_analyzer.py +152 -0
  175. nodescraper/plugins/inband/storage/storage_collector.py +110 -0
  176. nodescraper/plugins/inband/storage/storage_plugin.py +44 -0
  177. nodescraper/plugins/inband/storage/storagedata.py +70 -0
  178. nodescraper/plugins/inband/sysctl/__init__.py +29 -0
  179. nodescraper/plugins/inband/sysctl/analyzer_args.py +67 -0
  180. nodescraper/plugins/inband/sysctl/sysctl_analyzer.py +81 -0
  181. nodescraper/plugins/inband/sysctl/sysctl_collector.py +101 -0
  182. nodescraper/plugins/inband/sysctl/sysctl_plugin.py +43 -0
  183. nodescraper/plugins/inband/sysctl/sysctldata.py +42 -0
  184. nodescraper/plugins/inband/syslog/__init__.py +28 -0
  185. nodescraper/plugins/inband/syslog/syslog_collector.py +121 -0
  186. nodescraper/plugins/inband/syslog/syslog_plugin.py +37 -0
  187. nodescraper/plugins/inband/syslog/syslogdata.py +46 -0
  188. nodescraper/plugins/inband/uptime/__init__.py +25 -0
  189. nodescraper/plugins/inband/uptime/uptime_collector.py +88 -0
  190. nodescraper/plugins/inband/uptime/uptime_plugin.py +37 -0
  191. nodescraper/plugins/inband/uptime/uptimedata.py +31 -0
  192. nodescraper/resultcollators/__init__.py +25 -0
  193. nodescraper/resultcollators/tablesummary.py +159 -0
  194. nodescraper/taskresulthooks/__init__.py +28 -0
  195. nodescraper/taskresulthooks/filesystemloghook.py +88 -0
  196. nodescraper/typeutils.py +171 -0
  197. nodescraper/utils.py +412 -0
@@ -0,0 +1,274 @@
1
+ ###############################################################################
2
+ #
3
+ # MIT License
4
+ #
5
+ # Copyright (c) 2025 Advanced Micro Devices, Inc.
6
+ #
7
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ # of this software and associated documentation files (the "Software"), to deal
9
+ # in the Software without restriction, including without limitation the rights
10
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ # copies of the Software, and to permit persons to whom the Software is
12
+ # furnished to do so, subject to the following conditions:
13
+ #
14
+ # The above copyright notice and this permission notice shall be included in all
15
+ # copies or substantial portions of the Software.
16
+ #
17
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ # SOFTWARE.
24
+ #
25
+ ###############################################################################
26
+ from __future__ import annotations
27
+
28
+ import copy
29
+ import logging
30
+ from collections import deque
31
+ from typing import Optional, Type, Union
32
+
33
+ from pydantic import BaseModel
34
+
35
+ from nodescraper.constants import DEFAULT_LOGGER
36
+ from nodescraper.interfaces import ConnectionManager, DataPlugin, PluginInterface
37
+ from nodescraper.models import PluginConfig, SystemInfo
38
+ from nodescraper.models.pluginresult import PluginResult
39
+ from nodescraper.pluginregistry import PluginRegistry
40
+ from nodescraper.taskresulthooks import FileSystemLogHook
41
+ from nodescraper.typeutils import TypeUtils
42
+
43
+
44
+ class PluginExecutor:
45
+ """Class to manage execution of data collectors and error detectors"""
46
+
47
+ def __init__(
48
+ self,
49
+ plugin_configs: list[PluginConfig],
50
+ connections: Optional[dict[str, Union[dict, BaseModel]]] = None,
51
+ system_info: Optional[SystemInfo] = None,
52
+ logger: Optional[logging.Logger] = None,
53
+ plugin_registry: Optional[PluginRegistry] = None,
54
+ log_path: Optional[str] = None,
55
+ ):
56
+
57
+ if logger is None:
58
+ logger = logging.getLogger(DEFAULT_LOGGER)
59
+ self.logger = logger
60
+
61
+ self.plugin_registry = plugin_registry or PluginRegistry()
62
+
63
+ if system_info is None:
64
+ system_info = SystemInfo()
65
+ self.system_info = system_info
66
+
67
+ self.plugin_config = self.merge_configs(plugin_configs)
68
+
69
+ self.connection_library: dict[type[ConnectionManager], ConnectionManager] = {}
70
+
71
+ self.log_path = log_path
72
+
73
+ self.connection_result_hooks = []
74
+ if log_path:
75
+ self.connection_result_hooks.append(FileSystemLogHook(log_base_path=log_path))
76
+
77
+ if connections:
78
+ for connection, connection_args in connections.items():
79
+ if connection not in self.plugin_registry.connection_managers:
80
+ self.logger.error(
81
+ "Unable to find registered connection manager class for %s", connection
82
+ )
83
+ continue
84
+
85
+ connection_manager = self.plugin_registry.connection_managers[connection]
86
+
87
+ self.connection_library[connection_manager] = connection_manager(
88
+ system_info=self.system_info,
89
+ logger=self.logger,
90
+ connection_args=connection_args,
91
+ task_result_hooks=self.connection_result_hooks,
92
+ )
93
+
94
+ self.logger.info("System Name: %s", self.system_info.name)
95
+ self.logger.info("System SKU: %s", self.system_info.sku)
96
+ self.logger.info("System Platform: %s", self.system_info.platform)
97
+ self.logger.info("System location: %s", self.system_info.location)
98
+
99
+ @staticmethod
100
+ def merge_configs(plugin_configs: list[PluginConfig]) -> PluginConfig:
101
+ merged_config = PluginConfig()
102
+ for config in plugin_configs:
103
+ merged_config.global_args.update(config.global_args)
104
+ merged_config.plugins.update(config.plugins)
105
+ merged_config.result_collators.update(config.result_collators)
106
+
107
+ return merged_config
108
+
109
+ def run_queue(self) -> list[PluginResult]:
110
+ """Run the plugin queue and return results
111
+
112
+ Returns:
113
+ list[PluginResult]: List of results from running the plugins in the queue
114
+ """
115
+ plugin_results = []
116
+ plugin_queue = deque(self.plugin_config.plugins.items())
117
+ try:
118
+ while len(plugin_queue) > 0:
119
+ plugin_name, plugin_args = plugin_queue.popleft()
120
+ if plugin_name not in self.plugin_registry.plugins:
121
+ self.logger.error("Unable to find registered plugin for name %s", plugin_name)
122
+ continue
123
+
124
+ plugin_class = self.plugin_registry.plugins[plugin_name]
125
+
126
+ init_payload = {
127
+ "system_info": self.system_info,
128
+ "logger": self.logger,
129
+ "queue_callback": plugin_queue.append,
130
+ "log_path": self.log_path,
131
+ }
132
+
133
+ if plugin_class.CONNECTION_TYPE:
134
+ connection_manager_class: Type[ConnectionManager] = plugin_class.CONNECTION_TYPE
135
+ if (
136
+ connection_manager_class.__name__
137
+ not in self.plugin_registry.connection_managers
138
+ ):
139
+ self.logger.error(
140
+ "Unable to find registered connection manager class for %s that is required by",
141
+ connection_manager_class.__name__,
142
+ )
143
+ continue
144
+
145
+ if connection_manager_class not in self.connection_library:
146
+ self.logger.info(
147
+ "Initializing connection manager for %s with default args",
148
+ connection_manager_class.__name__,
149
+ )
150
+ self.connection_library[connection_manager_class] = (
151
+ connection_manager_class(
152
+ system_info=self.system_info,
153
+ logger=self.logger,
154
+ task_result_hooks=self.connection_result_hooks,
155
+ )
156
+ )
157
+
158
+ init_payload["connection_manager"] = self.connection_library[
159
+ connection_manager_class
160
+ ]
161
+
162
+ try:
163
+ plugin_inst = plugin_class(**init_payload)
164
+
165
+ run_payload = copy.deepcopy(plugin_args)
166
+ run_args = TypeUtils.get_func_arg_types(plugin_class.run, plugin_class)
167
+
168
+ for arg in run_args.keys():
169
+ if arg == "preserve_connection" and issubclass(plugin_class, DataPlugin):
170
+ run_payload[arg] = True
171
+
172
+ try:
173
+ global_run_args = self.apply_global_args_to_plugin(
174
+ plugin_inst, plugin_class, self.plugin_config.global_args
175
+ )
176
+ # Merge analysis_args and collection_args
177
+ for args_key in ["analysis_args", "collection_args"]:
178
+ if args_key in global_run_args and args_key in run_payload:
179
+ # Merge: global args override plugin-specific args keys specified in both global and plugin-specific args
180
+ run_payload[args_key].update(global_run_args[args_key])
181
+ del global_run_args[args_key]
182
+ run_payload.update(global_run_args)
183
+ except ValueError as ve:
184
+ self.logger.error(
185
+ "Invalid global_args for plugin %s: %s. Skipping plugin.",
186
+ plugin_name,
187
+ str(ve),
188
+ )
189
+ continue
190
+
191
+ self.logger.info("-" * 50)
192
+ plugin_results.append(plugin_inst.run(**run_payload))
193
+ except Exception as e:
194
+ self.logger.exception(
195
+ "Unexpected exception when running plugin %s: %s", plugin_name, e
196
+ )
197
+ except Exception as e:
198
+ self.logger.exception("Unexpected exception running plugin queue: %s", str(e))
199
+ finally:
200
+ self.logger.info("Closing connections")
201
+
202
+ if self.plugin_config.result_collators:
203
+ self.logger.info("Running result collators")
204
+ for collator, collator_args in self.plugin_config.result_collators.items():
205
+ collator_class = self.plugin_registry.result_collators.get(collator)
206
+ if collator_class is None:
207
+ self.logger.warning(
208
+ "No result collator found in registry for name: %s", collator
209
+ )
210
+ continue
211
+
212
+ self.logger.info("Running %s result collator", collator)
213
+ collator_inst = collator_class(logger=self.logger, log_path=self.log_path)
214
+ collator_inst.collate_results(
215
+ plugin_results,
216
+ [
217
+ connection_manager.result
218
+ for connection_manager in self.connection_library.values()
219
+ ],
220
+ **collator_args,
221
+ )
222
+ for connection_manager in self.connection_library.values():
223
+ connection_manager.disconnect()
224
+
225
+ return plugin_results
226
+
227
+ def apply_global_args_to_plugin(
228
+ self,
229
+ plugin_inst: PluginInterface,
230
+ plugin_class: type,
231
+ global_args: dict,
232
+ ) -> dict:
233
+ """
234
+ Applies global arguments to the plugin instance, including standard attributes
235
+ and merging Pydantic model arguments (collection_args, analysis_args).
236
+
237
+ Args:
238
+ plugin_inst: The plugin instance to update.
239
+ plugin_class: The plugin class (needed for model instantiation).
240
+ global_args: Dict of global argument overrides.
241
+ """
242
+
243
+ run_args = {}
244
+ for key in global_args:
245
+ if key in ["collection_args", "analysis_args"] and isinstance(plugin_inst, DataPlugin):
246
+ continue
247
+ else:
248
+ run_args[key] = global_args[key]
249
+
250
+ if (
251
+ "collection_args" in global_args
252
+ and hasattr(plugin_class, "COLLECTOR_ARGS")
253
+ and plugin_class.COLLECTOR_ARGS is not None
254
+ ):
255
+
256
+ plugin_fields = set(plugin_class.COLLECTOR_ARGS.model_fields.keys())
257
+ filtered = {
258
+ k: v for k, v in global_args["collection_args"].items() if k in plugin_fields
259
+ }
260
+ if filtered:
261
+ run_args["collection_args"] = filtered
262
+
263
+ if (
264
+ "analysis_args" in global_args
265
+ and hasattr(plugin_class, "ANALYZER_ARGS")
266
+ and plugin_class.ANALYZER_ARGS is not None
267
+ ):
268
+
269
+ plugin_fields = set(plugin_class.ANALYZER_ARGS.model_fields.keys())
270
+ filtered = {k: v for k, v in global_args["analysis_args"].items() if k in plugin_fields}
271
+ if filtered:
272
+ run_args["analysis_args"] = filtered
273
+
274
+ return run_args
@@ -0,0 +1,152 @@
1
+ ###############################################################################
2
+ #
3
+ # MIT License
4
+ #
5
+ # Copyright (c) 2025 Advanced Micro Devices, Inc.
6
+ #
7
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ # of this software and associated documentation files (the "Software"), to deal
9
+ # in the Software without restriction, including without limitation the rights
10
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ # copies of the Software, and to permit persons to whom the Software is
12
+ # furnished to do so, subject to the following conditions:
13
+ #
14
+ # The above copyright notice and this permission notice shall be included in all
15
+ # copies or substantial portions of the Software.
16
+ #
17
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ # SOFTWARE.
24
+ #
25
+ ###############################################################################
26
+ import importlib
27
+ import importlib.metadata
28
+ import inspect
29
+ import pkgutil
30
+ import types
31
+ from typing import Optional
32
+
33
+ import nodescraper.connection as internal_connections
34
+ import nodescraper.plugins as internal_plugins
35
+ import nodescraper.resultcollators as internal_collators
36
+ from nodescraper.interfaces import (
37
+ ConnectionManager,
38
+ PluginInterface,
39
+ PluginResultCollator,
40
+ )
41
+
42
+
43
+ class PluginRegistry:
44
+
45
+ def __init__(
46
+ self,
47
+ plugin_pkg: Optional[list[types.ModuleType]] = None,
48
+ load_internal_plugins: bool = True,
49
+ load_entry_point_plugins: bool = True,
50
+ ) -> None:
51
+ """Initialize the PluginRegistry with optional plugin packages.
52
+
53
+ Args:
54
+ plugin_pkg (Optional[list[types.ModuleType]], optional): The module to search for plugins in. Defaults to None.
55
+ load_internal_plugins (bool, optional): Whether internal plugin should be loaded. Defaults to True.
56
+ load_entry_point_plugins (bool, optional): Whether to load plugins from entry points. Defaults to True.
57
+ """
58
+ if load_internal_plugins:
59
+ self.plugin_pkg = [internal_plugins, internal_connections, internal_collators]
60
+ else:
61
+ self.plugin_pkg = []
62
+
63
+ if plugin_pkg:
64
+ self.plugin_pkg += plugin_pkg
65
+
66
+ self.plugins: dict[str, type[PluginInterface]] = PluginRegistry.load_plugins(
67
+ PluginInterface, self.plugin_pkg
68
+ )
69
+ self.connection_managers: dict[str, type[ConnectionManager]] = PluginRegistry.load_plugins(
70
+ ConnectionManager, self.plugin_pkg
71
+ )
72
+ self.result_collators: dict[str, type[PluginResultCollator]] = PluginRegistry.load_plugins(
73
+ PluginResultCollator, self.plugin_pkg
74
+ )
75
+
76
+ if load_entry_point_plugins:
77
+ entry_point_plugins = self.load_plugins_from_entry_points()
78
+ self.plugins.update(entry_point_plugins)
79
+
80
+ @staticmethod
81
+ def load_plugins(
82
+ base_class: type,
83
+ search_modules: list[types.ModuleType],
84
+ ) -> dict[str, type]:
85
+ """Load plugins from the specified modules that are subclasses of the given base class.
86
+
87
+ Args:
88
+ base_class (type): The base class that the plugins should inherit from.
89
+ search_modules (list[types.ModuleType]): List of modules to search for plugins.
90
+
91
+ Returns:
92
+ dict[str, type]: A dictionary mapping plugin names to their classes.
93
+ """
94
+ registry = {}
95
+
96
+ def _recurse_pkg(pkg: types.ModuleType, base_class: type) -> None:
97
+ for _, module_name, ispkg in pkgutil.iter_modules(pkg.__path__, pkg.__name__ + "."):
98
+ module = importlib.import_module(module_name)
99
+ for _, plugin in inspect.getmembers(
100
+ module,
101
+ lambda x: inspect.isclass(x)
102
+ and issubclass(x, base_class)
103
+ and not inspect.isabstract(x),
104
+ ):
105
+ if hasattr(plugin, "is_valid") and not plugin.is_valid():
106
+ continue
107
+ registry[plugin.__name__] = plugin
108
+ if ispkg:
109
+ _recurse_pkg(module, base_class)
110
+
111
+ for pkg in search_modules:
112
+ _recurse_pkg(pkg, base_class)
113
+ return registry
114
+
115
+ @staticmethod
116
+ def load_plugins_from_entry_points() -> dict[str, type]:
117
+ """Load plugins registered via entry points.
118
+
119
+ Returns:
120
+ dict[str, type]: A dictionary mapping plugin names to their classes.
121
+ """
122
+ plugins = {}
123
+
124
+ try:
125
+ # Python 3.10+ supports group parameter
126
+ try:
127
+ eps = importlib.metadata.entry_points(group="nodescraper.plugins") # type: ignore[call-arg]
128
+ except TypeError:
129
+ # Python 3.9 - entry_points() returns dict-like object
130
+ all_eps = importlib.metadata.entry_points() # type: ignore[assignment]
131
+ eps = all_eps.get("nodescraper.plugins", []) # type: ignore[assignment, attr-defined]
132
+
133
+ for entry_point in eps:
134
+ try:
135
+ plugin_class = entry_point.load() # type: ignore[attr-defined]
136
+
137
+ if (
138
+ inspect.isclass(plugin_class)
139
+ and issubclass(plugin_class, PluginInterface)
140
+ and not inspect.isabstract(plugin_class)
141
+ ):
142
+ if hasattr(plugin_class, "is_valid") and not plugin_class.is_valid():
143
+ continue
144
+
145
+ plugins[plugin_class.__name__] = plugin_class
146
+ except Exception:
147
+ pass
148
+
149
+ except Exception:
150
+ pass
151
+
152
+ return plugins
@@ -0,0 +1,25 @@
1
+ ###############################################################################
2
+ #
3
+ # MIT License
4
+ #
5
+ # Copyright (c) 2025 Advanced Micro Devices, Inc.
6
+ #
7
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ # of this software and associated documentation files (the "Software"), to deal
9
+ # in the Software without restriction, including without limitation the rights
10
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ # copies of the Software, and to permit persons to whom the Software is
12
+ # furnished to do so, subject to the following conditions:
13
+ #
14
+ # The above copyright notice and this permission notice shall be included in all
15
+ # copies or substantial portions of the Software.
16
+ #
17
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ # SOFTWARE.
24
+ #
25
+ ###############################################################################
@@ -0,0 +1,25 @@
1
+ ###############################################################################
2
+ #
3
+ # MIT License
4
+ #
5
+ # Copyright (c) 2025 Advanced Micro Devices, Inc.
6
+ #
7
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ # of this software and associated documentation files (the "Software"), to deal
9
+ # in the Software without restriction, including without limitation the rights
10
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ # copies of the Software, and to permit persons to whom the Software is
12
+ # furnished to do so, subject to the following conditions:
13
+ #
14
+ # The above copyright notice and this permission notice shall be included in all
15
+ # copies or substantial portions of the Software.
16
+ #
17
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ # SOFTWARE.
24
+ #
25
+ ###############################################################################
@@ -0,0 +1,28 @@
1
+ ###############################################################################
2
+ #
3
+ # MIT License
4
+ #
5
+ # Copyright (c) 2025 Advanced Micro Devices, Inc.
6
+ #
7
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ # of this software and associated documentation files (the "Software"), to deal
9
+ # in the Software without restriction, including without limitation the rights
10
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ # copies of the Software, and to permit persons to whom the Software is
12
+ # furnished to do so, subject to the following conditions:
13
+ #
14
+ # The above copyright notice and this permission notice shall be included in all
15
+ # copies or substantial portions of the Software.
16
+ #
17
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ # SOFTWARE.
24
+ #
25
+ ###############################################################################
26
+ from .amdsmi_plugin import AmdSmiPlugin
27
+
28
+ __all__ = ["AmdSmiPlugin"]