Skip to main content

train-guard

train-guard — Power-aware supervision for one long-running job.

Power-aware supervision for one long-running job.

CI

train-guard watches a laptop's power source, charge level and available battery temperature, then applies full, gentle or stop to one named process tree. The same policy can be replayed against a recorded trace before it controls a live job.

Train Guard is a workload policy, not a hardware safety controller. It does not set a charge limit or predict battery life, temperature, energy use or throughput.

Install 0.4.0

Install the published package with pipx:

pipx install "train-guard==0.4.0"
train-guard doctor

If the PyPI publication has not happened yet, validate the tagged source in a fresh checkout instead:

git clone --branch v0.4.0 --depth 1 \
  https://github.com/fus3r/train-guard.git
cd train-guard
python3 -m venv .venv
source .venv/bin/activate
python -m pip install .
train-guard doctor

Missing battery temperature is common on some systems, especially Windows, and disables temperature rules for that observation.

First disposable job

train-guard config --init
train-guard run --name quickstart -- \
  python3 -c "import time; print('quickstart running', flush=True); time.sleep(120)"
train-guard status
train-guard events quickstart --limit 10
train-guard stop quickstart

Without --kill, stop releases changes owned by Train Guard and detaches.

Replay and bounded sweeps

The source archive and tagged checkout include an example trace and policy files. From that checkout, a pipx or wheel installation can replay them without controlling a process.

Create a small policy grid as grid.json:

{"temp_pause_c": [40, 42, 44], "run_on_battery": [true, false]}

Then run the nominal and bounded analyses:

train-guard simulate examples/power-trace.jsonl \
  --config config.example.json
train-guard simulate examples/power-trace.jsonl \
  --config config.example.json \
  --temperature-uncertainty-c 0.5 \
  --charge-uncertainty-pct 1 --json
train-guard sweep examples/power-trace.jsonl \
  --grid grid.json --engine python \
  --temperature-uncertainty-c 0.5 \
  --charge-uncertainty-pct 1 --json

The uncertainty widths are supplied by the user; Train Guard does not infer sensor accuracy or attach a confidence level. Exactness is limited to the current threshold policy and the finite IEEE-754 binary64 representatives in the declared box. The action-change report gives divergence context, not a complete witness or certificate. Bounded-sweep survivors form a conservative outer enclosure, not an exact robust Pareto set.

Replay and sweep re-weight an exogenous recorded trace. They do not model how a different action would have changed later temperature, charge, performance or energy use.

For large source-checkout sweeps, the optional C++17 kernel keeps nominal TGK 1 and bounded TGS 1 as separate protocols:

cmake -S native -B native/build
cmake --build native/build --config Release
python tools/bench_sweep.py \
  --kernel native/build/train-guard-kernel --sensitivity

Python remains the reference, and native rows are accepted only after the baseline agrees bit for bit. The wheel is pure Python and does not ship the kernel. Benchmark timings are hardware-specific and are not release gates.

Documentation for this tag

The later documentation portal is built from these canonical Markdown files.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

train_guard-0.4.0.tar.gz (137.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

train_guard-0.4.0-py3-none-any.whl (67.6 kB view details)

Uploaded Python 3

File details

Details for the file train_guard-0.4.0.tar.gz.

File metadata

  • Download URL: train_guard-0.4.0.tar.gz
  • Upload date:
  • Size: 137.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for train_guard-0.4.0.tar.gz
Algorithm Hash digest
SHA256 ae5c2f6bfbff6fcd7286ceffcb445292f6c43967113b29a89b370ef2b891b2d3
MD5 9055f77a7c2521c4062630053cd27d62
BLAKE2b-256 e2112b73af20adaca01296cdf61dee8f0d1426d65c44e5267ccaf6678f1acb8d

See more details on using hashes here.

Provenance

The following attestation bundles were made for train_guard-0.4.0.tar.gz:

Publisher: release.yml on fus3r/train-guard

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file train_guard-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: train_guard-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 67.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for train_guard-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 01c648195e78d00bbc9df03c7ba2a25d312552fe273a53b550019c9bd130626b
MD5 59dd8db35a912e9af0ae2267d64dfb07
BLAKE2b-256 c9557e6b72bffd2cc466dfcc4d257d740a3b4d0d6d0c6d56deb4440a87e52d79

See more details on using hashes here.

Provenance

The following attestation bundles were made for train_guard-0.4.0-py3-none-any.whl:

Publisher: release.yml on fus3r/train-guard

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page