Skip to content

Commit

Permalink
[QPROF] Many enhancements (#1287)
Browse files Browse the repository at this point in the history
* [QPROF] Many enhancements

Possibility to filter based on tooltip.
Should close:
 - https://jira.verticacorp.com/jira/browse/VER-97128?filter=-1
 - https://jira.verticacorp.com/jira/browse/VER-97129?filter=-1

* black
  • Loading branch information
oualib authored Sep 26, 2024
1 parent 10d042b commit eb32db6
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 6 deletions.
4 changes: 2 additions & 2 deletions verticapy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@
__url__: str = "https://github.com/vertica/verticapy/"
__license__: str = "Apache License, Version 2.0"
__version__: str = "1.0.5"
__iteration__: int = 2
__iteration__: int = 3
__date__: str = "26092024"
__last_commit__: str = "845f1130772d54ecd184f71f57c92b76ed4b1628"
__last_commit__: str = "8ca3c10cc479cb3da4ff3eb1bbe3a22627f5638a"
__long_version__: str = f"{__version__}-{__iteration__}{__date__}-{__last_commit__}"
__codecov__: float = 0.84

Expand Down
24 changes: 23 additions & 1 deletion verticapy/performance/vertica/qprof.py
Original file line number Diff line number Diff line change
Expand Up @@ -2841,7 +2841,7 @@ def _get_qplan_tr_order(

return res

def _get_metric_val(self):
def _get_metric_val(self) -> tuple:
"""
Helper function to returns the
operator statistics.
Expand Down Expand Up @@ -2904,6 +2904,19 @@ def _get_metric_val(self):
# Returning the metric.
return metric_value_op, metric_value

def _get_all_op(self) -> list[str]:
"""
Returns the input ``transaction``
operators.
"""
all_metrics_op = self._get_metric_val()[0]
all_op = []
for path_id in all_metrics_op:
for op in all_metrics_op[path_id]:
if op not in all_op:
all_op += [op]
return all_op

def _get_vdf_summary(self):
"""
Helper function to returns the
Expand Down Expand Up @@ -3315,6 +3328,15 @@ def get_qplan_tree(
of the corresponding ``path_id``
will be used.
Default: None
- tooltip_filter:
``str`` used to disable some
specific ``path_id``. If the
``path_id`` description does
not include the input information:
A minimalist representation
of the corresponding ``path_id``
will be used.
Default: None
- fontcolor:
Font color.
Default (light-m): #000000 (black)
Expand Down
24 changes: 21 additions & 3 deletions verticapy/performance/vertica/tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,8 @@ def _set_style(self, d: dict) -> None:
d["threshold_metric2"] = None
if "op_filter" not in d:
d["op_filter"] = None
if "tooltip_filter" not in d:
d["tooltip_filter"] = None
if "display_path_transition" not in d:
d["display_path_transition"] = True
if "display_annotations" not in d:
Expand Down Expand Up @@ -1528,6 +1530,7 @@ def _gen_label_table(
colors: list,
operator: Optional[str] = None,
legend_metrics: Optional[list] = None,
tooptip_description: Optional[str] = None,
) -> str:
"""
Generates the Graphviz
Expand All @@ -1537,13 +1540,17 @@ def _gen_label_table(
Parameters
----------
label: int / str
label: int | str
The node label.
colors: list
A ``list`` of one or
two colors.
operator: str, optional
Operator Icon.
legend_metrics: list, optional
Metrics values.
tooptip_description: str, optional
Tooltip Description.
Returns
-------
Expand Down Expand Up @@ -1592,10 +1599,20 @@ def _gen_label_table(
display_path_id = False

# Filter based on the operator.
filter_op = self._is_op_in_path_id(label)
filter_op = not (self._is_op_in_path_id(label))
if filter_op:
display_path_id = False

# Filter based on the tooptip.
tooptip_description = str(tooptip_description).lower().strip()
if not (isinstance(self.style["tooltip_filter"], NoneType)):
tooltip_filter = str(self.style["tooltip_filter"]).lower().strip()
filter_tooltip = tooltip_filter not in tooptip_description
if filter_tooltip:
display_path_id = False

# Special Display.
if not (display_path_id) or not (filter_op):
if not (display_path_id):
return (
'<<TABLE border="1" cellborder="1" cellspacing="0" '
f'cellpadding="0"><TR><TD WIDTH="{width * 2}" '
Expand Down Expand Up @@ -1846,6 +1863,7 @@ def _gen_labels(self) -> str:
colors,
operator=row,
legend_metrics=legend_metrics,
tooptip_description=row,
)

if tree_id in links and display_tr:
Expand Down

0 comments on commit eb32db6

Please sign in to comment.