Skip to content

Commit 3a05c52

Browse files
committed
Cleaner sanitization
1 parent 6b8c25e commit 3a05c52

3 files changed

Lines changed: 10 additions & 25 deletions

File tree

skills/apu-memory-tuner/scripts/apply_profile.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,6 @@
6161
from dataclasses import dataclass
6262
from pathlib import Path
6363

64-
from _sanitize import sanitize_process_output
65-
6664
PAGE_SIZE_BYTES = 4096
6765
MIN_VRAM_GB = 0.5 # Floor most BIOSes allow for the UMA frame buffer.
6866
MIN_GTT_GB = 1.0 # Below this, even routine GPU work fails.
@@ -83,15 +81,12 @@ class ProfileTargets:
8381
def _run(cmd: list[str], timeout: float = 60.0) -> tuple[int, str, str]:
8482
try:
8583
r = subprocess.run(
86-
cmd, capture_output=True, text=True, timeout=timeout, check=False,
87-
)
88-
return (
89-
r.returncode,
90-
sanitize_process_output(r.stdout),
91-
sanitize_process_output(r.stderr),
84+
cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
85+
text=True, timeout=timeout, check=False,
9286
)
87+
return r.returncode, r.stdout or "", r.stderr or ""
9388
except (FileNotFoundError, subprocess.SubprocessError, OSError) as e:
94-
return 127, "", sanitize_process_output(str(e))
89+
return 127, "", str(e)
9590

9691

9792
def _read_text(path: str) -> str:

skills/apu-memory-tuner/scripts/detect_platform.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@
3636
from dataclasses import asdict, dataclass, field
3737
from pathlib import Path
3838

39-
from _sanitize import sanitize_process_output
40-
4139
# Mapping from LLVM gfx target to the marketing-friendly generation bucket
4240
# the rest of the skill keys off. RDNA3.5 (gfx115x) is the only generation
4341
# the source ROCm doc describes shared-memory tuning for, so it is the only
@@ -91,13 +89,10 @@ def _run(cmd: list[str], timeout: float = 5.0) -> tuple[int, str, str]:
9189
"""Run a command; return (exit, stdout, stderr). Never raises."""
9290
try:
9391
r = subprocess.run(
94-
cmd, capture_output=True, text=True, timeout=timeout, check=False,
95-
)
96-
return (
97-
r.returncode,
98-
sanitize_process_output(r.stdout),
99-
sanitize_process_output(r.stderr),
92+
cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
93+
text=True, timeout=timeout, check=False,
10094
)
95+
return r.returncode, r.stdout or "", r.stderr or ""
10196
except (FileNotFoundError, subprocess.SubprocessError, OSError):
10297
return 127, "", ""
10398

skills/apu-memory-tuner/scripts/show_config.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@
3636
from dataclasses import asdict, dataclass
3737
from pathlib import Path
3838

39-
from _sanitize import sanitize_process_output
40-
4139
# 4 KiB is the page size assumed by the amdgpu/TTM accounting on every
4240
# platform we target. The kernel param is in pages, the user thinks in GB.
4341
PAGE_SIZE_BYTES = 4096
@@ -64,13 +62,10 @@ class Config:
6462
def _run(cmd: list[str], timeout: float = 10.0) -> tuple[int, str, str]:
6563
try:
6664
r = subprocess.run(
67-
cmd, capture_output=True, text=True, timeout=timeout, check=False,
68-
)
69-
return (
70-
r.returncode,
71-
sanitize_process_output(r.stdout),
72-
sanitize_process_output(r.stderr),
65+
cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
66+
text=True, timeout=timeout, check=False,
7367
)
68+
return r.returncode, r.stdout or "", r.stderr or ""
7469
except (FileNotFoundError, subprocess.SubprocessError, OSError):
7570
return 127, "", ""
7671

0 commit comments

Comments
 (0)