Skip to content

Commit

Permalink
Add Python environment and version metadata to benchmark results (#476)
Browse files Browse the repository at this point in the history
This PR adds the Python environment data and version to the benchmark result.
  • Loading branch information
AdrianSosic authored Feb 6, 2025
2 parents d519024 + 2aaf3a5 commit 55425de
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
21 changes: 20 additions & 1 deletion benchmarks/result/result.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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}

0 comments on commit 55425de

Please sign in to comment.