Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New tooling for dependency management and building #43

Merged
merged 3 commits into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions .github/workflows/python-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
build:
name: Check if every commit in the PR works
runs-on: ubuntu-latest
timeout-minutes: 60
timeout-minutes: 10
strategy:
fail-fast: false
matrix:
Expand All @@ -24,16 +24,23 @@ jobs:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: ${{ env.PR_FETCH_DEPTH }}

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
- name: Install uv
uses: astral-sh/setup-uv@v3
with:
python-version: ${{ matrix.python-version }}
version: "0.4.28"
enable-cache: true

- name: Set up Python ${{ matrix.python-version }}
run: uv python install ${{ matrix.python-version }}

- name: Test every commit in the PR for Python ${{ matrix.python-version }}
run: |
COMMITS=$(git rev-list ${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }})
for commit in $COMMITS; do
git checkout $commit || exit 1
git show --no-patch --format='Testing commit %h %s'
make check || exit 1
make sync_deps check_ci bundle || exit 1
done

- name: Minimize uv cache
run: uv cache prune --ci
15 changes: 9 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# ignore misc build/test files
.env-lint
# ignore uv venv
.venv

# ignore standard cache folders
.*_cache

# ignore built files
*.pyc
.ruff-cache
dist

hwbench-out-*
hwbench.egg-info
.coverage
junit-python*.xml
57 changes: 29 additions & 28 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,36 +1,37 @@
all:

.PHONY: update_deps clean check format
.PHONY: update_deps update_lock sync_deps clean check check_ci bundle format

UPDATE_DEPS_ENV = .env-deps
LINT_ENV = .env-lint
SOURCES = hwbench csv graph

SOURCES = hwbench setup.py csv graph
update_deps:
uv sync -U

update_env:
python3 -m venv $(UPDATE_DEPS_ENV)
./$(UPDATE_DEPS_ENV)/bin/pip install --upgrade --quiet pip-tools
update_lock:
uv lock

update_deps: update_env
./$(UPDATE_DEPS_ENV)/bin/pip-compile --upgrade --output-file=requirements/base.txt requirements/base.in
./$(UPDATE_DEPS_ENV)/bin/pip-compile --upgrade --output-file=requirements/test.txt requirements/test.in

regen_hashes: update_env
./$(UPDATE_DEPS_ENV)/bin/pip-compile --output-file=requirements/base.txt requirements/base.in
./$(UPDATE_DEPS_ENV)/bin/pip-compile --output-file=requirements/test.txt requirements/test.in
sync_deps:
uv sync --all-extras --dev

clean:
rm -fr $(UPDATE_DEPS_ENV) $(LINT_ENV)

$(LINT_ENV):
python3 -m venv $(LINT_ENV)
./$(LINT_ENV)/bin/pip install -r requirements/test.txt

check: $(LINT_ENV)
env PYTHON=python3 ./$(LINT_ENV)/bin/tox

bundle: $(LINT_ENV)
env PYTHON=python3 ./$(LINT_ENV)/bin/tox -e bundle

format: $(LINT_ENV)
./$(LINT_ENV)/bin/ruff format $(SOURCES)
uv venv

check:
@uv lock --locked || echo "Your lock file should change because you probably added a dependency or bump the minimal Python version. Please run `uv lock`"
uv tool run ruff format --diff $(SOURCES)
uv tool run ruff check $(SOURCES)
uv run mypy $(SOURCES)
uv run pytest $(SOURCES)

check_ci:
@uv lock --locked || echo "Your lock file should change because you probably added a dependency or bump the minimal Python version, but this is not allowed in the CI. Please run `uv lock`"
uv tool run ruff format --diff $(SOURCES)
uv tool run ruff check --output-format=github $(SOURCES)
uv run mypy $(SOURCES)
uv run pytest $(SOURCES)

bundle:
uv build

format:
uv tool run ruff format $(SOURCES)
41 changes: 34 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,22 +63,49 @@ If multiple output files are passed as arguments, and only if they were generate

For more details, see the specific documentation.

# Examples
Running the **simple.conf** job:
<code>python3 -m hwbench.hwbench -j configs/simple.conf -m monitoring.cfg</code>
---

# Installation

# Requirements
## Mandatory
You will first need the following packages on your machine, depending on what you want to run:
1. The "main" tool: `hwbench`; you will install this on your server, or the machine you want to analyse
2. The "graphing" tool: `hwgraph`; this is the part used to parse `hwbench`'s output that will create those nice graphs for you to analyse and compare the runs!
You can install both of them on the server, but `hwgraph` requires some graphics library not always convenient to install in reduced environments.

### Requirements to run hwbench
#### Mandatory
- python >= 3.9
- [python dependencies](./requirements/base.in)
- turbostat >= 2022.04.16
- numactl
- dmidecode
- util-linux >= 2.32
- lspci
- rpm

## Optional
#### Optional
- ipmitool
- ilorest (for HPE servers)
- stress-ng >= 0.17.04

### Requirements to run hwgraph
#### Mandatory
- python >= 3.9
- Headers for Cairo (`cairo-devel` on RHEL-based or `libcairo2-dev` for Debian-based)
- Python 3 headers for your current interpreter (`python3-devel` on RHEL-based or `python3-dev` for Debian-based)


## Actual installation
We do not (yet, coming at some point) provide a PyPi package. However, installation is almost just as simple:
1. Clone the repository
2. Make sure that you have all the requirements above already installed on your system
3. Install a recent version of `uv` on your system: we require a version above 0.4.27, so you can just do a `pip install uv` on your system to install the latest release. If you are on Ubuntu or another Debian-derivative, you may receive an error and need to follow the guide on [uv's official website](https://docs.astral.sh/uv/getting-started/installation/).
4. Run `uv sync` in the repository.
> [!WARNING]
> If you want to also include the dependencies for the plotting, run `uv sync --extra graph` instead!
5. Have fun running `uv run hwbench` (as root) and `uv run hwgraph`!

---

# Examples
Running the **simple.conf** job:
<code>python3 -m hwbench.hwbench -j configs/simple.conf -m monitoring.cfg</code>
31 changes: 19 additions & 12 deletions graph/hwgraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,25 @@
import sys
from typing import Any # noqa: F401

from graph.common import fatal
from graph.graph import init_matplotlib, generic_graph, yerr_graph
from graph.individual import individual_graph
from graph.scaling import scaling_graph
from graph.chassis import graph_chassis
from graph.trace import Trace
from hwbench.bench.monitoring_structs import (
FanContext,
PowerCategories,
PowerContext,
Metrics,
)
try:
from graph.common import fatal
from graph.graph import init_matplotlib, generic_graph, yerr_graph
from graph.individual import individual_graph
from graph.scaling import scaling_graph
from graph.chassis import graph_chassis
from graph.trace import Trace
from hwbench.bench.monitoring_structs import (
FanContext,
PowerCategories,
PowerContext,
Metrics,
)
except ImportError as exc:
print(exc)
print(
'Could not start hwgraph: did you make sure to also install the "graph" optional dependencies using `uv sync --extra graph` or `pip install hwbench[graph]`?'
)
sys.exit(1)


def valid_trace_file(trace_arg: str) -> Trace:
Expand Down
53 changes: 44 additions & 9 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,44 @@
[tool.pip-tools]
rebuild = true
generate-hashes = true
resolver = "backtracking"
allow-unsafe = true
no-emit-index-url = true
no-emit-trusted-host = true
quiet = true
strip-extras = true
[build-system]
requires = ["hatchling>=1.25.0"]
build-backend = "hatchling.build"

[project]
name = "hwbench"
authors = [{name = "Erwan Velu", email = "[email protected]"}, {name = "Anisse Astier", email = "[email protected]"}, {name = "Aurélien Rougemont", email="[email protected]"}]
description = "hwbench is a benchmark orchestrator to automate the low-level testing of servers"
version = "0.1.0"
readme = "README.md"
requires-python = ">=3.9"
dependencies = [
"cachetools",
"redfish",
"packaging"
]

[project.urls]
Home = "https://github.com/criteo/hwbench"

[project.scripts]
hwbench = "hwbench.hwbench:main"
hwgraph = "graph.hwgraph:main"

[tool.hatch.build]
packages = ["hwbench", "graph"]

[dependency-groups]
dev = [
"cachetools>=4.2.4",
"mypy",
"pytest>=8.3.3",
"ruff>=0.7.1",
"types-cachetools>=5.5.0.20240820",
"uv>=0.4.27"
]

[project.optional-dependencies]
graph = [
"numpy",
"matplotlib>3.5.0",
"pillow>=11.0.0",
"pycairo",
]
6 changes: 0 additions & 6 deletions requirements/base.in

This file was deleted.

Loading