Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions nodescraper/cli/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,11 +344,13 @@ def generate_reference_config(

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

args = extract_analyzer_args_from_model(plugin, data_model, logger)
if not args:
continue
plugins[obj.source] = {"analysis_args": {}}
plugins[obj.source]["analysis_args"] = args.model_dump(exclude_none=True)
if obj.source not in plugins:
plugins[obj.source] = {}

a_args = extract_analyzer_args_from_model(plugin, data_model, logger)
if a_args:
plugins[obj.source]["analysis_args"] = a_args.model_dump(exclude_none=True)

plugin_config.plugins = plugins

return plugin_config
Expand Down
2 changes: 2 additions & 0 deletions nodescraper/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#
###############################################################################
from .analyzerargs import AnalyzerArgs
from .collectorargs import CollectorArgs
from .datamodel import DataModel
from .datapluginresult import DataPluginResult
from .event import Event
Expand All @@ -35,6 +36,7 @@

__all__ = [
"AnalyzerArgs",
"CollectorArgs",
"DataModel",
"TaskResult",
"Event",
Expand Down
30 changes: 30 additions & 0 deletions nodescraper/models/collectorargs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
###############################################################################
#
# MIT License
#
# Copyright (c) 2025 Advanced Micro Devices, Inc.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#
###############################################################################
from pydantic import BaseModel


class CollectorArgs(BaseModel):
model_config = {"extra": "forbid", "exclude_none": True}
7 changes: 3 additions & 4 deletions nodescraper/plugins/inband/process/collector_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,9 @@
# SOFTWARE.
#
###############################################################################
from pydantic import BaseModel

from nodescraper.models import CollectorArgs

class ProcessCollectorArgs(BaseModel):
top_n_process: int = 10

model_config = {"extra": "forbid"}
class ProcessCollectorArgs(CollectorArgs):
top_n_process: int = 10
2 changes: 2 additions & 0 deletions nodescraper/plugins/inband/process/process_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,5 @@ class ProcessPlugin(InBandDataPlugin[ProcessDataModel, ProcessCollectorArgs, Pro
ANALYZER = ProcessAnalyzer

ANALYZER_ARGS = ProcessAnalyzerArgs

COLLECTOR_ARGS = ProcessCollectorArgs
4 changes: 2 additions & 2 deletions test/unit/framework/common/shared_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,11 @@ class TestModelArg(AnalyzerArgs):

@classmethod
def build_from_model(cls, model):
return cls(model_attr=int(model.some_version))
return cls(model_attr=int(model.foo))


class DummyDataModel(DataModel):
some_version: str = None
foo: str = None


class TestPluginA(PluginInterface[MockConnectionManager, None]):
Expand Down
11 changes: 8 additions & 3 deletions test/unit/framework/test_cli_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,16 @@
from types import SimpleNamespace

import pytest
from common.shared_utils import DummyDataModel

# from common.shared_utils import DummyDataModel
from conftest import DummyDataModel
from pydantic import BaseModel

from nodescraper.cli import cli
from nodescraper.cli.helper import build_config, find_datamodel_and_result
from nodescraper.cli.helper import (
build_config,
find_datamodel_and_result,
)
from nodescraper.configregistry import ConfigRegistry
from nodescraper.enums import ExecutionStatus, SystemInteractionLevel
from nodescraper.models import PluginConfig, TaskResult
Expand All @@ -50,7 +55,7 @@ def test_generate_reference_config(plugin_registry):
source="TestPluginA",
message="Plugin tasks completed successfully",
result_data=DataPluginResult(
system_data=DummyDataModel(some_version="17"),
system_data=DummyDataModel(foo="17"),
collection_result=TaskResult(
status=ExecutionStatus.OK,
message="BIOS: 17",
Expand Down