Skip to content

Commit 301275b

Browse files
committed
readme: demo ValueError guidance
1 parent ff5cca2 commit 301275b

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,22 @@ In [4]: amdgpu_stats.utils.get_clock('core', format_freq=True)
4747
Out[4]: '659 MHz'
4848
```
4949

50+
Attempts are made to provide guidance as `ValueErrors`. For example:
51+
52+
```python
53+
In [2]: amdgpu_stats.utils.CARDS
54+
Out[2]: {'card1': '/sys/class/drm/card1/device/hwmon/hwmon3'}
55+
56+
In [3]: amdgpu_stats.utils.get_core_stats('card0')
57+
[...]
58+
File ~/.local/lib/python3.12/site-packages/amdgpu_stats/utils.py:82, in validate_card(card)
59+
80 raise ValueError("No AMD GPUs or hwmon directories found")
60+
81 # if 'card' was specified (not None) but invalid (not in 'CARDS'), raise a helpful error
61+
---> 82 raise ValueError(f"Invalid card: '{card}'. Must be one of: {list(CARDS.keys())}")
62+
63+
ValueError: Invalid card: 'card0'. Must be one of: ['card1']
64+
```
65+
5066
For more information on what the module provides, please see:
5167

5268
- [ReadTheDocs](https://amdgpu-stats.readthedocs.io/en/latest/)

0 commit comments

Comments
 (0)