Skip to content

Commit 0015410

Browse files
basnijholtjbweston
authored andcommitted
color the overhead between red and green (#252)
color the overhead between red and green
1 parent bbec975 commit 0015410

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

adaptive/notebook_integration.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,10 +250,14 @@ def _info_html(runner):
250250
"finished": "green",
251251
}[status]
252252

253+
overhead = runner.overhead()
254+
red_level = max(0, min(int(255 * overhead / 100), 255))
255+
overhead_color = "#{:02x}{:02x}{:02x}".format(red_level, 255 - red_level, 0)
256+
253257
info = [
254258
("status", f'<font color="{color}">{status}</font>'),
255259
("elapsed time", datetime.timedelta(seconds=runner.elapsed_time())),
256-
("overhead", f"{runner.overhead():.2f}%"),
260+
("overhead", f'<font color="{overhead_color}">{overhead:.2f}%</font>'),
257261
]
258262

259263
with suppress(Exception):

0 commit comments

Comments
 (0)