Skip to content

Commit

Permalink
annotations in console changes and a couple test fixes (forgot to com…
Browse files Browse the repository at this point in the history
…mit test file dir)
  • Loading branch information
dyokelson authored and slabasan committed Oct 4, 2023
1 parent 007d523 commit a7e0eb4
Show file tree
Hide file tree
Showing 4 changed files with 3,843 additions and 8 deletions.
62 changes: 61 additions & 1 deletion hatchet/external/console.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,36 @@ def render_label(index, low, high):
legend += self.colors.right + self.lr_arrows["▶"] + self.colors.end
legend += " Only in right graph\n"

if self.annotation_column is not None:
# temporal pattern legend customization
if "_pattern" in self.annotation_column:
score_ranges = [0.0, 0.2, 0.4, 0.6, 1.0]
legend += "\nTemporal Pattern"
for k in self.temporal_symbols.keys():
if "none" not in k:
legend += " " + self.temporal_symbols[k] + " " + k
legend += "\nTemporal Score "
if self.colormap_annotations:
legend_color_mapping = sorted(score_ranges)
legend_colormap = ColorMaps().get_colors(
self.colormap_annotations, False
)
for i in range(len(score_ranges) - 1):
color = legend_colormap[
legend_color_mapping.index(score_ranges[i + 1])
% len(legend_colormap)
]
legend += "{}".format(color)
legend += " {} - {}".format(
score_ranges[i], score_ranges[i + 1]
)
legend += "{}".format(self.colors_annotations.end)
else: # no color map passed in
for i in range(len(score_ranges) - 1):
legend += " {} - {}".format(
score_ranges[i], score_ranges[i + 1]
)

return legend

def render_frame(self, node, dataframe, indent="", child_indent=""):
Expand Down Expand Up @@ -251,7 +281,37 @@ def render_frame(self, node, dataframe, indent="", child_indent=""):
annotation_content = str(
dataframe.loc[df_index, self.annotation_column]
)
if self.colormap_annotations:

# custom visualization for temporal pattern metrics if it is the annotation column
if "_pattern" in self.annotation_column:
self.temporal_symbols = {
"none": "",
"constant": "\U00002192",
"phased": "\U00002933",
"dynamic": "\U000021DD",
"sporadic": "\U0000219D",
}
pattern_metric = dataframe.loc[df_index, self.annotation_column]
annotation_content = self.temporal_symbols[pattern_metric]
if self.colormap_annotations:
self.colors_annotations_mapping = list(
dataframe[self.annotation_column].apply(str).unique()
)
coloring_content = pattern_metric
if coloring_content != "none":
color_annotation = self.colors_annotations.colormap[
self.colors_annotations_mapping.index(coloring_content)
% len(self.colors_annotations.colormap)
]
metric_str += " {}".format(color_annotation)
metric_str += "{}".format(annotation_content)
metric_str += "{}".format(self.colors_annotations.end)
else:
metric_str += "{}".format(annotation_content)
else: # no colormap passed in
metric_str += " {}".format(annotation_content)
# no pattern column
elif self.colormap_annotations:
if isinstance(self.colormap_annotations, dict):
color_annotation = self.colors_annotations_mapping[
annotation_content
Expand Down
7 changes: 0 additions & 7 deletions hatchet/readers/caliper_native_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,6 @@ def read_metrics(self, ctx="path"):
for record in records:
# if we have a timeseries file we need to split the single cali file into multiple profiles
if self.timeseries_level in record:
# spot_profile = lambda : True if "spot.channel" in self.timeseries_level else False
# check if we've hit the next timestep
# if spot_profile:
# if "spot.channel" in record:# and record["spot.channel"] == "timeseries":
# print(record)
# next_timestep = int(record)
# else:
next_timestep = int(record[self.timeseries_level])
if cur_timestep != next_timestep:
# make a dataframe for the current profile before we continue reading metrics
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
__rec=node,id=21,attr=10,data=1612,parent=3
__rec=node,id=92,attr=8,data=caliper.config,parent=21
__rec=node,id=89,attr=10,data=1612,parent=1
__rec=node,id=90,attr=8,data=iterations,parent=89
__rec=node,id=22,attr=8,data=cali.caliper.version,parent=21
__rec=node,id=23,attr=22,data=2.10.0-dev
__rec=node,id=91,attr=90,data=100,parent=23
__rec=node,id=93,attr=92,data=,parent=91
__rec=node,id=30,attr=10,data=85,parent=5
__rec=node,id=67,attr=8,data=min#time.duration.ns,parent=30
__rec=node,id=68,attr=8,data=max#time.duration.ns,parent=30
__rec=node,id=69,attr=8,data=sum#time.duration.ns,parent=30
__rec=node,id=70,attr=8,data=avg#time.duration.ns,parent=30
__rec=node,id=32,attr=10,data=85,parent=2
__rec=node,id=85,attr=8,data=count,parent=32
__rec=node,id=86,attr=8,data=aggregate.slot,parent=32
__rec=node,id=26,attr=10,data=2133,parent=1
__rec=node,id=27,attr=8,data=loop.iterations,parent=26
__rec=node,id=31,attr=8,data=timeseries.starttime,parent=30
__rec=node,id=33,attr=8,data=timeseries.snapshot,parent=32
__rec=ctx,ref=93,attr=67=68=69=70=85=86=27=31=33,data=448713.000000=448713.000000=448713.000000=448713.000000=1=0=0=1689118709.135139=0
__rec=node,id=18,attr=10,data=276,parent=3
__rec=node,id=20,attr=8,data=region,parent=18
__rec=node,id=94,attr=20,data=main
__rec=ctx,ref=94=93,attr=67=68=69=70=85=86=27=31=33,data=59851.000000=59851.000000=59851.000000=59851.000000=1=1=0=1689118709.135139=0
__rec=node,id=95,attr=20,data=init,parent=94
__rec=node,id=42,attr=8,data=min#region.count,parent=30
__rec=node,id=43,attr=8,data=max#region.count,parent=30
__rec=node,id=44,attr=8,data=sum#region.count,parent=30
__rec=node,id=45,attr=8,data=avg#region.count,parent=30
__rec=ctx,ref=95=93,attr=42=43=44=45=67=68=69=70=85=86=27=31=33,data=1.000000=1.000000=1.000000=1.000000=12219.000000=12219.000000=12219.000000=12219.000000=1=2=0=1689118709.135139=0
__rec=node,id=34,attr=10,data=2133,parent=5
__rec=node,id=35,attr=8,data=timeseries.duration,parent=34
__rec=ctx,ref=94=93,attr=27=31=33=35=31,data=0=1689118709.135139=0=0.001398=1689118709.136537
__rec=node,id=28,attr=10,data=85,parent=1
__rec=node,id=29,attr=8,data=loop.start_iteration,parent=28
__rec=ctx,ref=94=93,attr=67=68=69=70=85=86=27=29=31=33,data=200739.000000=200739.000000=200739.000000=200739.000000=1=0=20=0=1689118709.136537=1
__rec=node,id=19,attr=8,data=loop,parent=18
__rec=node,id=103,attr=19,data=mainloop,parent=94
__rec=ctx,ref=103=93,attr=42=43=44=45=67=68=69=70=85=86=27=29=31=33,data=1.000000=1.000000=19.000000=1.000000=3306.000000=13928.000000=282447.000000=4787.237288=59=1=20=0=1689118709.136537=1
__rec=node,id=104,attr=20,data=foo,parent=103
__rec=ctx,ref=104=93,attr=42=43=44=45=67=68=69=70=85=86=27=29=31=33,data=1.000000=1.000000=20.000000=1.000000=141457.000000=219005.000000=3281358.000000=164067.900000=20=2=20=0=1689118709.136537=1
__rec=node,id=12,attr=10,data=84,parent=6
__rec=node,id=16,attr=8,data=class.iteration,parent=12
__rec=node,id=96,attr=16,data=true,parent=1
__rec=node,id=97,attr=10,data=21,parent=96
__rec=node,id=98,attr=8,data=iteration#mainloop,parent=97
__rec=ctx,ref=103=93,attr=27=29=31=33=35=31=98,data=20=0=1689118709.136537=1=0.003734=1689118709.140271=19
__rec=ctx,ref=103=93,attr=42=43=44=45=67=68=69=70=85=86=27=29=31=33,data=1.000000=1.000000=20.000000=1.000000=3238.000000=83328.000000=357604.000000=5960.066667=60=0=20=20=1689118709.140271=2
__rec=ctx,ref=104=93,attr=42=43=44=45=67=68=69=70=85=86=27=29=31=33,data=1.000000=1.000000=20.000000=1.000000=159474.000000=209917.000000=3364016.000000=168200.800000=20=1=20=20=1689118709.140271=2
__rec=ctx,ref=103=93,attr=27=29=31=33=35=31=98,data=20=20=1689118709.140271=2=0.003722=1689118709.143993=39
__rec=ctx,ref=103=93,attr=42=43=44=45=67=68=69=70=85=86=27=29=31=33,data=1.000000=1.000000=20.000000=1.000000=3213.000000=84229.000000=402162.000000=6702.700000=60=0=20=40=1689118709.143993=3
__rec=ctx,ref=104=93,attr=42=43=44=45=67=68=69=70=85=86=27=29=31=33,data=1.000000=1.000000=20.000000=1.000000=159545.000000=335990.000000=3522373.000000=176118.650000=20=1=20=40=1689118709.143993=3
__rec=ctx,ref=103=93,attr=27=29=31=33=35=31=98,data=20=40=1689118709.143993=3=0.003928=1689118709.147921=59
__rec=ctx,ref=103=93,attr=42=43=44=45=67=68=69=70=85=86=27=29=31=33,data=1.000000=1.000000=20.000000=1.000000=3342.000000=96083.000000=348946.000000=5815.766667=60=0=20=60=1689118709.147921=4
__rec=ctx,ref=104=93,attr=42=43=44=45=67=68=69=70=85=86=27=29=31=33,data=1.000000=1.000000=20.000000=1.000000=136880.000000=173199.000000=3203448.000000=160172.400000=20=1=20=60=1689118709.147921=4
__rec=ctx,ref=103=93,attr=27=29=31=33=35=31=98,data=20=60=1689118709.147921=4=0.003560=1689118709.151481=79
__rec=ctx,ref=103=93,attr=42=43=44=45=67=68=69=70=85=86=27=29=31=33,data=1.000000=1.000000=20.000000=1.000000=3308.000000=112210.000000=407532.000000=6792.200000=60=0=20=80=1689118709.151481=5
__rec=ctx,ref=104=93,attr=42=43=44=45=67=68=69=70=85=86=27=29=31=33,data=1.000000=1.000000=20.000000=1.000000=156252.000000=715191.000000=4120824.000000=206041.200000=20=1=20=80=1689118709.151481=5
__rec=ctx,ref=103=93,attr=27=29=31=33=35=31=98,data=20=80=1689118709.151481=5=0.004522=1689118709.156003=99
__rec=ctx,ref=103=93,attr=42=43=44=45=67=68=69=70=85=86=27=31=33,data=1.000000=1.000000=1.000000=1.000000=114486.000000=114486.000000=114486.000000=114486.000000=1=0=0=1689118709.156003=6
__rec=ctx,ref=103=93,attr=27=31=33=35=31,data=0=1689118709.156003=6=0.000119=1689118709.156122
__rec=node,id=24,attr=8,data=cali.channel,parent=21
__rec=node,id=25,attr=24,data=default
__rec=globals,ref=93=25
Loading

0 comments on commit a7e0eb4

Please sign in to comment.