Skip to content

Commit 709cb21

Browse files
authored
Merge pull request #4 from bogdanminko/feature/powermetrics-docker
add powermetrics and full project to pypi
2 parents e940650 + ed96716 commit 709cb21

File tree

11 files changed

+1630
-107
lines changed

11 files changed

+1630
-107
lines changed

.github/workflows/docker-build.yml

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,30 @@
11
name: Docker Build and Push
22

3+
# Temporarily disabled
4+
# on:
5+
# push:
6+
# branches:
7+
# - main
8+
# paths:
9+
# - 'src/**'
10+
# - 'main.py'
11+
# - 'pyproject.toml'
12+
# - 'uv.lock'
13+
# - 'Dockerfile.laperf-cli'
14+
# tags:
15+
# - 'v*.*.*'
16+
# pull_request:
17+
# branches:
18+
# - main
19+
# paths:
20+
# - 'src/**'
21+
# - 'main.py'
22+
# - 'pyproject.toml'
23+
# - 'uv.lock'
24+
# - 'Dockerfile.laperf-cli'
25+
326
on:
4-
push:
5-
branches:
6-
- main
7-
paths:
8-
- 'src/**'
9-
- 'main.py'
10-
- 'pyproject.toml'
11-
- 'uv.lock'
12-
- 'Dockerfile.laperf-cli'
13-
tags:
14-
- 'v*.*.*'
15-
pull_request:
16-
branches:
17-
- main
18-
paths:
19-
- 'src/**'
20-
- 'main.py'
21-
- 'pyproject.toml'
22-
- 'uv.lock'
23-
- 'Dockerfile.laperf-cli'
27+
workflow_dispatch:
2428

2529
env:
2630
REGISTRY: docker.io
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
name: Publish laperf-power to PyPI
2+
3+
on:
4+
release:
5+
types: [published]
6+
branches:
7+
- main
8+
workflow_dispatch:
9+
inputs:
10+
test_pypi:
11+
description: 'Publish to TestPyPI instead of PyPI'
12+
required: false
13+
default: true
14+
type: boolean
15+
16+
jobs:
17+
build:
18+
name: Build laperf-power distribution
19+
runs-on: ubuntu-latest
20+
if: github.ref == 'refs/heads/main' || github.event_name == 'workflow_dispatch'
21+
22+
steps:
23+
- name: Checkout code
24+
uses: actions/checkout@v4
25+
26+
- name: Set up Python
27+
uses: actions/setup-python@v5
28+
with:
29+
python-version: "3.12"
30+
31+
- name: Install uv
32+
run: |
33+
python -m pip install --upgrade pip
34+
pip install uv
35+
36+
- name: Build laperf-power package
37+
run: |
38+
cd laperf-power
39+
uv build
40+
41+
- name: Store distribution packages
42+
uses: actions/upload-artifact@v4
43+
with:
44+
name: laperf-power-distributions
45+
path: laperf-power/dist/
46+
47+
publish-to-pypi:
48+
name: Publish laperf-power to PyPI
49+
if: github.event_name == 'release' && github.event.action == 'published'
50+
needs:
51+
- build
52+
runs-on: ubuntu-latest
53+
54+
environment:
55+
name: laperf-power-pypi
56+
url: https://pypi.org/p/laperf-power
57+
58+
permissions:
59+
id-token: write
60+
61+
steps:
62+
- name: Download distribution packages
63+
uses: actions/download-artifact@v4
64+
with:
65+
name: laperf-power-distributions
66+
path: dist/
67+
68+
- name: Publish to PyPI
69+
uses: pypa/gh-action-pypi-publish@release/v1
70+
71+
publish-to-testpypi:
72+
name: Publish laperf-power to TestPyPI
73+
if: github.event_name == 'workflow_dispatch' && inputs.test_pypi
74+
needs:
75+
- build
76+
runs-on: ubuntu-latest
77+
78+
environment:
79+
name: laperf-power-testpypi
80+
url: https://test.pypi.org/p/laperf-power
81+
82+
permissions:
83+
id-token: write
84+
85+
steps:
86+
- name: Download distribution packages
87+
uses: actions/download-artifact@v4
88+
with:
89+
name: laperf-power-distributions
90+
path: dist/
91+
92+
- name: Publish to TestPyPI
93+
uses: pypa/gh-action-pypi-publish@release/v1
94+
with:
95+
repository-url: https://test.pypi.org/legacy/

.github/workflows/publish-pypi.yml

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
name: Publish to PyPI
2+
3+
on:
4+
release:
5+
types: [published]
6+
branches:
7+
- main # Only trigger on releases from main branch
8+
workflow_dispatch:
9+
inputs:
10+
test_pypi:
11+
description: 'Publish to TestPyPI instead of PyPI'
12+
required: false
13+
default: true
14+
type: boolean
15+
16+
jobs:
17+
build:
18+
name: Build distribution
19+
runs-on: ubuntu-latest
20+
# Ensure we only build from main or when manually triggered
21+
if: github.ref == 'refs/heads/main' || github.event_name == 'workflow_dispatch'
22+
23+
steps:
24+
- name: Checkout code
25+
uses: actions/checkout@v4
26+
27+
- name: Set up Python
28+
uses: actions/setup-python@v5
29+
with:
30+
python-version: "3.12"
31+
32+
- name: Install uv
33+
run: |
34+
python -m pip install --upgrade pip
35+
pip install uv
36+
37+
- name: Build package
38+
run: uv build
39+
40+
- name: Store distribution packages
41+
uses: actions/upload-artifact@v4
42+
with:
43+
name: python-package-distributions
44+
path: dist/
45+
46+
publish-to-pypi:
47+
name: Publish to PyPI
48+
if: github.event_name == 'release' && github.event.action == 'published'
49+
needs:
50+
- build
51+
runs-on: ubuntu-latest
52+
53+
environment:
54+
name: pypi
55+
url: https://pypi.org/p/laperf
56+
57+
permissions:
58+
id-token: write # IMPORTANT: mandatory for trusted publishing
59+
60+
steps:
61+
- name: Download distribution packages
62+
uses: actions/download-artifact@v4
63+
with:
64+
name: python-package-distributions
65+
path: dist/
66+
67+
- name: Publish to PyPI
68+
uses: pypa/gh-action-pypi-publish@release/v1
69+
70+
publish-to-testpypi:
71+
name: Publish to TestPyPI
72+
if: github.event_name == 'workflow_dispatch' && inputs.test_pypi
73+
needs:
74+
- build
75+
runs-on: ubuntu-latest
76+
77+
environment:
78+
name: testpypi
79+
url: https://test.pypi.org/p/laperf
80+
81+
permissions:
82+
id-token: write # IMPORTANT: mandatory for trusted publishing
83+
84+
steps:
85+
- name: Download distribution packages
86+
uses: actions/download-artifact@v4
87+
with:
88+
name: python-package-distributions
89+
path: dist/
90+
91+
- name: Publish to TestPyPI
92+
uses: pypa/gh-action-pypi-publish@release/v1
93+
with:
94+
repository-url: https://test.pypi.org/legacy/

README.md

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,81 @@ This will:
157157

158158
---
159159

160+
## Power Monitoring Tool
161+
162+
La Perf includes a standalone real-time power monitoring tool that works independently from benchmarks.
163+
164+
### Installation & Usage
165+
166+
**Option 1: Run without installation (recommended)**
167+
```bash
168+
# Lightweight standalone package (~5 MB with psutil)
169+
uvx laperf-power
170+
171+
# With custom options
172+
uvx laperf-power --interval 1.0 --output metrics.json
173+
```
174+
175+
**Option 2: Install as a global tool**
176+
```bash
177+
# Lightweight standalone package
178+
uv tool install laperf-power
179+
# or: pip install laperf-power
180+
181+
# Now available everywhere
182+
laperf-power
183+
laperf-power --interval 10.0 --no-sudo
184+
```
185+
186+
**Option 3: Development mode (from source)**
187+
```bash
188+
git clone https://github.com/bogdanminko/laperf.git
189+
cd laperf/laperf-power
190+
uv pip install -e .
191+
laperf-power
192+
```
193+
194+
### CLI Options
195+
196+
```bash
197+
laperf-power [OPTIONS]
198+
199+
Options:
200+
--interval SECONDS Sampling interval in seconds (default: 10.0)
201+
--no-sudo Disable sudo powermetrics on macOS
202+
--output FILE Save results to JSON file
203+
-h, --help Show help message
204+
```
205+
206+
**Press Ctrl+C to stop and view statistics.**
207+
208+
### What it monitors
209+
210+
- **GPU**: Power (W), Utilization (%), VRAM (GB), Temperature (°C)
211+
- **CPU**: Power (W, macOS only with sudo), Utilization (%)
212+
- **System**: RAM usage (GB), Battery drain (%)
213+
214+
### Example Output
215+
216+
```
217+
⚡ REAL-TIME POWER MONITORING
218+
================================================================================
219+
Started: 2025-11-27 14:30:00
220+
Interval: 1.0s
221+
================================================================================
222+
223+
Press Ctrl+C to stop and view statistics
224+
225+
[Sample #42] GPU: 11.7W 32% 8.2GB | CPU: 15% 1.0W | RAM: 16.3GB | Temp: 45°C
226+
```
227+
228+
**Platform Support:**
229+
- **macOS**: Full support (with sudo for GPU/CPU power via `powermetrics`)
230+
- **Linux (NVIDIA)**: GPU metrics via `nvidia-smi`
231+
- **Windows**: Basic CPU/RAM metrics via `psutil`
232+
233+
---
234+
160235
## Running on GPU Servers (Docker)
161236

162237
For production deployments on cloud GPU instances or dedicated servers, you can use our Docker image:

0 commit comments

Comments
 (0)