holobench 1.41.0__py3-none-any.whl → 1.43.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. bencher/__init__.py +20 -2
  2. bencher/bench_cfg.py +262 -54
  3. bencher/bench_report.py +2 -2
  4. bencher/bench_runner.py +96 -10
  5. bencher/bencher.py +421 -89
  6. bencher/class_enum.py +70 -7
  7. bencher/example/example_dataframe.py +2 -2
  8. bencher/example/example_levels.py +17 -173
  9. bencher/example/example_pareto.py +107 -31
  10. bencher/example/example_rerun2.py +1 -1
  11. bencher/example/example_simple_bool.py +2 -2
  12. bencher/example/example_simple_float2d.py +6 -1
  13. bencher/example/example_video.py +2 -0
  14. bencher/example/experimental/example_hvplot_explorer.py +2 -2
  15. bencher/example/inputs_0D/example_0_in_1_out.py +25 -15
  16. bencher/example/inputs_0D/example_0_in_2_out.py +12 -3
  17. bencher/example/inputs_0_float/example_0_cat_in_2_out.py +88 -0
  18. bencher/example/inputs_0_float/example_1_cat_in_2_out.py +98 -0
  19. bencher/example/inputs_0_float/example_2_cat_in_2_out.py +107 -0
  20. bencher/example/inputs_0_float/example_3_cat_in_2_out.py +111 -0
  21. bencher/example/inputs_1D/example1d_common.py +48 -12
  22. bencher/example/inputs_1D/example_0_float_1_cat.py +33 -0
  23. bencher/example/inputs_1D/example_1_cat_in_2_out_repeats.py +68 -0
  24. bencher/example/inputs_1D/example_1_float_2_cat_repeats.py +3 -0
  25. bencher/example/inputs_1D/example_1_int_in_1_out.py +98 -0
  26. bencher/example/inputs_1D/example_1_int_in_2_out.py +101 -0
  27. bencher/example/inputs_1D/example_1_int_in_2_out_repeats.py +99 -0
  28. bencher/example/inputs_1_float/example_1_float_0_cat_in_2_out.py +117 -0
  29. bencher/example/inputs_1_float/example_1_float_1_cat_in_2_out.py +124 -0
  30. bencher/example/inputs_1_float/example_1_float_2_cat_in_2_out.py +132 -0
  31. bencher/example/inputs_1_float/example_1_float_3_cat_in_2_out.py +140 -0
  32. bencher/example/inputs_2D/example_2_cat_in_4_out_repeats.py +104 -0
  33. bencher/example/inputs_2_float/example_2_float_0_cat_in_2_out.py +98 -0
  34. bencher/example/inputs_2_float/example_2_float_1_cat_in_2_out.py +112 -0
  35. bencher/example/inputs_2_float/example_2_float_2_cat_in_2_out.py +122 -0
  36. bencher/example/inputs_2_float/example_2_float_3_cat_in_2_out.py +138 -0
  37. bencher/example/inputs_3_float/example_3_float_0_cat_in_2_out.py +111 -0
  38. bencher/example/inputs_3_float/example_3_float_1_cat_in_2_out.py +117 -0
  39. bencher/example/inputs_3_float/example_3_float_2_cat_in_2_out.py +124 -0
  40. bencher/example/inputs_3_float/example_3_float_3_cat_in_2_out.py +129 -0
  41. bencher/example/meta/generate_examples.py +118 -7
  42. bencher/example/meta/generate_meta.py +88 -40
  43. bencher/job.py +174 -9
  44. bencher/plotting/plot_filter.py +52 -17
  45. bencher/results/bench_result.py +117 -25
  46. bencher/results/bench_result_base.py +117 -8
  47. bencher/results/dataset_result.py +6 -200
  48. bencher/results/explorer_result.py +23 -0
  49. bencher/results/{hvplot_result.py → histogram_result.py} +3 -18
  50. bencher/results/holoview_results/__init__.py +0 -0
  51. bencher/results/holoview_results/bar_result.py +79 -0
  52. bencher/results/holoview_results/curve_result.py +110 -0
  53. bencher/results/holoview_results/distribution_result/__init__.py +0 -0
  54. bencher/results/holoview_results/distribution_result/box_whisker_result.py +73 -0
  55. bencher/results/holoview_results/distribution_result/distribution_result.py +109 -0
  56. bencher/results/holoview_results/distribution_result/scatter_jitter_result.py +92 -0
  57. bencher/results/holoview_results/distribution_result/violin_result.py +70 -0
  58. bencher/results/holoview_results/heatmap_result.py +319 -0
  59. bencher/results/holoview_results/holoview_result.py +346 -0
  60. bencher/results/holoview_results/line_result.py +240 -0
  61. bencher/results/holoview_results/scatter_result.py +107 -0
  62. bencher/results/holoview_results/surface_result.py +158 -0
  63. bencher/results/holoview_results/table_result.py +14 -0
  64. bencher/results/holoview_results/tabulator_result.py +20 -0
  65. bencher/results/optuna_result.py +30 -115
  66. bencher/results/video_controls.py +38 -0
  67. bencher/results/video_result.py +39 -36
  68. bencher/results/video_summary.py +2 -2
  69. bencher/results/{plotly_result.py → volume_result.py} +29 -8
  70. bencher/utils.py +175 -26
  71. bencher/variables/inputs.py +122 -15
  72. bencher/video_writer.py +2 -1
  73. bencher/worker_job.py +31 -3
  74. {holobench-1.41.0.dist-info → holobench-1.43.0.dist-info}/METADATA +24 -24
  75. holobench-1.43.0.dist-info/RECORD +147 -0
  76. bencher/example/example_levels2.py +0 -37
  77. bencher/example/inputs_1D/example_1_in_1_out.py +0 -62
  78. bencher/example/inputs_1D/example_1_in_2_out.py +0 -63
  79. bencher/example/inputs_1D/example_1_in_2_out_repeats.py +0 -61
  80. bencher/results/holoview_result.py +0 -796
  81. bencher/results/panel_result.py +0 -41
  82. holobench-1.41.0.dist-info/RECORD +0 -114
  83. {holobench-1.41.0.dist-info → holobench-1.43.0.dist-info}/WHEEL +0 -0
  84. {holobench-1.41.0.dist-info → holobench-1.43.0.dist-info}/licenses/LICENSE +0 -0
bencher/__init__.py CHANGED
@@ -43,6 +43,24 @@ from .results.composable_container.composable_container_video import (
43
43
  RenderCfg,
44
44
  )
45
45
 
46
+ from bencher.results.holoview_results.distribution_result.box_whisker_result import BoxWhiskerResult
47
+ from bencher.results.holoview_results.distribution_result.violin_result import ViolinResult
48
+ from bencher.results.holoview_results.scatter_result import ScatterResult
49
+ from bencher.results.holoview_results.distribution_result.scatter_jitter_result import (
50
+ ScatterJitterResult,
51
+ )
52
+ from bencher.results.holoview_results.bar_result import BarResult
53
+ from bencher.results.holoview_results.line_result import LineResult
54
+ from bencher.results.holoview_results.curve_result import CurveResult
55
+ from bencher.results.holoview_results.heatmap_result import HeatmapResult
56
+ from bencher.results.holoview_results.surface_result import SurfaceResult
57
+ from bencher.results.holoview_results.tabulator_result import TabulatorResult
58
+ from bencher.results.holoview_results.table_result import TableResult
59
+
60
+ from bencher.results.histogram_result import HistogramResult
61
+ from bencher.results.explorer_result import ExplorerResult
62
+ from bencher.results.dataset_result import DataSetResult
63
+
46
64
  from .utils import (
47
65
  hmap_canonical_input,
48
66
  get_nearest_coords,
@@ -68,8 +86,8 @@ from .plotting.plot_filter import VarRange, PlotFilter
68
86
  from .variables.parametrised_sweep import ParametrizedSweep
69
87
  from .caching import CachedParams
70
88
  from .results.bench_result import BenchResult
71
- from .results.panel_result import PanelResult
72
- from .results.holoview_result import ReduceType, HoloviewResult
89
+ from .results.video_result import VideoResult
90
+ from .results.holoview_results.holoview_result import ReduceType, HoloviewResult
73
91
  from .bench_report import BenchReport, GithubPagesCfg
74
92
  from .job import Executors
75
93
  from .video_writer import VideoWriter, add_image
bencher/bench_cfg.py CHANGED
@@ -3,11 +3,12 @@ from __future__ import annotations
3
3
  import argparse
4
4
  import logging
5
5
 
6
- from typing import List
6
+ from typing import List, Optional, Dict, Any, Union, TypeVar
7
7
 
8
8
  import param
9
9
  import panel as pn
10
10
  from datetime import datetime
11
+ from copy import deepcopy
11
12
 
12
13
  from bencher.variables.sweep_base import hash_sha1, describe_variable
13
14
  from bencher.variables.time import TimeSnapshot, TimeEvent
@@ -15,20 +16,79 @@ from bencher.variables.results import OptDir
15
16
  from bencher.job import Executors
16
17
  from bencher.results.laxtex_result import to_latex
17
18
 
19
+ T = TypeVar("T") # Generic type variable
20
+
18
21
 
19
22
  class BenchPlotSrvCfg(param.Parameterized):
20
- port: int = param.Integer(None, doc="The port to launch panel with")
21
- allow_ws_origin = param.Boolean(
23
+ """Configuration for the benchmarking plot server.
24
+
25
+ This class defines parameters for controlling how the benchmark visualization
26
+ server operates, including network configuration.
27
+
28
+ Attributes:
29
+ port (int): The port to launch panel with
30
+ allow_ws_origin (bool): Add the port to the whitelist (warning will disable remote
31
+ access if set to true)
32
+ show (bool): Open the served page in a web browser
33
+ """
34
+
35
+ port: Optional[int] = param.Integer(None, doc="The port to launch panel with")
36
+ allow_ws_origin: bool = param.Boolean(
22
37
  False,
23
- doc="Add the port to the whilelist, (warning will disable remote access if set to true)",
38
+ doc="Add the port to the whitelist, (warning will disable remote access if set to true)",
24
39
  )
25
40
  show: bool = param.Boolean(True, doc="Open the served page in a web browser")
26
41
 
27
42
 
28
43
  class BenchRunCfg(BenchPlotSrvCfg):
29
- """A Class to store options for how to run a benchmark parameter sweep"""
30
-
31
- repeats: bool = param.Integer(1, doc="The number of times to sample the inputs")
44
+ """Configuration class for benchmark execution parameters.
45
+
46
+ This class extends BenchPlotSrvCfg to provide comprehensive control over benchmark execution,
47
+ including caching behavior, reporting options, visualization settings, and execution strategy.
48
+ It defines numerous parameters that control how benchmark runs are performed, cached,
49
+ and displayed to the user.
50
+
51
+ Attributes:
52
+ repeats (int): The number of times to sample the inputs
53
+ over_time (bool): If true each time the function is called it will plot a
54
+ timeseries of historical and the latest result
55
+ use_optuna (bool): Show optuna plots
56
+ summarise_constant_inputs (bool): Print the inputs that are kept constant
57
+ when describing the sweep parameters
58
+ print_bench_inputs (bool): Print the inputs to the benchmark function
59
+ every time it is called
60
+ print_bench_results (bool): Print the results of the benchmark function
61
+ every time it is called
62
+ clear_history (bool): Clear historical results
63
+ print_pandas (bool): Print a pandas summary of the results to the console
64
+ print_xarray (bool): Print an xarray summary of the results to the console
65
+ serve_pandas (bool): Serve a pandas summary on the results webpage
66
+ serve_pandas_flat (bool): Serve a flattened pandas summary on the results webpage
67
+ serve_xarray (bool): Serve an xarray summary on the results webpage
68
+ auto_plot (bool): Automatically deduce the best type of plot for the results
69
+ raise_duplicate_exception (bool): Used to debug unique plot names
70
+ cache_results (bool): Benchmark level cache for completed benchmark results
71
+ clear_cache (bool): Clear the cache of saved input->output mappings
72
+ cache_samples (bool): Enable per-sample caching
73
+ only_hash_tag (bool): Use only the tag hash for cache identification
74
+ clear_sample_cache (bool): Clear the per-sample cache
75
+ overwrite_sample_cache (bool): Recalculate and overwrite cached sample values
76
+ only_plot (bool): Do not calculate benchmarks if no results are found in cache
77
+ use_holoview (bool): Use holoview for plotting
78
+ nightly (bool): Run a more extensive set of tests for a nightly benchmark
79
+ time_event (str): String representation of a sequence over time
80
+ headless (bool): Run the benchmarks headlessly
81
+ render_plotly (bool): Controls plotly rendering behavior with bokeh
82
+ level (int): Method of defining the number of samples to sweep over
83
+ run_tag (str): Tag for isolating cached results
84
+ run_date (datetime): Date the benchmark run was performed
85
+ executor (Executors): Executor for running the benchmark
86
+ plot_size (int): Sets both width and height of the plot
87
+ plot_width (int): Sets width of the plots
88
+ plot_height (int): Sets height of the plot
89
+ """
90
+
91
+ repeats: int = param.Integer(1, doc="The number of times to sample the inputs")
32
92
 
33
93
  over_time: bool = param.Boolean(
34
94
  False,
@@ -37,7 +97,7 @@ class BenchRunCfg(BenchPlotSrvCfg):
37
97
 
38
98
  use_optuna: bool = param.Boolean(False, doc="show optuna plots")
39
99
 
40
- summarise_constant_inputs = param.Boolean(
100
+ summarise_constant_inputs: bool = param.Boolean(
41
101
  True, doc="Print the inputs that are kept constant when describing the sweep parameters"
42
102
  )
43
103
 
@@ -119,30 +179,30 @@ class BenchRunCfg(BenchPlotSrvCfg):
119
179
  False, doc="Run a more extensive set of tests for a nightly benchmark"
120
180
  )
121
181
 
122
- time_event: str = param.String(
182
+ time_event: Optional[str] = param.String(
123
183
  None,
124
184
  doc="A string representation of a sequence over time, i.e. datetime, pull request number, or run number",
125
185
  )
126
186
 
127
187
  headless: bool = param.Boolean(False, doc="Run the benchmarks headlessly")
128
188
 
129
- render_plotly = param.Boolean(
189
+ render_plotly: bool = param.Boolean(
130
190
  True,
131
191
  doc="Plotly and Bokeh don't play nicely together, so by default pre-render plotly figures to a non dynamic version so that bokeh plots correctly. If you want interactive 3D graphs, set this to true but be aware that your 2D interactive graphs will probably stop working.",
132
192
  )
133
193
 
134
- level = param.Integer(
194
+ level: int = param.Integer(
135
195
  default=0,
136
196
  bounds=[0, 12],
137
197
  doc="The level parameter is a method of defining the number samples to sweep over in a variable agnostic way, i.e you don't need to specify the number of samples for each variable as they are calculated dynamically from the sampling level. See example_level.py for more information.",
138
198
  )
139
199
 
140
- run_tag = param.String(
200
+ run_tag: str = param.String(
141
201
  default="",
142
202
  doc="Define a tag for a run to isolate the results stored in the cache from other runs",
143
203
  )
144
204
 
145
- run_date = param.Date(
205
+ run_date: datetime = param.Date(
146
206
  default=datetime.now(),
147
207
  doc="The date the bench run was performed",
148
208
  )
@@ -157,21 +217,25 @@ class BenchRunCfg(BenchPlotSrvCfg):
157
217
  doc="The function can be run serially or in parallel with different futures executors",
158
218
  )
159
219
 
160
- plot_size = param.Integer(default=None, doc="Sets the width and height of the plot")
161
- plot_width = param.Integer(
220
+ plot_size: Optional[int] = param.Integer(
221
+ default=None, doc="Sets the width and height of the plot"
222
+ )
223
+ plot_width: Optional[int] = param.Integer(
162
224
  default=None,
163
225
  doc="Sets with width of the plots, this will override the plot_size parameter",
164
226
  )
165
- plot_height = param.Integer(
227
+ plot_height: Optional[int] = param.Integer(
166
228
  default=None, doc="Sets the height of the plot, this will override the plot_size parameter"
167
229
  )
168
230
 
169
231
  @staticmethod
170
232
  def from_cmd_line() -> BenchRunCfg: # pragma: no cover
171
- """create a BenchRunCfg by parsing command line arguments
233
+ """Create a BenchRunCfg by parsing command line arguments.
234
+
235
+ Parses command line arguments to create a configuration for benchmark runs.
172
236
 
173
237
  Returns:
174
- parsed args: parsed args
238
+ BenchRunCfg: Configuration object with settings from command line arguments
175
239
  """
176
240
 
177
241
  parser = argparse.ArgumentParser(description="benchmark")
@@ -216,9 +280,44 @@ class BenchRunCfg(BenchPlotSrvCfg):
216
280
 
217
281
  return BenchRunCfg(**vars(parser.parse_args()))
218
282
 
283
+ def deep(self):
284
+ return deepcopy(self)
285
+
219
286
 
220
287
  class BenchCfg(BenchRunCfg):
221
- """A class for storing the arguments to configure a benchmark protocol If the inputs variables are the same the class should return the same hash and same filename. This is so that historical data can be referenced and ensures that the generated plots are unique per benchmark"""
288
+ """Complete configuration for a benchmark protocol.
289
+
290
+ This class extends BenchRunCfg and provides a comprehensive set of parameters
291
+ for configuring benchmark runs. It maintains a unique hash value based on its
292
+ configuration to ensure that benchmark results can be consistently referenced
293
+ and that plots are uniquely identified across runs.
294
+
295
+ The class handles input variables, result variables, constant values, meta variables,
296
+ and various presentation options. It also provides methods for generating
297
+ descriptive summaries and visualizations of the benchmark configuration.
298
+
299
+ Attributes:
300
+ input_vars (List): A list of ParameterizedSweep variables to perform a parameter sweep over
301
+ result_vars (List): A list of ParameterizedSweep results to collect and plot
302
+ const_vars (List): Variables to keep constant but are different from the default value
303
+ result_hmaps (List): A list of holomap results
304
+ meta_vars (List): Meta variables such as recording time and repeat id
305
+ all_vars (List): Stores a list of both the input_vars and meta_vars
306
+ iv_time (List[TimeSnapshot | TimeEvent]): Parameter for sampling the same inputs over time
307
+ iv_time_event (List[TimeEvent]): Parameter for sampling inputs over time as a discrete type
308
+ over_time (bool): Controls whether the function is sampled over time
309
+ name (str): The name of the benchmarkCfg
310
+ title (str): The title of the benchmark
311
+ raise_duplicate_exception (bool): Used for debugging filename generation uniqueness
312
+ bench_name (str): The name of the benchmark and save folder
313
+ description (str): A longer description of the benchmark function
314
+ post_description (str): Comments on the output of the graphs
315
+ has_results (bool): Whether this config has results
316
+ pass_repeat (bool): Whether to pass the 'repeat' kwarg to the benchmark function
317
+ tag (str): Tags for grouping different benchmarks
318
+ hash_value (str): Stored hash value of the config
319
+ plot_callbacks (List): Callables that take a BenchResult and return panel representation
320
+ """
222
321
 
223
322
  input_vars = param.List(
224
323
  default=None,
@@ -246,7 +345,7 @@ class BenchCfg(BenchRunCfg):
246
345
  )
247
346
  iv_time = param.List(
248
347
  default=[],
249
- item_type=TimeSnapshot | TimeEvent,
348
+ item_type=Union[TimeSnapshot, TimeEvent],
250
349
  doc="A parameter to represent the sampling the same inputs over time as a scalar type",
251
350
  )
252
351
 
@@ -256,22 +355,24 @@ class BenchCfg(BenchRunCfg):
256
355
  doc="A parameter to represent the sampling the same inputs over time as a discrete type",
257
356
  )
258
357
 
259
- over_time: param.Boolean(
358
+ over_time: bool = param.Boolean(
260
359
  False, doc="A parameter to control whether the function is sampled over time"
261
360
  )
262
- name: str = param.String(None, doc="The name of the benchmarkCfg")
263
- title: str = param.String(None, doc="The title of the benchmark")
264
- raise_duplicate_exception: str = param.Boolean(
361
+ name: Optional[str] = param.String(None, doc="The name of the benchmarkCfg")
362
+ title: Optional[str] = param.String(None, doc="The title of the benchmark")
363
+ raise_duplicate_exception: bool = param.Boolean(
265
364
  False, doc="Use this while debugging if filename generation is unique"
266
365
  )
267
- bench_name: str = param.String(
366
+ bench_name: Optional[str] = param.String(
268
367
  None, doc="The name of the benchmark and the name of the save folder"
269
368
  )
270
- description: str = param.String(
369
+ description: Optional[str] = param.String(
271
370
  None,
272
371
  doc="A place to store a longer description of the function of the benchmark",
273
372
  )
274
- post_description: str = param.String(None, doc="A place to comment on the output of the graphs")
373
+ post_description: Optional[str] = param.String(
374
+ None, doc="A place to comment on the output of the graphs"
375
+ )
275
376
 
276
377
  has_results: bool = param.Boolean(
277
378
  False,
@@ -298,17 +399,31 @@ class BenchCfg(BenchRunCfg):
298
399
  doc="A callable that takes a BenchResult and returns panel representation of the results",
299
400
  )
300
401
 
301
- def __init__(self, **params):
402
+ def __init__(self, **params: Any) -> None:
403
+ """Initialize a BenchCfg with the given parameters.
404
+
405
+ Args:
406
+ **params (Any): Parameters to set on the BenchCfg
407
+ """
302
408
  super().__init__(**params)
303
409
  self.plot_lib = None
304
410
  self.hmap_kdims = None
305
411
  self.iv_repeat = None
306
412
 
307
- def hash_persistent(self, include_repeats) -> str:
308
- """override the default hash function because the default hash function does not return the same value for the same inputs. It references internal variables that are unique per instance of BenchCfg
413
+ def hash_persistent(self, include_repeats: bool) -> str:
414
+ """Generate a persistent hash for the benchmark configuration.
415
+
416
+ Overrides the default hash function because the default hash function does not
417
+ return the same value for the same inputs. This method references only stable
418
+ variables that are consistent across instances of BenchCfg with the same
419
+ configuration.
309
420
 
310
421
  Args:
311
- include_repeats (bool) : by default include repeats as part of the hash except with using the sample cache
422
+ include_repeats (bool): Whether to include repeats as part of the hash
423
+ (True by default except when using the sample cache)
424
+
425
+ Returns:
426
+ str: A persistent hash value for the benchmark configuration
312
427
  """
313
428
 
314
429
  if include_repeats:
@@ -336,13 +451,33 @@ class BenchCfg(BenchRunCfg):
336
451
  return hash_val
337
452
 
338
453
  def inputs_as_str(self) -> List[str]:
454
+ """Get a list of input variable names.
455
+
456
+ Returns:
457
+ List[str]: List of the names of input variables
458
+ """
339
459
  return [i.name for i in self.input_vars]
340
460
 
341
- def to_latex(self):
461
+ def to_latex(self) -> Optional[pn.pane.LaTeX]:
462
+ """Convert benchmark configuration to LaTeX representation.
463
+
464
+ Returns:
465
+ Optional[pn.pane.LaTeX]: LaTeX representation of the benchmark configuration
466
+ """
342
467
  return to_latex(self)
343
468
 
344
- def describe_sweep(self, width: int = 800, accordion=True) -> pn.pane.Markdown | pn.Column:
345
- """Produce a markdown summary of the sweep settings"""
469
+ def describe_sweep(
470
+ self, width: int = 800, accordion: bool = True
471
+ ) -> Union[pn.pane.Markdown, pn.Column]:
472
+ """Produce a markdown summary of the sweep settings.
473
+
474
+ Args:
475
+ width (int): Width of the markdown panel in pixels. Defaults to 800.
476
+ accordion (bool): Whether to wrap the description in an accordion. Defaults to True.
477
+
478
+ Returns:
479
+ Union[pn.pane.Markdown, pn.Column]: Panel containing the sweep description
480
+ """
346
481
 
347
482
  latex = self.to_latex()
348
483
  desc = pn.pane.Markdown(self.describe_benchmark(), width=width)
@@ -352,9 +487,14 @@ class BenchCfg(BenchRunCfg):
352
487
  sentence = self.sweep_sentence()
353
488
  if latex is not None:
354
489
  return pn.Column(sentence, latex, desc)
355
- return pn.Column(sentence, latex, desc)
490
+ return pn.Column(sentence, desc)
491
+
492
+ def sweep_sentence(self) -> pn.pane.Markdown:
493
+ """Generate a concise summary sentence of the sweep configuration.
356
494
 
357
- def sweep_sentence(self):
495
+ Returns:
496
+ pn.pane.Markdown: A panel containing a markdown summary sentence
497
+ """
358
498
  inputs = " by ".join([iv.name for iv in self.all_vars])
359
499
 
360
500
  all_vars_lens = [len(iv.values()) for iv in reversed(self.all_vars)]
@@ -363,13 +503,15 @@ class BenchCfg(BenchRunCfg):
363
503
  result_sizes = "x".join([str(iv) for iv in all_vars_lens])
364
504
  results = ", ".join([rv.name for rv in self.result_vars])
365
505
 
366
- return f"Sweeping {inputs} to generate a {result_sizes} result dataframe containing {results}. "
506
+ return pn.pane.Markdown(
507
+ f"Sweeping {inputs} to generate a {result_sizes} result dataframe containing {results}. "
508
+ )
367
509
 
368
510
  def describe_benchmark(self) -> str:
369
- """Generate a string summary of the inputs and results from a BenchCfg
511
+ """Generate a detailed string summary of the inputs and results from a BenchCfg.
370
512
 
371
513
  Returns:
372
- str: summary of BenchCfg
514
+ str: Comprehensive summary of BenchCfg
373
515
  """
374
516
  benchmark_sampling_str = ["```text"]
375
517
  benchmark_sampling_str.append("")
@@ -406,26 +548,62 @@ class BenchCfg(BenchRunCfg):
406
548
  benchmark_sampling_str = "\n".join(benchmark_sampling_str)
407
549
  return benchmark_sampling_str
408
550
 
409
- def to_title(self, panel_name: str = None) -> pn.pane.Markdown:
551
+ def to_title(self, panel_name: Optional[str] = None) -> pn.pane.Markdown:
552
+ """Create a markdown panel with the benchmark title.
553
+
554
+ Args:
555
+ panel_name (Optional[str]): The name for the panel. Defaults to the benchmark title.
556
+
557
+ Returns:
558
+ pn.pane.Markdown: A panel with the benchmark title as a heading
559
+ """
410
560
  if panel_name is None:
411
561
  panel_name = self.title
412
562
  return pn.pane.Markdown(f"# {self.title}", name=panel_name)
413
563
 
414
564
  def to_description(self, width: int = 800) -> pn.pane.Markdown:
565
+ """Create a markdown panel with the benchmark description.
566
+
567
+ Args:
568
+ width (int): Width of the markdown panel in pixels. Defaults to 800.
569
+
570
+ Returns:
571
+ pn.pane.Markdown: A panel with the benchmark description
572
+ """
415
573
  return pn.pane.Markdown(f"{self.description}", width=width)
416
574
 
417
575
  def to_post_description(self, width: int = 800) -> pn.pane.Markdown:
576
+ """Create a markdown panel with the benchmark post-description.
577
+
578
+ Args:
579
+ width (int): Width of the markdown panel in pixels. Defaults to 800.
580
+
581
+ Returns:
582
+ pn.pane.Markdown: A panel with the benchmark post-description
583
+ """
418
584
  return pn.pane.Markdown(f"{self.post_description}", width=width)
419
585
 
420
586
  def to_sweep_summary(
421
587
  self,
422
- name=None,
423
- description=True,
424
- describe_sweep=True,
425
- results_suffix=True,
588
+ name: Optional[str] = None,
589
+ description: bool = True,
590
+ describe_sweep: bool = True,
591
+ results_suffix: bool = True,
426
592
  title: bool = True,
427
- ) -> pn.pane.Markdown:
428
- """Produce panel output summarising the title, description and sweep setting"""
593
+ ) -> pn.Column:
594
+ """Produce panel output summarising the title, description and sweep setting.
595
+
596
+ Args:
597
+ name (Optional[str]): Name for the panel. Defaults to benchmark title or
598
+ "Data Collection Parameters" if title is False.
599
+ description (bool): Whether to include the benchmark description. Defaults to True.
600
+ describe_sweep (bool): Whether to include the sweep description. Defaults to True.
601
+ results_suffix (bool): Whether to add a "Results:" heading. Defaults to True.
602
+ title (bool): Whether to include the benchmark title. Defaults to True.
603
+
604
+ Returns:
605
+ pn.Column: A panel with the benchmark summary
606
+ """
429
607
  if name is None:
430
608
  if title:
431
609
  name = self.title
@@ -442,7 +620,16 @@ class BenchCfg(BenchRunCfg):
442
620
  col.append(pn.pane.Markdown("## Results:"))
443
621
  return col
444
622
 
445
- def optuna_targets(self, as_var=False) -> List[str]:
623
+ def optuna_targets(self, as_var: bool = False) -> List[Any]:
624
+ """Get the list of result variables that are optimization targets.
625
+
626
+ Args:
627
+ as_var (bool): If True, return the variable objects rather than their names.
628
+ Defaults to False.
629
+
630
+ Returns:
631
+ List[Any]: List of result variable names or objects that are optimization targets
632
+ """
446
633
  targets = []
447
634
  for rv in self.result_vars:
448
635
  if hasattr(rv, "direction") and rv.direction != OptDir.none:
@@ -454,17 +641,38 @@ class BenchCfg(BenchRunCfg):
454
641
 
455
642
 
456
643
  class DimsCfg:
457
- """A class to store data about the sampling and result dimensions"""
644
+ """A class to store data about the sampling and result dimensions.
645
+
646
+ This class processes a BenchCfg object to extract and organize information about
647
+ the dimensions of the benchmark, including names, ranges, sizes, and coordinates.
648
+ It is used to set up the structure for analyzing and visualizing benchmark results.
649
+
650
+ Attributes:
651
+ dims_name (List[str]): Names of the benchmark dimensions
652
+ dim_ranges (List[List[Any]]): Values for each dimension
653
+ dims_size (List[int]): Size (number of values) for each dimension
654
+ dim_ranges_index (List[List[int]]): Indices for each dimension value
655
+ dim_ranges_str (List[str]): String representation of dimension ranges
656
+ coords (Dict[str, List[Any]]): Mapping of dimension names to their values
657
+ """
458
658
 
459
659
  def __init__(self, bench_cfg: BenchCfg) -> None:
460
- self.dims_name = [i.name for i in bench_cfg.all_vars]
660
+ """Initialize the DimsCfg with dimension information from a benchmark configuration.
661
+
662
+ Extracts dimension names, ranges, sizes, and coordinates from the provided benchmark
663
+ configuration for use in organizing and analyzing benchmark results.
664
+
665
+ Args:
666
+ bench_cfg (BenchCfg): The benchmark configuration containing dimension information
667
+ """
668
+ self.dims_name: List[str] = [i.name for i in bench_cfg.all_vars]
461
669
 
462
- self.dim_ranges = []
670
+ self.dim_ranges: List[List[Any]] = []
463
671
  self.dim_ranges = [i.values() for i in bench_cfg.all_vars]
464
- self.dims_size = [len(p) for p in self.dim_ranges]
465
- self.dim_ranges_index = [list(range(i)) for i in self.dims_size]
466
- self.dim_ranges_str = [f"{s}\n" for s in self.dim_ranges]
467
- self.coords = dict(zip(self.dims_name, self.dim_ranges))
672
+ self.dims_size: List[int] = [len(p) for p in self.dim_ranges]
673
+ self.dim_ranges_index: List[List[int]] = [list(range(i)) for i in self.dims_size]
674
+ self.dim_ranges_str: List[str] = [f"{s}\n" for s in self.dim_ranges]
675
+ self.coords: Dict[str, List[Any]] = dict(zip(self.dims_name, self.dim_ranges))
468
676
 
469
677
  logging.debug(f"dims_name: {self.dims_name}")
470
678
  logging.debug(f"dim_ranges {self.dim_ranges_str}")
bencher/bench_report.py CHANGED
@@ -162,8 +162,8 @@ class BenchReport(BenchPlotServer):
162
162
 
163
163
  def publish_args(branch_name) -> Tuple[str, str]:
164
164
  return (
165
- "https://github.com/dyson-ai/bencher.git",
166
- f"https://github.com/dyson-ai/bencher/blob/{branch_name}")
165
+ "https://github.com/blooop/bencher.git",
166
+ f"https://github.com/blooop/bencher/blob/{branch_name}")
167
167
 
168
168
 
169
169
  Args: