Skip to content

Commit 7aee55f

Browse files
committed
remove verbosity levels ERROR and WARNING, consistent prefix for all prints, use warnings for warning messages
1 parent 0613028 commit 7aee55f

3 files changed

Lines changed: 12 additions & 15 deletions

File tree

nsight/extraction.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,6 @@ def extract_df_from_report(
144144
}
145145

146146
# Extract all profiling data
147-
if verbosity >= VerbosityLevel.INFO:
148-
print(f"Extracting profiling data")
149147
profiling_data: dict[str, list[utils.NCUActionData]] = {}
150148
for range_idx in range(report.num_ranges()):
151149
current_range: ncu_report.IRange = report.range_by_idx(range_idx)
@@ -172,7 +170,7 @@ def extract_df_from_report(
172170

173171
for annotation, annotation_data in profiling_data.items():
174172
if verbosity >= VerbosityLevel.INFO:
175-
print(f"Extracting {annotation} profiling data")
173+
print(f"[NSIGHT-PYTHON] Extracting {annotation} profiling data")
176174

177175
configs_repeated = [
178176
(config,) if is_scalar(config) else config

nsight/thermovision.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from typing import Any, Literal
66

77
from nsight.exceptions import CoolingTimeoutError
8+
import warnings
89

910
"""
1011
This module provides GPU thermal monitoring and throttling prevention using NVIDIA's NVML library
@@ -22,8 +23,8 @@
2223
CUDA_CORE_AVAILABLE = True
2324
except ImportError:
2425
CUDA_CORE_AVAILABLE = False
25-
print(
26-
"Warning: Cannot import cuda.core. Ensure nsight-python was installed properly with all dependencies."
26+
warnings.warn(
27+
"Cannot import cuda.core. Ensure nsight-python was installed properly with all dependencies."
2728
)
2829

2930
# Default thermal threshold constants
@@ -270,7 +271,7 @@ def _is_temp_retrieval_supported(self) -> bool:
270271
self.device.temperature.margin
271272
return True
272273
except Exception:
273-
print(
274-
"Warning: Nsight Python Thermovision is not supported on this machine"
274+
warnings.warn(
275+
"Nsight Python Thermovision is not supported on this machine"
275276
)
276277
return False

nsight/utils.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,10 @@ class VerbosityLevel(enum.IntEnum):
4343
"""Verbosity level for ``@nsight.analyze.kernel``.
4444
4545
Selecting level N enables output at all levels with value <= N.
46-
For example, ``INFO`` enables ERROR, WARNING, and INFO but not DEBUG.
46+
For example, ``INFO`` enables INFO but not DEBUG.
4747
"""
4848

4949
SILENT = 0
50-
ERROR = 1
51-
WARNING = 2
5250
INFO = 3
5351
DEBUG = 4
5452

@@ -134,10 +132,10 @@ def format_time(seconds: float) -> str:
134132
# Sincerely stolen (and adjusted) from attention-gym
135133
def print_header(*lines: str) -> None:
136134
width = max(80, max(len(line) for line in lines) + 4)
137-
print(purple("╔" + "═" * (width - 2) + "╗"))
135+
print(purple("[NSIGHT-PYTHON] ╔" + "═" * (width - 2) + "╗"))
138136
for line in lines:
139-
print(purple(f"║ {line.center(width - 4)} ║"))
140-
print(purple("╚" + "═" * (width - 2) + "╝"))
137+
print(purple(f"[NSIGHT-PYTHON] {line.center(width - 4)} ║"))
138+
print(purple("[NSIGHT-PYTHON] ╚" + "═" * (width - 2) + "╝"))
141139

142140

143141
@dataclass
@@ -203,13 +201,13 @@ def print_progress_bar(
203201
sys.stdout.write("\033[1A") # Move cursor up 1 line
204202
sys.stdout.write("\033[2K\r") # Clear line
205203
sys.stdout.write(
206-
f"Progress: [{bar}] {progress * 100:.2f}% | Estimated time remaining: {formatted_time}\n"
204+
f"[NSIGHT-PYTHON] Progress: [{bar}] {progress * 100:.2f}% | Estimated time remaining: {formatted_time}\n"
207205
)
208206
sys.stdout.flush()
209207

210208
else:
211209
print(
212-
f"Progress: [{bar}] {progress * 100:.2f}% | Estimated time remaining: {formatted_time}"
210+
f"[NSIGHT-PYTHON] Progress: [{bar}] {progress * 100:.2f}% | Estimated time remaining: {formatted_time}"
213211
)
214212

215213

0 commit comments

Comments
 (0)