Skip to content

Commit 6a50e27

Browse files
committed
merged alex_diff + ProcessCollectorArgs
2 parents e4707e9 + 779eb6a commit 6a50e27

File tree

10 files changed

+59
-32
lines changed

10 files changed

+59
-32
lines changed

nodescraper/cli/cli.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,11 +326,12 @@ def main(arg_input: Optional[list[str]] = None):
326326
top_level_args, plugin_arg_map = process_args(arg_input, list(plugin_subparser_map.keys()))
327327

328328
parsed_args = parser.parse_args(top_level_args)
329+
system_info = get_system_info(parsed_args)
329330

330331
if parsed_args.log_path and parsed_args.subcmd not in ["gen-plugin-config", "describe"]:
331332
log_path = os.path.join(
332333
parsed_args.log_path,
333-
f"scraper_logs_{datetime.datetime.now().strftime('%Y_%m_%d-%I_%M_%S_%p')}",
334+
f"scraper_logs_{system_info.name}_{datetime.datetime.now().strftime('%Y_%m_%d-%I_%M_%S_%p')}",
334335
)
335336
os.makedirs(log_path)
336337
else:
@@ -386,7 +387,6 @@ def main(arg_input: Optional[list[str]] = None):
386387
plugin_subparser_map=plugin_subparser_map,
387388
)
388389

389-
system_info = get_system_info(parsed_args)
390390
log_system_info(log_path, system_info, logger)
391391
except Exception as e:
392392
parser.error(str(e))

nodescraper/cli/helper.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
from nodescraper.cli.inputargtypes import ModelArgHandler
3535
from nodescraper.configbuilder import ConfigBuilder
3636
from nodescraper.configregistry import ConfigRegistry
37-
from nodescraper.enums import SystemInteractionLevel, SystemLocation
37+
from nodescraper.enums import ExecutionStatus, SystemInteractionLevel, SystemLocation
3838
from nodescraper.models import PluginConfig, PluginResult, SystemInfo, TaskResult
3939
from nodescraper.pluginexecutor import PluginExecutor
4040
from nodescraper.pluginregistry import PluginRegistry
@@ -300,12 +300,23 @@ def generate_reference_config(
300300
plugin_config = PluginConfig()
301301
plugins = {}
302302
for obj in results:
303+
if obj.result_data.collection_result.status != ExecutionStatus.OK:
304+
logger.warning(
305+
"Plugin: %s result status is %, skipping",
306+
obj.source,
307+
obj.result_data.collection_result.status,
308+
)
309+
continue
310+
303311
data_model = obj.result_data.system_data
312+
if data_model is None:
313+
logger.warning("Plugin: %s data model not found: %s, skipping", obj.source)
314+
continue
304315

305316
plugin = plugin_reg.plugins.get(obj.source)
306317
if not plugin.ANALYZER_ARGS:
307318
logger.warning(
308-
"Plugin: %s does not support reference config creation. No analyzer args defined.",
319+
"Plugin: %s does not support reference config creation. No analyzer args defined, skipping.",
309320
obj.source,
310321
)
311322
continue

nodescraper/models/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#
2525
###############################################################################
2626
from .analyzerargs import AnalyzerArgs
27+
from .collectorargs import CollectorArgs
2728
from .datamodel import DataModel
2829
from .datapluginresult import DataPluginResult
2930
from .event import Event
@@ -35,6 +36,7 @@
3536

3637
__all__ = [
3738
"AnalyzerArgs",
39+
"CollectorArgs",
3840
"DataModel",
3941
"TaskResult",
4042
"Event",

nodescraper/models/analyzerargs.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,10 @@
2323
# SOFTWARE.
2424
#
2525
###############################################################################
26-
from abc import ABC
27-
2826
from pydantic import BaseModel
2927

3028

31-
class AnalyzerArgs(BaseModel, ABC):
29+
class AnalyzerArgs(BaseModel):
3230
model_config = {"extra": "forbid", "exclude_none": True}
3331

3432
@classmethod
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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 abc import ABC
27+
28+
from pydantic import BaseModel
29+
30+
31+
class CollectorArgs(BaseModel, ABC):
32+
model_config = {"extra": "forbid", "exclude_none": True}

nodescraper/plugins/inband/dmesg/analyzer_args.py

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,24 +26,8 @@
2626
from typing import Optional
2727

2828
from nodescraper.models import TimeRangeAnalysisArgs
29-
from nodescraper.plugins.inband.dmesg.dmesgdata import DmesgData
3029

3130

3231
class DmesgAnalyzerArgs(TimeRangeAnalysisArgs):
3332
check_unknown_dmesg_errors: Optional[bool] = True
3433
exclude_category: Optional[set[str]] = None
35-
36-
@classmethod
37-
def build_from_model(cls, datamodel: DmesgData) -> "TimeRangeAnalysisArgs":
38-
"""build analyzer args from data model
39-
40-
Args:
41-
datamodel (DmesgDataModel): data model for plugin
42-
43-
Raises:
44-
NotImplementedError: does not implement abstract function
45-
46-
Returns:
47-
TimeRangeAnalysisArgs: instance of analyzer args class
48-
"""
49-
raise NotImplementedError("Dmesg does not support reference config creation")

nodescraper/plugins/inband/process/collector_args.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@
2323
# SOFTWARE.
2424
#
2525
###############################################################################
26-
from pydantic import BaseModel
2726

27+
from nodescraper.models import CollectorArgs
2828

29-
class ProcessCollectorArgs(BaseModel):
29+
30+
class ProcessCollectorArgs(CollectorArgs):
3031
top_n_process: int = 10

nodescraper/plugins/inband/process/process_plugin.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,5 @@ class ProcessPlugin(InBandDataPlugin[ProcessDataModel, ProcessCollectorArgs, Pro
4242
ANALYZER = ProcessAnalyzer
4343

4444
ANALYZER_ARGS = ProcessAnalyzerArgs
45+
46+
COLLECTOR_ARGS = ProcessCollectorArgs

test/unit/framework/common/shared_utils.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,9 @@
2626
from typing import Optional
2727
from unittest.mock import MagicMock
2828

29-
from pydantic import BaseModel
30-
3129
from nodescraper.enums import ExecutionStatus
3230
from nodescraper.interfaces import ConnectionManager, PluginInterface
33-
from nodescraper.models import PluginResult, TaskResult
31+
from nodescraper.models import AnalyzerArgs, PluginResult, TaskResult
3432
from nodescraper.models.datamodel import DataModel
3533

3634

@@ -69,12 +67,12 @@ def disconnect(self):
6967
pass
7068

7169

72-
class TestModelArg(BaseModel):
70+
class TestModelArg(AnalyzerArgs):
7371
model_attr: int = 123
7472

7573
@classmethod
7674
def build_from_model(cls, model):
77-
return cls()
75+
return cls(model_attr=int(model.some_version))
7876

7977

8078
class DummyDataModel(DataModel):

test/unit/framework/test_analyzerargs.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ def build_from_model(cls, datamodel):
1313

1414
def test_build_from_model(dummy_data_model):
1515
dummy = dummy_data_model(foo=1)
16-
args = MyArgs(args_foo=1)
17-
args = args.build_from_model(dummy)
16+
args = MyArgs.build_from_model(dummy)
1817
assert isinstance(args, MyArgs)
1918
assert args.args_foo == dummy.foo
2019
dump = args.model_dump(mode="json", exclude_none=True)

0 commit comments

Comments
 (0)