Skip to content

Commit

Permalink
Add Python environment and version metadata to benchmark results
Browse files Browse the repository at this point in the history
  • Loading branch information
fabianliebig committed Feb 5, 2025
1 parent daaf4d1 commit c811a36
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions benchmarks/result/result.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

from __future__ import annotations

import sys

import importlib_metadata
from attrs import define, field
from attrs.validators import instance_of
from pandas import DataFrame
Expand All @@ -22,3 +25,17 @@ class Result(BenchmarkSerialization):

metadata: ResultMetadata = field(validator=instance_of(ResultMetadata))
"""The metadata associated with the benchmark result."""

python_env: dict[str, str] = field(validator=instance_of(dict))
"""The Python environment in which the benchmark was executed."""

python_version: str = field(default=sys.version, validator=instance_of(str))
"""The Python version in which the benchmark was executed."""

@python_env.default
def _default_python_env(self) -> dict[str, str]:
installed_packages = importlib_metadata.distributions()
package_dict = {
dist.metadata["Name"]: dist.version for dist in installed_packages
}
return package_dict

0 comments on commit c811a36

Please sign in to comment.