diff --git a/CHANGELOG.md b/CHANGELOG.md index e1f61da8f2..ad0c8d6251 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] ### Added - `BCUT2D` encoding for `SubstanceParameter` +- Stored benchmarking results now include the Python environment and version ## [0.12.2] - 2025-01-31 ### Changed diff --git a/benchmarks/result/result.py b/benchmarks/result/result.py index 842052c290..ac0e8fdde0 100644 --- a/benchmarks/result/result.py +++ b/benchmarks/result/result.py @@ -2,8 +2,11 @@ from __future__ import annotations +import sys + +import importlib_metadata from attrs import define, field -from attrs.validators import instance_of +from attrs.validators import deep_mapping, instance_of from pandas import DataFrame from benchmarks.result import ResultMetadata @@ -22,3 +25,19 @@ class Result(BenchmarkSerialization): metadata: ResultMetadata = field(validator=instance_of(ResultMetadata)) """The metadata associated with the benchmark result.""" + + python_env: dict[str, str] = field( + init=False, + validator=deep_mapping(instance_of(str), instance_of(str), instance_of(dict)), + ) + """The Python environment in which the benchmark was executed.""" + + python_version: str = field( + init=False, default=sys.version, validator=instance_of(str) + ) + """The Python version with which the benchmark was executed.""" + + @python_env.default + def _default_python_env(self) -> dict[str, str]: + installed_packages = importlib_metadata.distributions() + return {dist.metadata["Name"]: dist.version for dist in installed_packages}