Skip to content

Commit

Permalink
chore: extract hwgraph dependencies into a extra group
Browse files Browse the repository at this point in the history
This allows users to install the "graph" group optionally. This is useful for server environments without graphical libraries where you do not need the hwgraph command anyway.

Signed-off-by: Arno Dubois <[email protected]>
  • Loading branch information
Arno500 authored and Arno Dubois committed Oct 30, 2024
1 parent 1d65cc0 commit 18aa394
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 17 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ We do not (yet, coming at some point) provide a PyPi package. However, installat
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`!

---
Expand Down
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
14 changes: 9 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,7 @@ requires-python = ">=3.9"
dependencies = [
"cachetools",
"redfish",
"packaging",
"numpy",
"matplotlib>3.5.0",
"pillow>=11.0.0",
"pycairo",
"packaging"
]

[project.urls]
Expand All @@ -38,3 +34,11 @@ dev = [
"types-cachetools>=5.5.0.20240820",
"uv>=0.4.27"
]

[project.optional-dependencies]
graph = [
"numpy",
"matplotlib>3.5.0",
"pillow>=11.0.0",
"pycairo",
]

0 comments on commit 18aa394

Please sign in to comment.