Skip to content

Commit 0535bf4

Browse files
author
OutlyingWest
committed
display_graph_for_last moved to extension
1 parent 6c9f759 commit 0535bf4

2 files changed

Lines changed: 20 additions & 19 deletions

File tree

src/jumper/kernel.py

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -953,26 +953,8 @@ async def do_execute(
953953
self.get_perfdata_index(-1, metrics[1:]), nmetrics)
954954
return self.standard_reply()
955955
"""
956-
if code.startswith("%%display_graph_for_last"):
957-
if not len(kernel_context.perfdata_handler.get_perfdata_history()):
958-
self.cell_output("No performance data available.")
959-
time_indices = kernel_context.perfdata_handler.get_time_indices()[-1]
960-
if time_indices:
961-
sub_idxs = [x[0] for x in time_indices[0]]
962-
self.cell_output(
963-
f"Cell seemed to be tracked in multi cell"
964-
" mode. Got performance data for the"
965-
f" following sub cells: {sub_idxs}"
966-
)
967-
perfvis.draw_performance_graph(
968-
self.nodelist,
969-
kernel_context.perfdata_handler.get_perfdata_history()[-1],
970-
kernel_context.gpu_avail,
971-
time_indices,
972-
)
973-
return self.standard_reply()
974956

975-
elif code.startswith("%%display_code_for_index"):
957+
if code.startswith("%%display_code_for_index"):
976958
if len(code.split(" ")) == 1:
977959
self.cell_output(
978960
"No index specified. Use: %%display_code_for_index index",

src/magic_extension/magic.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,25 @@ def display_graph_for_index(self, line):
8282
time_indices,
8383
)
8484

85+
@line_magic
86+
def display_graph_for_last(self, line):
87+
if not len(kernel_context.perfdata_handler.get_perfdata_history()):
88+
self.cell_output("No performance data available.")
89+
time_indices = kernel_context.perfdata_handler.get_time_indices()[-1]
90+
if time_indices:
91+
sub_idxs = [x[0] for x in time_indices[0]]
92+
self.cell_output(
93+
f"Cell seemed to be tracked in multi cell"
94+
" mode. Got performance data for the"
95+
f" following sub cells: {sub_idxs}"
96+
)
97+
perfvis.draw_performance_graph(
98+
self.nodelist,
99+
kernel_context.perfdata_handler.get_perfdata_history()[-1],
100+
kernel_context.gpu_avail,
101+
time_indices,
102+
)
103+
85104

86105
@cell_magic
87106
def set_perfmonitor(self, line, code):

0 commit comments

Comments
 (0)