Skip to content
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
14 changes: 9 additions & 5 deletions bencher/bencher.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@
from bencher.utils import params_to_str
from bencher.sample_order import SampleOrder

# Default cache size for benchmark results (100 GB)
DEFAULT_CACHE_SIZE_BYTES = int(100e9)

# Customize the formatter
formatter = logging.Formatter("%(levelname)s: %(message)s")
logging.basicConfig(level=logging.INFO, format="%(levelname)s %(message)s")
Expand Down Expand Up @@ -157,15 +160,15 @@
If None, a new report will be created. Defaults to None.

Raises:
AssertionError: If bench_name is not a string.
TypeError: If bench_name is not a string.
RuntimeError: If worker is a class type instead of an instance.
"""
assert isinstance(bench_name, str)
if not isinstance(bench_name, str):
raise TypeError(f"bench_name must be a string, got {type(bench_name).__name__}")

Check warning on line 167 in bencher/bencher.py

View check run for this annotation

Codecov / codecov/patch

bencher/bencher.py#L167

Added line #L167 was not covered by tests
self.bench_name = bench_name
self.worker = None
self.worker_class_instance = None
self.worker_input_cfg = None
self.worker_class_instance = None
self.set_worker(worker, worker_input_cfg)
self.run_cfg = run_cfg
if report is None:
Expand All @@ -181,7 +184,7 @@
self.sample_cache = None # store the results of each benchmark function call in a cache
self.ds_dynamic = {} # A dictionary to store unstructured vector datasets

self.cache_size = int(100e9) # default to 100gb
self.cache_size = DEFAULT_CACHE_SIZE_BYTES

# self.bench_cfg = BenchCfg()

Expand Down Expand Up @@ -414,7 +417,8 @@
for k, v in input_vars_in.items():
param_var = self.convert_vars_to_params(k, "input", run_cfg)
if isinstance(v, list):
assert len(v) > 0
if len(v) == 0:
raise ValueError(f"Input variable '{k}' cannot be an empty list")
param_var = param_var.with_sample_values(v)

else:
Expand Down
11 changes: 10 additions & 1 deletion bencher/utils_rerun.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,24 @@
import logging
from importlib.metadata import version as get_package_version, PackageNotFoundError
from rerun.legacy_notebook import as_html
import rerun as rr
import panel as pn
from .utils import publish_file, gen_rerun_data_path


def _get_rerun_version() -> str:
"""Get the installed rerun package version."""
try:
return get_package_version("rerun-sdk")
except PackageNotFoundError:
return "0.20.1" # Fallback version

Check warning on line 14 in bencher/utils_rerun.py

View check run for this annotation

Codecov / codecov/patch

bencher/utils_rerun.py#L11-L14

Added lines #L11 - L14 were not covered by tests


def rrd_to_pane(
url: str, width: int = 500, height: int = 600, version: str = None
): # pragma: no cover
if version is None:
version = "0.20.1" # TODO find a better way of doing this
version = _get_rerun_version()
return pn.pane.HTML(
f'<iframe src="https://app.rerun.io/version/{version}/?url={url}" width={width} height={height}></iframe>'
)
Expand Down