Skip to content

Commit 245b1f0

Browse files
committed
Updated the instructions to use treecript from within a container
1 parent 7c0a20a commit 245b1f0

1 file changed

Lines changed: 119 additions & 55 deletions

File tree

README.md

Lines changed: 119 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ A set of Python programs to monitor, collect, and digest metrics of a given Linu
2525
- [Collecting metrics](#collecting-metrics)
2626
- [Plotting time series charts](#plotting-time-series-charts)
2727
- [Finding CPU TDP](#finding-cpu-tdp)
28-
- [`tdp-finder.py` — from a metrics directory](#tdp-finderpy--from-a-metrics-directory)
29-
- [`cpuinfo-tdp-finder.py` — from `/proc/cpuinfo`](#cpuinfo-tdp-finderpy--from-proccpuinfo)
30-
- [`modelname-tdp-finder.py` — from a processor model string](#modelname-tdp-finderpy--from-a-processor-model-string)
28+
- [`tdp-finder` — from a metrics directory](#tdp-finder--from-a-metrics-directory)
29+
- [`cpuinfo-tdp-finder` — from `/proc/cpuinfo`](#cpuinfo-tdp-finder--from-proccpuinfo)
30+
- [`modelname-tdp-finder` — from a processor model string](#modelname-tdp-finder--from-a-processor-model-string)
3131
- [Digesting metrics](#digesting-metrics)
3232
- [CPU Dataset Setup](#cpu-dataset-setup)
3333
- [Output Files Reference](#output-files-reference)
@@ -65,7 +65,7 @@ treecript/
6565
| `sample-series/` | Real metrics collected from a WfExS workflow run, used throughout this README as examples |
6666
| `sample-charts/` | Pre-generated chart outputs (SVG/PDF/PNG) from the sample series |
6767
| `sample-work-to-measure/` | Ready-to-use scripts to download and run example workloads to measure |
68-
| `sample_cpuinfo/` | Example `/proc/cpuinfo` files (Intel and AMD) for testing `cpuinfo-tdp-finder.py` and `modelname-tdp-finder.py` without needing a real machine |
68+
| `sample_cpuinfo/` | Example `/proc/cpuinfo` files (Intel and AMD) for testing `cpuinfo-tdp-finder` and `modelname-tdp-finder` without needing a real machine |
6969
| `onboarding/` | Self-contained worked example: a full metrics collection, chart generation and aggregation walkthrough for new users |
7070
| `sample/` | Legacy single-process sample from 2018, predating the current process-tree approach |
7171
| `tests/` | Unit tests for the core collector module |
@@ -74,35 +74,38 @@ treecript/
7474

7575
## Installation
7676

77-
### Prerequisites
77+
### Prerequisites (singularity)
78+
79+
- Linux OS
80+
- [Singularity](https://sylabs.io/docs/) or [Apptainer](https://apptainer.org/).
81+
82+
### Prerequisites (native)
7883

7984
- Linux OS (Ubuntu recommended)
8085
- Python 3.9 or newer
8186
- Git
8287

8388
### Not sure which installation method to use?
8489

85-
| I want to... | Use |
86-
| ---------------------------------------------------------- | -------------------------------------------------------------- |
87-
| Keep things simple and already have Python installed | **Option 1 — pip + venv** |
88-
| Already use conda or manage multiple projects/environments | **Option 2 — Conda** |
89-
| Work on an HPC or shared cluster environment (e.g. BSC) | **Option 2 — Conda** |
90-
| Work on a machine with a corporate or university firewall | Either — both have firewall notes in their respective sections |
90+
| I want to... | Use |
91+
| ------------------------------------------------------------------------------ | -------------------------------------------------------------- |
92+
| Keep things simple, already have either Apptainer or Singularity installed and you only want to gather metrics | **Option 1 — Singularity** |
93+
| Keep things simple and already have Python installed | **Option 2 — pip + venv** |
94+
| Already use conda or manage multiple projects/environments | **Option 3 — Conda** |
95+
| Work on an HPC or shared cluster environment (e.g. BSC) | **Option 1 — Singularity** or **Option 3 — Conda** |
96+
| Work on a machine with a corporate or university firewall | Either — both have firewall notes in their respective sections |
9197

9298
---
9399

94-
### Choosing a constraints file
100+
### Choosing a constraints file (only needed for option 2 or option 3)
95101

96-
The repository ships per-version constraints files under the `installation/` directory to ensure a working set of dependencies. Pick the one that matches your setup:
102+
The repository ships per-version constraints files under the `installation/` directory to ensure a working set of dependencies. Pick the one that matches your setup (including the Python version):
97103

98104
| Situation | Constraints file to use |
99105
| ----------------------------- | ---------------------------------------------------- |
100-
| Native Linux, Python 3.9 | `installation/constraints-3.9.txt` |
101-
| Native Linux, Python 3.10 | `installation/constraints-3.10.txt` |
102-
| Native Linux, Python 3.11 | `installation/constraints-3.11.txt` |
103-
| Native Linux, Python 3.12 | `installation/constraints-3.12.txt` |
104-
| Ubuntu 22.04 on WSL (Windows) | `installation/constraints-3.10_Ubuntu-22.04-wsl.txt` |
105-
| Ubuntu 24.04 on WSL (Windows) | `installation/constraints-3.10_Ubuntu-24.04-wsl.txt` |
106+
| Native Linux, Python 3.x | `installation/constraints-3.x.txt` |
107+
| Ubuntu 22.04 on WSL (Windows) | `installation/constraints-3.x_Ubuntu-22.04-wsl.txt` |
108+
| Ubuntu 24.04 on WSL (Windows) | `installation/constraints-3.x_Ubuntu-24.04-wsl.txt` |
106109

107110
> **WSL** = Windows Subsystem for Linux — Ubuntu running inside Windows rather than directly on hardware. If you are running Ubuntu natively on your machine, use the plain constraints file. To check:
108111
>
@@ -118,7 +121,55 @@ python3 --version
118121
119122
---
120123

121-
### Option 1: pip + virtual environment (venv)
124+
### Option 1: Singularity
125+
126+
#### Alternative A: Fetch a pre-built image (only for metrics gathering)
127+
128+
Pre-build singularity images are listed at https://github.com/inab/treecript/pkgs/container/treecript .
129+
130+
They can be fetched using Apptainer/Singularity just using `singularity pull` subcommand:
131+
132+
```bash
133+
# Replace exec by the tag of the version you want to use
134+
singularity pull oras://ghcr.io/inab/treecript:exec
135+
136+
# The name of the created file depends on the tag
137+
ls -l treecript-exec.sif
138+
```
139+
140+
#### Alternative B: Building from source
141+
142+
When no file is locally, but you already have either Apptainer or Singularity installed:
143+
144+
```bash
145+
# TREECRIPT_VER can be either a branch, a tag or a commit hash
146+
TREECRIPT_VER=7c0a20a688518e43952d7bd7080bc34b863e32da
147+
148+
# If you don't have the recipe, you can fetch it using either curl or wget
149+
mkdir -p treecript_SIF_build/installation
150+
cd treecript_SIF_build/installation
151+
curl -O https://raw.githubusercontent.com/inab/treecript/${TREECRIPT_VER}/installation/Singularity.def
152+
cd ..
153+
```
154+
155+
If you have already checked out the code
156+
157+
```bash
158+
# Alternatively, you can use a checked out copy
159+
cd treecript
160+
TREECRIPT_VER=$(git rev-parse HEAD)
161+
```
162+
163+
At last, you can build the SIF image with next command:
164+
165+
```
166+
singularity build --build-arg treecript_checkout="${TREECRIPT_VER}" \
167+
treecript-${TREECRIPT_VER}.sif installation/Singularity.def
168+
```
169+
170+
---
171+
172+
### Option 2: pip + virtual environment (venv)
122173

123174
Use this if you already have Python installed on your system and don't use conda. This is the lightest option — it creates an isolated Python environment using only tools that come built into Python, with no additional software required.
124175

@@ -136,7 +187,7 @@ pip install --upgrade pip wheel
136187
wget https://raw.githubusercontent.com/inab/treecript/exec/installation/constraints-3.10.txt
137188

138189
# 5. Install treecript with constraints
139-
pip install -c constraints-3.10.txt git+https://github.com/inab/treecript.git@exec
190+
pip install -c constraints-3.10.txt 'treecript [analytics,docker] @ git+https://github.com/inab/treecript.git@exec'
140191
```
141192

142193
> **Network issues?** If you are behind a corporate or university firewall (e.g. Fortiguard), add `--no-check-certificate` to the `wget` command.
@@ -155,7 +206,7 @@ source TREECRIPT/bin/activate
155206

156207
---
157208

158-
### Option 2: Conda environment
209+
### Option 3: Conda environment
159210

160211
Use this if you already work with Anaconda or Miniconda, or if you prefer conda for managing environments across multiple projects. Conda handles both Python and system-level dependencies, which makes it particularly well suited for HPC or shared computing environments.
161212

@@ -202,7 +253,7 @@ wget https://raw.githubusercontent.com/inab/treecript/exec/installation/constrai
202253
# wget https://raw.githubusercontent.com/inab/treecript/exec/installation/constraints-3.10_Ubuntu-22.04-wsl.txt
203254
204255
# 4. Install treecript and all dependencies in one shot
205-
pip install -c constraints-3.10.txt git+https://github.com/inab/treecript.git@exec
256+
pip install -c constraints-3.10.txt 'treecript [analytics,docker] @ git+https://github.com/inab/treecript.git@exec'
206257
```
207258
208259
To deactivate:
@@ -238,20 +289,33 @@ import treecript; print('treecript OK')
238289

239290
---
240291

241-
## Quick Start
292+
## Quick Start (Singularity/Apptainer)
293+
294+
At the moment, it is limited to metrics gathering
295+
296+
```bash
297+
# 1. Collect metrics for a command in background
298+
my_command --arg1 --arg2 &
299+
300+
# bash puts the PID of the last background process in $! variable
301+
# This way is needed because the
302+
singularity exec treecript-exec.sif process-metrics-collector $! ~/my_metrics
303+
```
304+
305+
## Quick Start (other options)
242306

243307
```bash
244308
# 1. Collect metrics for a command
245-
execution-metrics-collector.py ~/my_metrics my_command --arg1 --arg2
309+
execution-metrics-collector ~/my_metrics my_command --arg1 --arg2
246310

247311
# 2. Plot time series charts
248-
plotGraph.py ~/my_metrics/2025_01_01-00_00-12345/ ~/my_charts/
312+
plotGraph ~/my_metrics/2025_01_01-00_00-12345/ ~/my_charts/
249313

250314
# 3. Find your CPU's TDP
251-
tdp-finder.py ~/my_metrics/2025_01_01-00_00-12345/ cpu-spec-dataset_Josua/dataset/*.csv
315+
tdp-finder ~/my_metrics/2025_01_01-00_00-12345/ cpu-spec-dataset_Josua/dataset/*.csv
252316

253317
# 4. Aggregate and estimate energy consumption
254-
metrics-aggregator.py ~/my_metrics/2025_01_01-00_00-12345/ ~/my_agg/ 28.0
318+
metrics-aggregator ~/my_metrics/2025_01_01-00_00-12345/ ~/my_agg/ 28.0
255319
```
256320

257321
---
@@ -260,38 +324,38 @@ metrics-aggregator.py ~/my_metrics/2025_01_01-00_00-12345/ ~/my_agg/ 28.0
260324

261325
### Collecting metrics
262326

263-
`execution-metrics-collector.py` runs a command and monitors it and all its child processes:
327+
`execution-metrics-collector` runs a command and monitors it and all its child processes:
264328

265329
```bash
266-
execution-metrics-collector.py {base_metrics_directory} {command} {args...}
330+
execution-metrics-collector {base_metrics_directory} {command} {args...}
267331
```
268332

269-
Internally this launches the command, captures its PID, and calls `process-metrics-collector.py` with a sampling period of 1 second:
333+
Internally this launches the command, captures its PID, and calls `process-metrics-collector` with a sampling period of 1 second:
270334

271335
```bash
272-
process-metrics-collector.py {pid} {base_metrics_directory} {sample_period}
336+
process-metrics-collector {pid} {base_metrics_directory} [sample_period]
273337
```
274338

275339
Example:
276340

277341
```bash
278-
execution-metrics-collector.py ~/metrics python myscript.py --input data.txt
342+
execution-metrics-collector ~/metrics python myscript.py --input data.txt
279343
```
280344

281345
---
282346

283347
### Plotting time series charts
284348

285-
`plotGraph.py` generates line charts for each monitored process, comparing time series of CPU, memory, I/O and other metrics:
349+
`plotGraph` generates line charts for each monitored process, comparing time series of CPU, memory, I/O and other metrics:
286350

287351
```bash
288-
plotGraph.py {metrics_directory} {output_directory}
352+
plotGraph {metrics_directory} {output_directory}
289353
```
290354

291355
Example:
292356

293357
```bash
294-
plotGraph.py ~/metrics/2025_01_01-00_00-12345/ ~/charts/
358+
plotGraph ~/metrics/2025_01_01-00_00-12345/ ~/charts/
295359
```
296360

297361
---
@@ -300,62 +364,62 @@ plotGraph.py ~/metrics/2025_01_01-00_00-12345/ ~/charts/
300364

301365
Three programs are available depending on what information you have:
302366

303-
#### `tdp-finder.py` — from a metrics directory
367+
#### `tdp-finder` — from a metrics directory
304368

305369
```bash
306-
tdp-finder.py {metrics_directory} {csv_files...}
370+
tdp-finder {metrics_directory} {csv_files...}
307371
```
308372

309373
Example:
310374

311375
```bash
312-
tdp-finder.py ~/metrics/2025_01_01-00_00-12345/ cpu-spec-dataset_Josua/dataset/*.csv cpumark_table.csv
376+
tdp-finder ~/metrics/2025_01_01-00_00-12345/ cpu-spec-dataset_Josua/dataset/*.csv cpumark_table.csv
313377
```
314378

315379
Use `-q` for quiet mode (outputs only the TDP value, useful for scripting):
316380

317381
```bash
318-
tdp-finder.py -q ~/metrics/2025_01_01-00_00-12345/ cpu-spec-dataset_Josua/dataset/*.csv
382+
tdp-finder -q ~/metrics/2025_01_01-00_00-12345/ cpu-spec-dataset_Josua/dataset/*.csv
319383
# Output: 28.0
320384
```
321385

322-
#### `cpuinfo-tdp-finder.py` — from `/proc/cpuinfo`
386+
#### `cpuinfo-tdp-finder` — from `/proc/cpuinfo`
323387

324388
Does not require a metrics directory:
325389

326390
```bash
327-
cpuinfo-tdp-finder.py /proc/cpuinfo cpu-spec-dataset_Josua/dataset/*.csv cpumark_table.csv
391+
cpuinfo-tdp-finder /proc/cpuinfo cpu-spec-dataset_Josua/dataset/*.csv cpumark_table.csv
328392
```
329393

330394
Or from a saved copy of `/proc/cpuinfo` — the `sample_cpuinfo/` directory contains example files for Intel and AMD processors you can use for testing:
331395

332396
```bash
333-
cpuinfo-tdp-finder.py sample_cpuinfo/cpuinfo-amd.txt cpu-spec-dataset_Josua/dataset/*.csv
397+
cpuinfo-tdp-finder sample_cpuinfo/cpuinfo-amd.txt cpu-spec-dataset_Josua/dataset/*.csv
334398
```
335399

336-
#### `modelname-tdp-finder.py` — from a processor model string
400+
#### `modelname-tdp-finder` — from a processor model string
337401

338402
```bash
339-
modelname-tdp-finder.py "11th Gen Intel(R) Core(TM) i7-1185G7 @ 3.00GHz" cpu-spec-dataset_Josua/dataset/*.csv
340-
modelname-tdp-finder.py "AMD EPYC 7742 64-Core Processor" cpu-spec-dataset_Josua/dataset/*.csv cpumark_table.csv
403+
modelname-tdp-finder "11th Gen Intel(R) Core(TM) i7-1185G7 @ 3.00GHz" cpu-spec-dataset_Josua/dataset/*.csv
404+
modelname-tdp-finder "AMD EPYC 7742 64-Core Processor" cpu-spec-dataset_Josua/dataset/*.csv cpumark_table.csv
341405
```
342406

343407
---
344408

345409
### Digesting metrics
346410

347-
`metrics-aggregator.py` digests the collected time series and estimates energy consumption per process subtree. It requires the CPU TDP value in Watts.
411+
`metrics-aggregator` digests the collected time series and estimates energy consumption per process subtree. It requires the CPU TDP value in Watts.
348412

349413
```bash
350-
metrics-aggregator.py {metrics_directory} {output_directory} {TDP_watts} [command_filter]
414+
metrics-aggregator {metrics_directory} {output_directory} {TDP_watts} [command_filter]
351415
```
352416

353417
The optional `command_filter` argument filters results to show only processes whose command matches the string (e.g. `"docker run"` to focus on Docker steps).
354418

355419
Example using the included sample series:
356420

357421
```bash
358-
metrics-aggregator.py sample-series/Wetlab2Variations_metrics/2025_05_20-02_19-14001/ dest_directory 28.0 "docker run"
422+
metrics-aggregator sample-series/Wetlab2Variations_metrics/2025_05_20-02_19-14001/ dest_directory 28.0 "docker run"
359423
```
360424

361425
The output directory will contain:
@@ -398,14 +462,14 @@ python -m treecript.tdp_sources cpumark_table.csv
398462
You can pass multiple sources to the TDP programs and they will be tried in order:
399463

400464
```bash
401-
tdp-finder.py ~/metrics/dir/ cpu-spec-dataset_Josua/dataset/*.csv cpumark_table.csv
465+
tdp-finder ~/metrics/dir/ cpu-spec-dataset_Josua/dataset/*.csv cpumark_table.csv
402466
```
403467

404468
---
405469

406470
## Output Files Reference
407471

408-
Each `execution-metrics-collector.py` run creates a subdirectory named after the start timestamp and PID. It contains:
472+
Each `execution-metrics-collector` run creates a subdirectory named after the start timestamp and PID. It contains:
409473

410474
| File | Description |
411475
| ---------------------------------- | -------------------------------------------------------------- |
@@ -482,13 +546,13 @@ The `legacy/` directory contains older Bash-based scripts that predate the curre
482546

483547
### `execution-metrics-collector.sh`
484548

485-
The original Bash wrapper for launching a command and monitoring it. It runs the command in the background, captures the PID, and calls `process-metrics-collector.py` directly:
549+
The original Bash wrapper for launching a command and monitoring it. It runs the command in the background, captures the PID, and calls `process-metrics-collector` directly:
486550

487551
```bash
488552
./legacy/execution-metrics-collector.sh {base_metrics_directory} {command} {args...}
489553
```
490554

491-
This has been superseded by `execution-metrics-collector.py`, which provides the same functionality in a more portable and maintainable way. The sample series included in this repository was originally collected using this script:
555+
This has been superseded by `execution-metrics-collector`, which provides the same functionality in a more portable and maintainable way. The sample series included in this repository was originally collected using this script:
492556

493557
```bash
494558
~/projects/treecript/legacy/execution-metrics-collector.sh \
@@ -499,15 +563,15 @@ This has been superseded by `execution-metrics-collector.py`, which provides the
499563

500564
### `plotGraph.sh`
501565

502-
The original gnuplot-based visualization script. It reads the collected CSV files and generates `.pdf` charts using `gnuplot` (requires `apt install gnuplot`). It has been superseded by `plotGraph.py`, which generates richer charts without requiring gnuplot.
566+
The original gnuplot-based visualization script. It reads the collected CSV files and generates `.pdf` charts using `gnuplot` (requires `apt install gnuplot`). It has been superseded by `plotGraph`, which generates richer charts without requiring gnuplot.
503567

504568
```bash
505569
./legacy/plotGraph.sh {metrics_csv_files...}
506570
```
507571

508572
### `plot-metrics.sh`
509573

510-
An earlier helper script for plotting individual metric files. Also superseded by `plotGraph.py`.
574+
An earlier helper script for plotting individual metric files. Also superseded by `plotGraph`.
511575

512576
> These scripts are no longer actively maintained. For all new usage, prefer the Python equivalents.
513577

0 commit comments

Comments
 (0)