Skip to content

Commit 72fb0b1

Browse files
Merge pull request #20 from amd/alex_collector_args
Adding collector_args
2 parents b8cbaf7 + 3cc31fc commit 72fb0b1

File tree

7 files changed

+54
-14
lines changed

7 files changed

+54
-14
lines changed

nodescraper/cli/helper.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -344,11 +344,13 @@ def generate_reference_config(
344344

345345
plugin = plugin_reg.plugins.get(obj.source)
346346

347-
args = extract_analyzer_args_from_model(plugin, data_model, logger)
348-
if not args:
349-
continue
350-
plugins[obj.source] = {"analysis_args": {}}
351-
plugins[obj.source]["analysis_args"] = args.model_dump(exclude_none=True)
347+
if obj.source not in plugins:
348+
plugins[obj.source] = {}
349+
350+
a_args = extract_analyzer_args_from_model(plugin, data_model, logger)
351+
if a_args:
352+
plugins[obj.source]["analysis_args"] = a_args.model_dump(exclude_none=True)
353+
352354
plugin_config.plugins = plugins
353355

354356
return plugin_config

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

nodescraper/plugins/inband/process/collector_args.py

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

27+
from nodescraper.models import CollectorArgs
2828

29-
class ProcessCollectorArgs(BaseModel):
30-
top_n_process: int = 10
3129

32-
model_config = {"extra": "forbid"}
30+
class ProcessCollectorArgs(CollectorArgs):
31+
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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,11 @@ class TestModelArg(AnalyzerArgs):
7272

7373
@classmethod
7474
def build_from_model(cls, model):
75-
return cls(model_attr=int(model.some_version))
75+
return cls(model_attr=int(model.foo))
7676

7777

7878
class DummyDataModel(DataModel):
79-
some_version: str = None
79+
foo: str = None
8080

8181

8282
class TestPluginA(PluginInterface[MockConnectionManager, None]):

test/unit/framework/test_cli_helper.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,16 @@
3131
from types import SimpleNamespace
3232

3333
import pytest
34-
from common.shared_utils import DummyDataModel
34+
35+
# from common.shared_utils import DummyDataModel
36+
from conftest import DummyDataModel
3537
from pydantic import BaseModel
3638

3739
from nodescraper.cli import cli
38-
from nodescraper.cli.helper import build_config, find_datamodel_and_result
40+
from nodescraper.cli.helper import (
41+
build_config,
42+
find_datamodel_and_result,
43+
)
3944
from nodescraper.configregistry import ConfigRegistry
4045
from nodescraper.enums import ExecutionStatus, SystemInteractionLevel
4146
from nodescraper.models import PluginConfig, TaskResult
@@ -50,7 +55,7 @@ def test_generate_reference_config(plugin_registry):
5055
source="TestPluginA",
5156
message="Plugin tasks completed successfully",
5257
result_data=DataPluginResult(
53-
system_data=DummyDataModel(some_version="17"),
58+
system_data=DummyDataModel(foo="17"),
5459
collection_result=TaskResult(
5560
status=ExecutionStatus.OK,
5661
message="BIOS: 17",

0 commit comments

Comments
 (0)