Skip to content

Commit 27b81c6

Browse files
Merge branch 'development' into alex_devenum
2 parents ed1be90 + d2ac221 commit 27b81c6

File tree

18 files changed

+2725
-45
lines changed

18 files changed

+2725
-45
lines changed

.github/workflows/code_quality_checks.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ name: Code Quality Check
44
permissions:
55
contents: read
66

7-
on: [pull_request]
7+
on:
8+
- pull_request
9+
- workflow_dispatch
810

911
jobs:
1012
pre-commit:
@@ -13,11 +15,10 @@ jobs:
1315

1416
steps:
1517
- uses: actions/checkout@v3
16-
- name: setup environment
17-
run: |
18-
./dev-setup.sh
19-
- name: run pre-commit hooks
18+
- name: setup environment and run pre-commit hooks
19+
shell: bash
2020
run: |
21+
source ./dev-setup.sh
2122
pre-commit run --all-files --show-diff-on-failure --color=always
2223
- name: Print message on failure
2324
if: failure()

.github/workflows/unit-test.yml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,16 @@ jobs:
1717
steps:
1818
- uses: actions/checkout@v3
1919

20-
- name: Install package
21-
run: |
22-
./dev-setup.sh
23-
2420
- name: Install xmllint
2521
run: |
2622
apt-get update
2723
apt-get install -y libxml2-utils bc
2824
29-
30-
- name: Run unit tests with coverage
25+
- name: Install package and run unit tests with coverage
3126
id: extract_coverage
27+
shell: bash
3228
run: |
29+
source ./dev-setup.sh
3330
pytest test/unit -s --cov=nodescraper --cov-report=xml --cov-report=term --cov-fail-under=70 --maxfail=1 --disable-warnings -v
3431
3532
- name: Print coverage

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,27 @@ a python virtual environment and also configures the pre-commit hooks for the pr
3232
source dev-setup.sh
3333
```
3434

35+
Alternatively, follow these manual steps:
36+
37+
### 1. Virtual Environment (Optional)
38+
```sh
39+
python3 -m venv venv
40+
source venv/bin/activate
41+
```
42+
On Debian/Ubuntu, you may need: `sudo apt install python3-venv`
43+
44+
### 2. Install from Source (Required)
45+
```sh
46+
python3 -m pip install --editable .[dev] --upgrade
47+
```
48+
This installs Node Scraper in editable mode with development dependencies. To verify: `node-scraper --help`
49+
50+
### 3. Git Hooks (Optional)
51+
```sh
52+
pre-commit install
53+
```
54+
Sets up pre-commit hooks for code quality checks. On Debian/Ubuntu, you may need: `sudo apt install pre-commit`
55+
3556
## CLI Usage
3657
The Node Scraper CLI can be used to run Node Scraper plugins on a target system. The following CLI
3758
options are available:

dev-setup.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
#!/usr/bin/env bash
2+
13
# Create venv if not already present
24
if [ ! -d "venv" ]; then
3-
python3 -m pip install venv
45
python3 -m venv venv
56
fi
67

nodescraper/models/analyzerargs.py

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,61 @@
2323
# SOFTWARE.
2424
#
2525
###############################################################################
26-
from pydantic import BaseModel
26+
from typing import Any
27+
28+
from pydantic import BaseModel, model_validator
2729

2830

2931
class AnalyzerArgs(BaseModel):
32+
"""Base class for all analyzer arguments.
33+
34+
This class provides automatic string stripping for all string values
35+
in analyzer args. All analyzer args classes should inherit from this
36+
directly.
37+
38+
"""
39+
3040
model_config = {"extra": "forbid", "exclude_none": True}
3141

42+
@model_validator(mode="before")
43+
@classmethod
44+
def strip_string_values(cls, data: Any) -> Any:
45+
"""Strip whitespace from all string values in analyzer args.
46+
47+
This validator recursively processes:
48+
- String values: strips whitespace
49+
- Lists: strips strings in lists
50+
- Dicts: strips string values in dicts
51+
- Other types: left unchanged
52+
53+
Args:
54+
data: The input data to validate
55+
56+
Returns:
57+
The data with all string values stripped
58+
"""
59+
if isinstance(data, dict):
60+
return {k: cls._strip_value(v) for k, v in data.items()}
61+
return data
62+
63+
@classmethod
64+
def _strip_value(cls, value: Any) -> Any:
65+
"""Recursively strip string values.
66+
67+
Args:
68+
value: The value to process
69+
70+
Returns:
71+
The processed value
72+
"""
73+
if isinstance(value, str):
74+
return value.strip()
75+
elif isinstance(value, list):
76+
return [cls._strip_value(item) for item in value]
77+
elif isinstance(value, dict):
78+
return {k: cls._strip_value(v) for k, v in value.items()}
79+
return value
80+
3281
@classmethod
3382
def build_from_model(cls, datamodel):
3483
"""Build analyzer args instance from data model object
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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"]

0 commit comments

Comments
 (0)