Skip to content

Commit 868f1bb

Browse files
author
jaspals
committed
changed default regex
1 parent fb70f69 commit 868f1bb

File tree

3 files changed

+23
-55
lines changed

3 files changed

+23
-55
lines changed

nodescraper/plugins/inband/package/analyzer_args.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,15 @@
3434
class PackageAnalyzerArgs(AnalyzerArgs):
3535
exp_package_ver: Dict[str, Optional[str]] = Field(default_factory=dict)
3636
regex_match: bool = False
37-
rocm_regex: str = (
38-
r"ocl-icd|kfdtest|llvm-amd|miopen|half|hip|hcc|hsa|rocm|atmi|comgr|composa|amd-smi|aomp|amdgpu|rock|mivision|migraph|rocprofiler|roctracer|rocbl|hipify|rocsol|rocthr|rocff|rocalu|rocprim|rocrand|rccl|rocspar|rdc|rocwmma|rpp|openmp|amdfwflash|ocl|opencl"
39-
)
37+
# rocm_regex is optional and should be specified in plugin_config.json if needed
38+
rocm_regex: Optional[str] = None
4039
enable_rocm_regex: bool = False
4140

4241
@classmethod
4342
def build_from_model(cls, datamodel: PackageDataModel) -> "PackageAnalyzerArgs":
4443
# Use custom rocm_regex from collection_args if enable_rocm_regex is true
44+
rocm_regex = None
4545
if datamodel.enable_rocm_regex and datamodel.rocm_regex:
4646
rocm_regex = datamodel.rocm_regex
47-
else:
48-
# Use default rocm_regex
49-
rocm_regex = PackageAnalyzerArgs().rocm_regex
5047

5148
return cls(exp_package_ver=datamodel.version_info, rocm_regex=rocm_regex)

nodescraper/plugins/inband/package/package_collector.py

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -232,24 +232,29 @@ def collect_data(
232232
self.result.status = ExecutionStatus.NOT_RAN
233233
return self.result, None
234234

235-
# Filter and log ROCm packages if on Linux
235+
# Filter and log ROCm packages if on Linux and rocm_regex is provided
236236
if self.system_info.os_family == OSFamily.LINUX and packages:
237-
# Get ROCm pattern from args or use default
238-
rocm_pattern = args.rocm_regex if args else PackageAnalyzerArgs().rocm_regex
239-
self.logger.info("Using rocm_pattern: %s", rocm_pattern)
240-
rocm_packages = self._filter_rocm_packages(packages, rocm_pattern)
241-
if rocm_packages:
242-
self.result.message = f"Found {len(rocm_packages)} ROCm-related packages installed"
243-
self.result.status = ExecutionStatus.OK
244-
self._log_event(
245-
category=EventCategory.OS,
246-
description=f"Found {len(rocm_packages)} ROCm-related packages installed",
247-
priority=EventPriority.INFO,
248-
data={"rocm_packages": sorted(rocm_packages.keys())},
249-
)
237+
# Get ROCm pattern from args if provided
238+
rocm_pattern = args.rocm_regex if args else None
239+
if rocm_pattern:
240+
self.logger.info("Using rocm_pattern: %s", rocm_pattern)
241+
rocm_packages = self._filter_rocm_packages(packages, rocm_pattern)
242+
if rocm_packages:
243+
self.result.message = (
244+
f"Found {len(rocm_packages)} ROCm-related packages installed"
245+
)
246+
self.result.status = ExecutionStatus.OK
247+
self._log_event(
248+
category=EventCategory.OS,
249+
description=f"Found {len(rocm_packages)} ROCm-related packages installed",
250+
priority=EventPriority.INFO,
251+
data={"rocm_packages": sorted(rocm_packages.keys())},
252+
)
253+
else:
254+
self.logger.info("No rocm_regex provided, skipping ROCm package filtering")
250255

251256
# Extract rocm_regex and enable_rocm_regex from args if provided
252-
rocm_regex = args.rocm_regex if args else ""
257+
rocm_regex = args.rocm_regex if (args and args.rocm_regex) else ""
253258
enable_rocm_regex = getattr(args, "enable_rocm_regex", False) if args else False
254259

255260
try:

test/unit/plugin/test_package_collector.py

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -224,40 +224,6 @@ def test_bad_splits_ubuntu(collector, conn_mock, command_results):
224224
assert res.status == ExecutionStatus.OK
225225

226226

227-
def test_rocm_package_filtering_default_regex(collector, conn_mock, command_results):
228-
"""Test ROCm package filtering with default regex pattern."""
229-
# Mock Ubuntu system with ROCm packages
230-
ubuntu_packages = """rocm-core 5.7.0
231-
hip-runtime-amd 5.7.0
232-
hsa-rocr 1.9.0
233-
amdgpu-dkms 6.3.6
234-
gcc 11.4.0
235-
python3 3.10.12"""
236-
237-
conn_mock.run_command.side_effect = [
238-
CommandArtifact(
239-
command="",
240-
exit_code=0,
241-
stdout=command_results["ubuntu_rel"],
242-
stderr="",
243-
),
244-
CommandArtifact(
245-
command="",
246-
exit_code=0,
247-
stdout=ubuntu_packages,
248-
stderr="",
249-
),
250-
]
251-
252-
res, data = collector.collect_data()
253-
assert res.status == ExecutionStatus.OK
254-
# Check that ROCm packages are found
255-
assert "rocm" in res.message.lower()
256-
assert data is not None
257-
# Verify all packages are collected
258-
assert len(data.version_info) == 6
259-
260-
261227
def test_rocm_package_filtering_custom_regex(collector, conn_mock, command_results):
262228
"""Test ROCm package filtering with custom regex pattern."""
263229
from nodescraper.plugins.inband.package.analyzer_args import PackageAnalyzerArgs

0 commit comments

Comments
 (0)