holobench 1.22.2__py3-none-any.whl → 1.23.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.
- bencher/__init__.py +9 -0
- bencher/bench_runner.py +1 -1
- bencher/bencher.py +3 -1
- bencher/optuna_conversions.py +3 -2
- bencher/utils.py +15 -2
- bencher/video_writer.py +20 -74
- {holobench-1.22.2.dist-info → holobench-1.23.0.dist-info}/METADATA +7 -5
- holobench-1.23.0.dist-info/RECORD +20 -0
- holobench-1.22.2.dist-info/RECORD +0 -20
- {holobench-1.22.2.data → holobench-1.23.0.data}/data/share/ament_index/resource_index/packages/bencher +0 -0
- {holobench-1.22.2.data → holobench-1.23.0.data}/data/share/bencher/package.xml +0 -0
- {holobench-1.22.2.dist-info → holobench-1.23.0.dist-info}/LICENSE +0 -0
- {holobench-1.22.2.dist-info → holobench-1.23.0.dist-info}/WHEEL +0 -0
- {holobench-1.22.2.dist-info → holobench-1.23.0.dist-info}/top_level.txt +0 -0
bencher/__init__.py
CHANGED
@@ -22,6 +22,15 @@ from .variables.results import (
|
|
22
22
|
curve,
|
23
23
|
)
|
24
24
|
|
25
|
+
from .results.composable_container.composable_container_base import (
|
26
|
+
ComposeType,
|
27
|
+
ComposableContainerBase,
|
28
|
+
)
|
29
|
+
from .results.composable_container.composable_container_video import (
|
30
|
+
ComposableContainerVideo,
|
31
|
+
RenderCfg,
|
32
|
+
)
|
33
|
+
|
25
34
|
from .plotting.plot_filter import VarRange, PlotFilter
|
26
35
|
from .utils import (
|
27
36
|
hmap_canonical_input,
|
bencher/bench_runner.py
CHANGED
@@ -121,7 +121,7 @@ class BenchRunner:
|
|
121
121
|
self.show_publish(report_level, show, publish, save, debug)
|
122
122
|
return self.results
|
123
123
|
|
124
|
-
def show_publish(self, report, show, publish, save, debug):
|
124
|
+
def show_publish(self, report: BenchReport, show: bool, publish: bool, save: bool, debug: bool):
|
125
125
|
if save:
|
126
126
|
report.save_index()
|
127
127
|
if publish and self.publisher is not None:
|
bencher/bencher.py
CHANGED
@@ -220,9 +220,11 @@ class Bench(BenchPlotServer):
|
|
220
220
|
relationship_cb=None,
|
221
221
|
plot_callbacks: List | bool = None,
|
222
222
|
) -> List[BenchResult]:
|
223
|
-
results = []
|
224
223
|
if relationship_cb is None:
|
225
224
|
relationship_cb = combinations
|
225
|
+
if input_vars is None:
|
226
|
+
input_vars = self.worker_class_instance.get_inputs_only()
|
227
|
+
results = []
|
226
228
|
for it in range(iterations):
|
227
229
|
for input_group in relationship_cb(input_vars, group_size):
|
228
230
|
title_gen = title + "Sweeping " + " vs ".join(params_to_str(input_group))
|
bencher/optuna_conversions.py
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
from typing import List
|
2
|
+
import logging
|
2
3
|
|
3
4
|
import optuna
|
4
5
|
import panel as pn
|
@@ -158,8 +159,8 @@ def summarise_optuna_study(study: optuna.study.Study) -> pn.pane.panel:
|
|
158
159
|
row.append(plot_param_importances(study))
|
159
160
|
try:
|
160
161
|
row.append(plot_pareto_front(study))
|
161
|
-
except Exception:
|
162
|
-
|
162
|
+
except Exception as e: # pylint: disable=broad-except
|
163
|
+
logging.exception(e)
|
163
164
|
|
164
165
|
row.append(
|
165
166
|
pn.pane.Markdown(f"```\nBest value: {study.best_value}\nParams: {study.best_params}```")
|
bencher/utils.py
CHANGED
@@ -8,8 +8,9 @@ from colorsys import hsv_to_rgb
|
|
8
8
|
from pathlib import Path
|
9
9
|
from uuid import uuid4
|
10
10
|
from functools import partial
|
11
|
-
from typing import Callable, Any, List
|
11
|
+
from typing import Callable, Any, List, Tuple
|
12
12
|
import param
|
13
|
+
import numpy as np
|
13
14
|
|
14
15
|
|
15
16
|
def hmap_canonical_input(dic: dict) -> tuple:
|
@@ -98,6 +99,10 @@ def un_camel(camel: str) -> str:
|
|
98
99
|
return capitalise_words(re.sub("([a-z])([A-Z])", r"\g<1> \g<2>", camel.replace("_", " ")))
|
99
100
|
|
100
101
|
|
102
|
+
def mult_tuple(inp: Tuple[float], val: float) -> Tuple[float]:
|
103
|
+
return tuple(np.array(inp) * val)
|
104
|
+
|
105
|
+
|
101
106
|
def tabs_in_markdown(regular_str: str, spaces: int = 2) -> str:
|
102
107
|
"""Given a string with tabs in the form \t convert the to   which is a double space in markdown
|
103
108
|
|
@@ -142,13 +147,21 @@ def color_tuple_to_css(color: tuple[float, float, float]) -> str:
|
|
142
147
|
return f"rgb{(color[0] * 255, color[1] * 255, color[2] * 255)}"
|
143
148
|
|
144
149
|
|
150
|
+
def color_tuple_to_255(color: tuple[float, float, float]) -> tuple[float, float, float]:
|
151
|
+
return (
|
152
|
+
min(int(color[0] * 255), 255),
|
153
|
+
min(int(color[1] * 255), 255),
|
154
|
+
min(int(color[2] * 255), 255),
|
155
|
+
)
|
156
|
+
|
157
|
+
|
145
158
|
def gen_path(filename, folder="generic", suffix=".dat"):
|
146
159
|
path = Path(f"cachedir/{folder}/{filename}/")
|
147
160
|
path.mkdir(parents=True, exist_ok=True)
|
148
161
|
return f"{path.absolute().as_posix()}/{filename}_{uuid4()}{suffix}"
|
149
162
|
|
150
163
|
|
151
|
-
def gen_video_path(video_name: str = "vid", extension: str = ".
|
164
|
+
def gen_video_path(video_name: str = "vid", extension: str = ".mp4") -> str:
|
152
165
|
return gen_path(video_name, "vid", extension)
|
153
166
|
|
154
167
|
|
bencher/video_writer.py
CHANGED
@@ -4,13 +4,6 @@ from pathlib import Path
|
|
4
4
|
from .utils import gen_video_path, gen_image_path
|
5
5
|
|
6
6
|
import moviepy
|
7
|
-
from moviepy.editor import (
|
8
|
-
VideoFileClip,
|
9
|
-
ImageClip,
|
10
|
-
ImageSequenceClip,
|
11
|
-
clips_array,
|
12
|
-
concatenate_videoclips,
|
13
|
-
)
|
14
7
|
from PIL import Image, ImageDraw
|
15
8
|
|
16
9
|
|
@@ -25,97 +18,50 @@ class VideoWriter:
|
|
25
18
|
self.images.append(img)
|
26
19
|
|
27
20
|
def write(self) -> str:
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
21
|
+
if len(self.images) > 0:
|
22
|
+
clip = moviepy.video.io.ImageSequenceClip.ImageSequenceClip(
|
23
|
+
self.images, fps=30, with_mask=False, load_images=True
|
24
|
+
)
|
25
|
+
self.write_video_raw(clip)
|
32
26
|
return self.filename
|
33
27
|
|
34
28
|
@staticmethod
|
35
|
-
def create_label(label, width=None, height=
|
29
|
+
def create_label(label, width=None, height=16, color=(255, 255, 255)):
|
36
30
|
if width is None:
|
37
|
-
width = len(label) *
|
38
|
-
new_img = Image.new("RGB", (width, height),
|
31
|
+
width = len(label) * 10
|
32
|
+
new_img = Image.new("RGB", (width, height), color=color)
|
39
33
|
# ImageDraw.Draw(new_img).text((width/2, 0), label, (0, 0, 0),align="center",achor="ms")
|
40
|
-
ImageDraw.Draw(new_img).text(
|
34
|
+
ImageDraw.Draw(new_img).text(
|
35
|
+
(width / 2.0, 0), label, (0, 0, 0), anchor="mt", font_size=height
|
36
|
+
)
|
41
37
|
|
42
38
|
return new_img
|
43
39
|
|
44
40
|
@staticmethod
|
45
|
-
def label_image(path: Path, label, padding=20) -> Path:
|
41
|
+
def label_image(path: Path, label, padding=20, color=(255, 255, 255)) -> Path:
|
46
42
|
image = Image.open(path)
|
47
|
-
new_img = VideoWriter.create_label(
|
43
|
+
new_img = VideoWriter.create_label(
|
44
|
+
label, image.size[0], image.size[1] + padding, color=color
|
45
|
+
)
|
48
46
|
new_img.paste(image, (0, padding))
|
49
47
|
return new_img
|
50
48
|
|
51
|
-
def append_file(self, filepath, label=None):
|
52
|
-
if label is not None:
|
53
|
-
path = Path(filepath)
|
54
|
-
new_path = path.with_name(path.stem + "_labelled" + path.suffix).as_posix()
|
55
|
-
padding = 20
|
56
|
-
match path.suffix:
|
57
|
-
case ".png" | ".jpg":
|
58
|
-
image = Image.open(filepath)
|
59
|
-
new_img = self.create_label(label, image.size[0], image.size[1] + padding)
|
60
|
-
new_img.paste(image, (0, padding))
|
61
|
-
new_img.save(new_path)
|
62
|
-
self.image_files.append(new_path)
|
63
|
-
case ".webm":
|
64
|
-
import warnings
|
65
|
-
|
66
|
-
video_clip = VideoFileClip(filepath)
|
67
|
-
new_img = self.create_label(label, video_clip.w, padding)
|
68
|
-
|
69
|
-
# Convert PIL image to MoviePy clip
|
70
|
-
label_clip = ImageClip(np.array(new_img), duration=video_clip.duration)
|
71
|
-
|
72
|
-
labeled_video_clip = clips_array([[label_clip], [video_clip]])
|
73
|
-
|
74
|
-
# otherwise ffmpeg complains that the file is not getting read. We don't need the file just the size
|
75
|
-
with warnings.catch_warnings():
|
76
|
-
warnings.simplefilter(action="ignore")
|
77
|
-
labeled_video_clip.write_videofile(new_path, remove_temp=True, logger=None)
|
78
|
-
self.video_files.append(new_path)
|
79
|
-
else:
|
80
|
-
self.image_files.append(filepath)
|
81
|
-
|
82
|
-
def to_images_sequence(self, images, target_duration: float = 10.0, frame_time=None, **kwargs):
|
83
|
-
target_duration = kwargs.pop("target_duration", target_duration)
|
84
|
-
if isinstance(images, list) and len(images) > 0:
|
85
|
-
if frame_time is None:
|
86
|
-
fps = len(images) / target_duration
|
87
|
-
fps = max(fps, 1) # never slower that 1 seconds per frame
|
88
|
-
fps = min(fps, 30)
|
89
|
-
else:
|
90
|
-
fps = 1.0 / frame_time
|
91
|
-
return ImageSequenceClip(images, fps=fps, with_mask=False)
|
92
|
-
return None
|
93
|
-
|
94
|
-
def write_png(self, **kwargs):
|
95
|
-
clip = None
|
96
|
-
if len(self.image_files) > 0:
|
97
|
-
clip = self.to_images_sequence(self.image_files, **kwargs)
|
98
|
-
if len(self.video_files) > 0:
|
99
|
-
clip = concatenate_videoclips([VideoFileClip(f) for f in self.video_files])
|
100
|
-
if clip is not None:
|
101
|
-
clip.write_videofile(self.filename)
|
102
|
-
return self.filename
|
103
|
-
return None
|
104
|
-
|
105
49
|
def write_video_raw(self, video_clip: moviepy.video.VideoClip, fps: int = 30) -> str:
|
106
50
|
video_clip.write_videofile(
|
107
51
|
self.filename,
|
108
|
-
codec="
|
52
|
+
codec="libx264",
|
109
53
|
audio=False,
|
110
54
|
bitrate="0",
|
111
55
|
fps=fps,
|
112
|
-
ffmpeg_params=["-crf", "
|
56
|
+
ffmpeg_params=["-crf", "23"],
|
57
|
+
threads=8,
|
113
58
|
)
|
114
59
|
video_clip.close()
|
115
60
|
return self.filename
|
116
61
|
|
117
62
|
|
118
|
-
def add_image(np_array: np.ndarray, name: str = "img"):
|
63
|
+
def add_image(np_array: np.ndarray, name: str = "img") -> str:
|
64
|
+
"""Creates a file on disk from a numpy array and returns the created image path"""
|
119
65
|
filename = gen_image_path(name)
|
120
66
|
Image.fromarray(np_array).save(filename)
|
121
67
|
return filename
|
@@ -1,8 +1,10 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: holobench
|
3
|
-
Version: 1.
|
3
|
+
Version: 1.23.0
|
4
4
|
Summary: A package for benchmarking the performance of arbitrary functions
|
5
5
|
Author-email: Austin Gregg-Smith <blooop@gmail.com>
|
6
|
+
Maintainer: austin.gregg-smith
|
7
|
+
Maintainer-email: austin.gregg-smith@dyson.com
|
6
8
|
Project-URL: Repository, https://github.com/dyson-ai/bencher
|
7
9
|
Project-URL: Home, https://github.com/dyson-ai/bencher
|
8
10
|
Project-URL: Documentation, https://bencher.readthedocs.io/en/latest/
|
@@ -13,7 +15,7 @@ Requires-Dist: numpy <=1.26.4,>=1.0
|
|
13
15
|
Requires-Dist: param <=2.1.0,>=1.13.0
|
14
16
|
Requires-Dist: hvplot <=0.10.0,>=0.8
|
15
17
|
Requires-Dist: matplotlib <=3.9.0,>=3.6.3
|
16
|
-
Requires-Dist: panel <=1.4.
|
18
|
+
Requires-Dist: panel <=1.4.4,>=1.3.6
|
17
19
|
Requires-Dist: diskcache <=5.6.3,>=5.6
|
18
20
|
Requires-Dist: optuna <=3.6.1,>=3.2
|
19
21
|
Requires-Dist: xarray <=2024.5.0,>=2023.7
|
@@ -30,9 +32,9 @@ Requires-Dist: black <=24.4.2,>=23 ; extra == 'test'
|
|
30
32
|
Requires-Dist: pylint <=3.2.2,>=2.17.7 ; extra == 'test'
|
31
33
|
Requires-Dist: pytest-cov <=5.0.0,>=4.1 ; extra == 'test'
|
32
34
|
Requires-Dist: pytest <=8.2.1,>=7.4 ; extra == 'test'
|
33
|
-
Requires-Dist: hypothesis <=6.
|
34
|
-
Requires-Dist: ruff <=0.4.
|
35
|
-
Requires-Dist: coverage <=7.5.
|
35
|
+
Requires-Dist: hypothesis <=6.103.0,>=6.82 ; extra == 'test'
|
36
|
+
Requires-Dist: ruff <=0.4.7,>=0.3 ; extra == 'test'
|
37
|
+
Requires-Dist: coverage <=7.5.3,>=7.2.7 ; extra == 'test'
|
36
38
|
|
37
39
|
# Bencher
|
38
40
|
|
@@ -0,0 +1,20 @@
|
|
1
|
+
bencher/__init__.py,sha256=XCrJ5Nbw3k1J6j8qVEf6kH5sMmECIXzII-t9SdB8gEI,1558
|
2
|
+
bencher/bench_cfg.py,sha256=8rvJyeQXalZmYF8Lb-NKb9RFJs0w08k9ogcZSR1rhgs,18413
|
3
|
+
bencher/bench_plot_server.py,sha256=D00_SOrHa2IT8zAjwetoNL6tEiHSHvXnbea9iElCLVk,4195
|
4
|
+
bencher/bench_report.py,sha256=jh3T_q9KByZDeMPMf0KNJojZukxRzkfaYGeuWQU8MKM,10528
|
5
|
+
bencher/bench_runner.py,sha256=-SzAKd6QbPJ05KaW3vteFIkE-UtlFS55Ob9QeE5eRXw,6202
|
6
|
+
bencher/bencher.py,sha256=SlSje8ZvWdRnmRs4ZLXGx3bDQRMHkDOgvyBIsLClUTE,33400
|
7
|
+
bencher/caching.py,sha256=AusaNrzGGlj5m6zcwcqnTn55Mam2mQdF--oqelO806M,1627
|
8
|
+
bencher/class_enum.py,sha256=kYHW9qKkKcNdwaXizZL-fTptS_DUEGv4c88yCehk3gc,1492
|
9
|
+
bencher/job.py,sha256=swa0VwrZf41v7qNjreVDIYUU6r_dfuLipPZbg_w5x7c,6089
|
10
|
+
bencher/optuna_conversions.py,sha256=an-LfPsQXyyvhIZnG8Wl1RQVYMvJj7WOi3YNqoUnuxQ,5356
|
11
|
+
bencher/utils.py,sha256=9KAThtIG8jNd0nd4Wft8miNM_yHWmZUkIBfJh19pzgI,6480
|
12
|
+
bencher/video_writer.py,sha256=B-V1tALd3oPDytaAsl8I6qUztDQlFbkp9gSYco-ah44,2175
|
13
|
+
bencher/worker_job.py,sha256=FREi0yWQACFmH86R1j-LH72tALEFkKhLDmmoGQY9Jh4,1571
|
14
|
+
holobench-1.23.0.data/data/share/ament_index/resource_index/packages/bencher,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
15
|
+
holobench-1.23.0.data/data/share/bencher/package.xml,sha256=HxWM9qIEiLbE60tG0aKsS7q3UaSKDyCMD4-1nYw8vOs,1045
|
16
|
+
holobench-1.23.0.dist-info/LICENSE,sha256=dSHXTdRY4Y7qGFMv63UksV700iff7iE-p7GGs6Sbnvo,1065
|
17
|
+
holobench-1.23.0.dist-info/METADATA,sha256=UrC2MLXikRWBDwgLOqPo0OFgM6079n6ciWTnkktDZX4,5691
|
18
|
+
holobench-1.23.0.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
19
|
+
holobench-1.23.0.dist-info/top_level.txt,sha256=rkP5-F_W08mOD-25ZPkt0HJsHxedb2EiRcRA7IP6Ceg,8
|
20
|
+
holobench-1.23.0.dist-info/RECORD,,
|
@@ -1,20 +0,0 @@
|
|
1
|
-
bencher/__init__.py,sha256=G37hQHeemdNYZUaN5BYds5v8AFLzVM1KIAkpUcrk2To,1321
|
2
|
-
bencher/bench_cfg.py,sha256=8rvJyeQXalZmYF8Lb-NKb9RFJs0w08k9ogcZSR1rhgs,18413
|
3
|
-
bencher/bench_plot_server.py,sha256=D00_SOrHa2IT8zAjwetoNL6tEiHSHvXnbea9iElCLVk,4195
|
4
|
-
bencher/bench_report.py,sha256=jh3T_q9KByZDeMPMf0KNJojZukxRzkfaYGeuWQU8MKM,10528
|
5
|
-
bencher/bench_runner.py,sha256=F4DN1YSFXnUAGO17tJ6DZDyEu7QBgvTyqn8G_iCd36c,6165
|
6
|
-
bencher/bencher.py,sha256=SmdjwFEdjNkPTVeoG6oXLRM8LOobZLVN90LSAsHCS5E,33299
|
7
|
-
bencher/caching.py,sha256=AusaNrzGGlj5m6zcwcqnTn55Mam2mQdF--oqelO806M,1627
|
8
|
-
bencher/class_enum.py,sha256=kYHW9qKkKcNdwaXizZL-fTptS_DUEGv4c88yCehk3gc,1492
|
9
|
-
bencher/job.py,sha256=swa0VwrZf41v7qNjreVDIYUU6r_dfuLipPZbg_w5x7c,6089
|
10
|
-
bencher/optuna_conversions.py,sha256=DAa1DBXJ5EvTGiPyzuDTovQSjKVpMZ2sdwEXThlXJVU,5288
|
11
|
-
bencher/utils.py,sha256=MXoJxtpBOf82-iiZBdWBSz6U0AqoUImQK1rXlmwWzF4,6125
|
12
|
-
bencher/video_writer.py,sha256=v0yXr7PV0rYWTWqVWBZkXFD3N_ExrZHHHkbEXcXK5bc,4512
|
13
|
-
bencher/worker_job.py,sha256=FREi0yWQACFmH86R1j-LH72tALEFkKhLDmmoGQY9Jh4,1571
|
14
|
-
holobench-1.22.2.data/data/share/ament_index/resource_index/packages/bencher,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
15
|
-
holobench-1.22.2.data/data/share/bencher/package.xml,sha256=HxWM9qIEiLbE60tG0aKsS7q3UaSKDyCMD4-1nYw8vOs,1045
|
16
|
-
holobench-1.22.2.dist-info/LICENSE,sha256=dSHXTdRY4Y7qGFMv63UksV700iff7iE-p7GGs6Sbnvo,1065
|
17
|
-
holobench-1.22.2.dist-info/METADATA,sha256=MVUNJCVjAdZG72Is39V08gCnGUgqZl9iSpPonIbdIzk,5613
|
18
|
-
holobench-1.22.2.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
19
|
-
holobench-1.22.2.dist-info/top_level.txt,sha256=rkP5-F_W08mOD-25ZPkt0HJsHxedb2EiRcRA7IP6Ceg,8
|
20
|
-
holobench-1.22.2.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|