Skip to content

Commit 2a1e02a

Browse files
Merge branch 'development' into alex_build_from_model
2 parents 80f65b9 + 523f27c commit 2a1e02a

File tree

15 files changed

+4703
-26
lines changed

15 files changed

+4703
-26
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Workflow to run plugin documentation generation then commit the updated changes
2+
3+
name: Plugin Documentation Generator
4+
5+
permissions:
6+
contents: write
7+
8+
on:
9+
workflow_dispatch:
10+
schedule:
11+
- cron: '0 0 * * *'
12+
13+
jobs:
14+
generate_docs:
15+
runs-on: [ self-hosted ]
16+
# To disable this workflow, set DISABLE_AUTO_DOCS to 'true' in repository variables
17+
if: vars.DISABLE_AUTO_DOCS != 'true'
18+
19+
steps:
20+
- name: Checkout repository
21+
uses: actions/checkout@v4
22+
with:
23+
token: ${{ secrets.GITHUB_TOKEN }}
24+
25+
- name: Install dependencies
26+
run: ./dev-setup.sh
27+
28+
- name: Run plugin documentation generator
29+
run: |
30+
source venv/bin/activate
31+
python docs/generate_plugin_doc_bundle.py \
32+
--package nodescraper.plugins.inband \
33+
--output docs/PLUGIN_DOC.md
34+
35+
- name: Format documentation with pre-commit
36+
run: |
37+
source venv/bin/activate
38+
pre-commit run --files docs/PLUGIN_DOC.md || true
39+
40+
- name: Commit and push changes
41+
run: |
42+
git config user.name "github-actions[bot]"
43+
git config user.email "github-actions[bot]@users.noreply.github.com"
44+
git add docs/PLUGIN_DOC.md
45+
git diff --staged --quiet || git commit --no-verify -m "docs: Update plugin documentation [automated]"
46+
git push

CONTRIBUTING.md

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,41 @@ When creating a PR, use the following process.
5252
> By creating a PR, you agree to allow your contribution to be licensed under the
5353
> terms of the LICENSE.txt file.
5454
55-
### Documentation
55+
### Pre-commit hooks
5656

57-
Submit Node Scraper documentation changes to our
58-
[documentation](https://github.com/amd/node-scraper/blob/development/README.md). You must update
59-
documentation related to any new feature or API contribution.
57+
This repository uses [pre-commit](https://pre-commit.com/) to automatically format code. When you commit changes to plugin files, the hooks will:
58+
59+
1. Run code formatters (ruff, black)
60+
2. Run type checking (mypy)
61+
62+
#### Setup
63+
64+
Install pre-commit hooks after cloning the repository:
65+
66+
```bash
67+
# Activate your virtual environment
68+
source venv/bin/activate
69+
70+
# Install pre-commit hooks
71+
pre-commit install
72+
```
73+
74+
#### Usage
75+
76+
The hooks run automatically when you commit.
77+
78+
```bash
79+
# First commit attempt - hooks run and may modify files
80+
git commit -m "Add new plugin feature"
81+
82+
# If hooks modified files, stage them and commit again
83+
git add .
84+
git commit -m "Add new plugin feature"
85+
```
86+
87+
You can also run hooks manually:
88+
89+
```bash
90+
# Run all hooks on all files
91+
pre-commit run --all-files
92+
```

docs/PLUGIN_DOC.md

Lines changed: 320 additions & 5 deletions
Large diffs are not rendered by default.

nodescraper/models/taskresult.py

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -103,28 +103,40 @@ def duration(self) -> Optional[str]:
103103
return duration
104104

105105
def _get_event_summary(self) -> str:
106-
"""Get summary string for artifacts
106+
"""Get summary string for events
107107
108108
Returns:
109-
str: artifact summary
109+
str: event summary with counts and descriptions
110110
"""
111-
error_count = 0
112-
warning_count = 0
111+
error_msg_counts: dict[str, int] = {}
112+
warning_msg_counts: dict[str, int] = {}
113113

114114
for event in self.events:
115115
if event.priority == EventPriority.WARNING:
116-
warning_count += 1
116+
warning_msg_counts[event.description] = (
117+
warning_msg_counts.get(event.description, 0) + 1
118+
)
117119
elif event.priority >= EventPriority.ERROR:
118-
error_count += 1
119-
120-
summary_list = []
121-
122-
if warning_count:
123-
summary_list.append(f"{warning_count} warnings")
124-
if error_count:
125-
summary_list.append(f"{error_count} errors")
126-
127-
return "|".join(summary_list)
120+
error_msg_counts[event.description] = error_msg_counts.get(event.description, 0) + 1
121+
122+
summary_parts = []
123+
124+
if warning_msg_counts:
125+
total_warnings = sum(warning_msg_counts.values())
126+
warning_details = [
127+
f"{msg} (x{count})" if count > 1 else msg
128+
for msg, count in warning_msg_counts.items()
129+
]
130+
summary_parts.append(f"{total_warnings} warnings: {', '.join(warning_details)}")
131+
132+
if error_msg_counts:
133+
total_errors = sum(error_msg_counts.values())
134+
error_details = [
135+
f"{msg} (x{count})" if count > 1 else msg for msg, count in error_msg_counts.items()
136+
]
137+
summary_parts.append(f"{total_errors} errors: {', '.join(error_details)}")
138+
139+
return "; ".join(summary_parts)
128140

129141
def _update_status(self) -> None:
130142
"""Update overall status based on event priority"""
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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 .analyzer_args import PcieAnalyzerArgs
27+
from .pcie_plugin import PciePlugin
28+
29+
__all__ = ["PciePlugin", "PcieAnalyzerArgs"]
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
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 typing import Dict, Optional, Union
27+
28+
from nodescraper.models import AnalyzerArgs
29+
30+
31+
class PcieAnalyzerArgs(AnalyzerArgs):
32+
"""Arguments for PCIe analyzer
33+
34+
Attributes:
35+
exp_speed: Expected PCIe speed (generation 1-5)
36+
exp_width: Expected PCIe width (1-16 lanes)
37+
exp_sriov_count: Expected SR-IOV VF count
38+
exp_gpu_count_override: Override expected GPU count
39+
exp_max_payload_size: Expected max payload size (int for all devices, dict for specific device IDs)
40+
exp_max_rd_req_size: Expected max read request size (int for all devices, dict for specific device IDs)
41+
exp_ten_bit_tag_req_en: Expected 10-bit tag request enable (int for all devices, dict for specific device IDs)
42+
"""
43+
44+
exp_speed: int = 5
45+
exp_width: int = 16
46+
exp_sriov_count: int = 0
47+
exp_gpu_count_override: Optional[int] = None
48+
exp_max_payload_size: Optional[Union[Dict[int, int], int]] = None
49+
exp_max_rd_req_size: Optional[Union[Dict[int, int], int]] = None
50+
exp_ten_bit_tag_req_en: Optional[Union[Dict[int, int], int]] = None
51+
52+
53+
def normalize_to_dict(
54+
value: Optional[Union[Dict[int, int], int]], vendorid_ep: int
55+
) -> Dict[int, int]:
56+
"""Normalize int or dict values to dict format using vendorid_ep as key for int values"""
57+
if value is None:
58+
return {}
59+
if isinstance(value, int):
60+
return {vendorid_ep: value}
61+
if isinstance(value, dict):
62+
return value
63+
return {}

0 commit comments

Comments
 (0)