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
2 changes: 1 addition & 1 deletion nodescraper/cli/inputargtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def process_file_arg(self, file_path: str) -> TModelType:
return self.model(**data)
except ValidationError as e:
raise argparse.ArgumentTypeError(
f"Validation errors when processing {file_path}: {e.errors()}"
f"Validation errors when processing {file_path}: {e.errors(include_url=False)}"
) from e


Expand Down
3 changes: 1 addition & 2 deletions nodescraper/interfaces/dataanalyzertask.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,12 @@ def wrapper(
if not analyze_arg_model:
raise ValueError("No model defined for analysis args")
args = analyze_arg_model(**args) # type: ignore

func(analyzer, data, args)
except ValidationError as exception:
analyzer._log_event(
category=EventCategory.RUNTIME,
description="Validation error during analysis",
data=get_exception_traceback(exception),
data={"errors": exception.errors(include_url=False)},
priority=EventPriority.CRITICAL,
console_log=True,
)
Expand Down
4 changes: 2 additions & 2 deletions nodescraper/interfaces/datacollectortask.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
from nodescraper.interfaces.task import SystemCompatibilityError, Task
from nodescraper.models import DataModel, SystemInfo, TaskResult
from nodescraper.typeutils import TypeUtils
from nodescraper.utils import get_exception_details, get_exception_traceback
from nodescraper.utils import get_exception_traceback

from .connectionmanager import TConnection
from .taskresulthook import TaskResultHook
Expand Down Expand Up @@ -76,7 +76,7 @@ def wrapper(
collector._log_event(
category=EventCategory.RUNTIME,
description="Pydantic validation error",
data=get_exception_details(exception),
data={"errors": exception.errors(include_url=False)},
priority=EventPriority.CRITICAL,
console_log=True,
)
Expand Down
16 changes: 15 additions & 1 deletion nodescraper/models/taskresult.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,15 @@

from .event import Event

STATUS_LOG_LEVEL_MAP = {
ExecutionStatus.UNSET: logging.INFO,
ExecutionStatus.NOT_RAN: logging.INFO,
ExecutionStatus.OK: logging.INFO,
ExecutionStatus.WARNING: logging.WARNING,
ExecutionStatus.ERROR: logging.ERROR,
ExecutionStatus.EXECUTION_FAILURE: logging.CRITICAL,
}


class TaskResult(BaseModel):
"""Object for result of a task"""
Expand Down Expand Up @@ -133,4 +142,9 @@ def finalize(self, logger: Optional[logging.Logger] = None) -> None:
self.message += f" ({event_summary})"

if logger:
logger.log(self.status.value, "(%s) %s", self.__class__.__name__, self.message)
logger.log(
STATUS_LOG_LEVEL_MAP.get(self.status, logging.INFO),
"(%s) %s",
self.parent,
self.message,
)
2 changes: 2 additions & 0 deletions nodescraper/plugins/inband/bios/analyzer_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ class BiosAnalyzerArgs(BaseModel):
exp_bios_version: list[str] = Field(default_factory=list)
regex_match: bool = False

model_config = {"extra": "forbid"}

@field_validator("exp_bios_version", mode="before")
@classmethod
def validate_exp_bios_version(cls, exp_bios_version: str | list) -> list:
Expand Down
2 changes: 2 additions & 0 deletions nodescraper/plugins/inband/cmdline/analyzer_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ class CmdlineAnalyzerArgs(BaseModel):
required_cmdline: str | list = Field(default_factory=list)
banned_cmdline: str | list = Field(default_factory=list)

model_config = {"extra": "forbid"}

@field_validator("required_cmdline", mode="before")
@classmethod
def validate_required_cmdline(cls, required_cmdline: str | list) -> list:
Expand Down
8 changes: 8 additions & 0 deletions nodescraper/plugins/inband/dkms/analyzer_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
# SOFTWARE.
#
###############################################################################
from typing import Any

from pydantic import BaseModel, Field, field_validator


Expand All @@ -31,6 +33,12 @@ class DkmsAnalyzerArgs(BaseModel):
dkms_version: str | list = Field(default_factory=list)
regex_match: bool = False

model_config = {"extra": "forbid"}

def model_post_init(self, __context: Any) -> None:
if not self.dkms_status and not self.dkms_version:
raise ValueError("At least one of dkms_status or dkms_version must be provided")

@field_validator("dkms_status", mode="before")
@classmethod
def validate_dkms_status(cls, dkms_status: str | list) -> list:
Expand Down
2 changes: 1 addition & 1 deletion nodescraper/plugins/inband/dkms/dkms_analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ def analyze_data(
error_state = False

for check, accepted_values in check_map.items():
actual_value = getattr(data, check)
for accepted_value in accepted_values:
actual_value = getattr(data, check)
if args.regex_match:
try:
regex_data = re.compile(accepted_value)
Expand Down
2 changes: 2 additions & 0 deletions nodescraper/plugins/inband/dmesg/analyzer_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,5 @@
class DmesgAnalyzerArgs(TimeRangeAnalyisArgs):
check_unknown_dmesg_errors: Optional[bool] = True
exclude_category: Optional[set[str]] = None

model_config = {"extra": "forbid"}
2 changes: 2 additions & 0 deletions nodescraper/plugins/inband/kernel/analyzer_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ class KernelAnalyzerArgs(BaseModel):
exp_kernel: str | list = Field(default_factory=list)
regex_match: bool = False

model_config = {"extra": "forbid"}

@field_validator("exp_kernel", mode="before")
@classmethod
def validate_exp_kernel(cls, exp_kernel: str | list) -> list:
Expand Down
2 changes: 2 additions & 0 deletions nodescraper/plugins/inband/memory/analyzer_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,5 @@
class MemoryAnalyzerArgs(BaseModel):
ratio: float = 0.66
memory_threshold: str = "30Gi"

model_config = {"extra": "forbid"}
2 changes: 2 additions & 0 deletions nodescraper/plugins/inband/package/analyzer_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,5 @@
class PackageAnalyzerArgs(BaseModel):
exp_package_ver: dict[str, str | None] = Field(default_factory=dict)
regex_match: bool = True

model_config = {"extra": "forbid"}
2 changes: 2 additions & 0 deletions nodescraper/plugins/inband/process/analyzer_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,5 @@
class ProcessAnalyzerArgs(BaseModel):
max_kfd_processes: int = 0
max_cpu_usage: int = 20

model_config = {"extra": "forbid"}
2 changes: 2 additions & 0 deletions nodescraper/plugins/inband/process/collector_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,5 @@

class ProcessCollectorArgs(BaseModel):
top_n_process: int = 10

model_config = {"extra": "forbid"}
2 changes: 2 additions & 0 deletions nodescraper/plugins/inband/rocm/analyzer_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
class RocmAnalyzerArgs(BaseModel):
exp_rocm: str | list = Field(default_factory=list)

model_config = {"extra": "forbid"}

@field_validator("exp_rocm", mode="before")
@classmethod
def validate_exp_rocm(cls, exp_rocm: str | list) -> list:
Expand Down
2 changes: 2 additions & 0 deletions nodescraper/plugins/inband/storage/analyzer_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,5 @@ class StorageAnalyzerArgs(BaseModel):
ignore_devices: Optional[list[str]] = Field(default_factory=list)
check_devices: Optional[list[str]] = Field(default_factory=list)
regex_match: bool = False

model_config = {"extra": "forbid"}
2 changes: 1 addition & 1 deletion test/unit/plugin/test_dkms_analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def test_missing_data(system_info, model_obj, config):

def test_invalid_data(system_info, model_obj, config):
analyzer = DkmsAnalyzer(system_info=system_info)
args = DkmsAnalyzerArgs(dkms_status=config["status"], invalid=config["invalid"])
args = DkmsAnalyzerArgs(dkms_status=config["status"], dkms_version=config["invalid"])
result = analyzer.analyze_data(data=model_obj, args=args)

assert result.status == ExecutionStatus.ERROR
Expand Down
2 changes: 1 addition & 1 deletion test/unit/plugin/test_storage_analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def test_both_abs_and_prct_fail(system_info):
assert any(e.category == EventCategory.STORAGE.value for e in result.events)
assert any(e.priority == EventPriority.CRITICAL for e in result.events)

args2 = StorageAnalyzerArgs(min_required_free_space_prct=40, min_required_dree_space_abs="1GB")
args2 = StorageAnalyzerArgs(min_required_free_space_prct=40, min_required_free_space_abs="1GB")
result2 = analyzer.analyze_data(model, args2)
assert result2.status == ExecutionStatus.OK

Expand Down