Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions verticapy/performance/vertica/qprof.py
Original file line number Diff line number Diff line change
Expand Up @@ -1883,6 +1883,7 @@ def _set_request_qd(self):
self.start_timestamp = []
self.end_timestamp = []
self.query_successes = []
self.queue_times = []
# Extracting transaction_ids and statement_ids from the list of tuples
transaction_ids = [t[0] for t in self.transactions]
statement_ids = [t[1] for t in self.transactions]
Expand All @@ -1906,7 +1907,8 @@ def _set_request_qd(self):
query_duration_us,
q2.start_time,
q2.end_time,
q2.success
q2.success,
ROUND(EXTRACT(EPOCH FROM (q3.acquisition_timestamp - q3.queue_entry_timestamp)), 3) AS queue_time_sec
FROM
v_internal.dc_requests_issued AS q0
FULL JOIN
Expand All @@ -1915,10 +1917,13 @@ def _set_request_qd(self):
FULL JOIN
v_monitor.query_consumption AS q2
USING (transaction_id, statement_id)
LEFT JOIN
v_monitor.resource_acquisitions AS q3
USING (transaction_id, statement_id)
WHERE
{transaction_id_condition}
AND {statement_id_condition};
"""
"""
query = self._replace_schema_in_query(query)
res = _executeSQL(
query,
Expand All @@ -1934,6 +1939,7 @@ def _set_request_qd(self):
"query_start_timestamp": row[5],
"query_end_timestamp": row[6],
"query_success": row[7],
"queue_time_sec": row[8],
}
for tr_id, st_id in self.transactions:
if (tr_id, st_id) not in transactions_dict:
Expand All @@ -1950,9 +1956,11 @@ def _set_request_qd(self):
self.start_timestamp += [info["query_start_timestamp"]]
self.end_timestamp += [info["query_end_timestamp"]]
self.query_successes += [info["query_success"]]
self.queue_times += [info["queue_time_sec"]]
self.request = self.requests[self.transactions_idx]
self.qduration = self.qdurations[self.transactions_idx]
self.query_success = self.query_successes[self.transactions_idx]
self.queue_time = self.queue_times[self.transactions_idx]

def _get_current_nodes(self):
"""
Expand Down Expand Up @@ -2090,6 +2098,7 @@ def set_position(self, idx: Union[int, tuple]) -> None:
self.request = self.requests[idx]
self.qduration = self.qdurations[idx]
self.query_success = self.query_successes[idx]
self.queue_time = self.queue_times[idx]
try:
self.session_params_non_default_current = (
self.session_params_non_default[idx]
Expand Down
84 changes: 71 additions & 13 deletions verticapy/performance/vertica/qprof_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,42 @@ def __init__(
# Query Inofrmation - Query Text & Time
self._query_display_info = widgets.HTML(
value=f"""
<b>Query Execution Success:</b> {self._success_html if self.query_success else self._failure_html} <br>
<b>Execution Time:</b> {self.get_qduration()} (seconds)<br>
<b>Target Schema:</b> {self.target_schema["v_internal"] if self.target_schema else ''} <br>
<b>Transaction ID:</b> {self.transaction_id} <br>
<b>Statement ID:</b> {self.statement_id} <br>
<b>Key ID:</b> {self.key_id}
"""
<div>
<div style="margin-bottom: 4px;">
<b>Query Execution Success:</b> {self._success_html if self.query_success else self._failure_html}
</div>

<div style="display: table; border-spacing: 0;">
<div style="display: table-row;">
<div style="display: table-cell; "><b>Completion Time:</b></div>
<div style="display: table-cell; text-align: right; width: 70px;">{float(self.get_qduration()):.6f}</div>
<div style="display: table-cell; ">(seconds)</div>
</div>
<div style="display: table-row;">
<div style="display: table-cell; "><b>Queue Time:</b></div>
<div style="display: table-cell; text-align: right; width: 70px;">{float(self.queue_time):.6f}</div>
<div style="display: table-cell; ">(seconds)</div>
</div>
<div style="display: table-row;">
<div style="display: table-cell; "><b>Run Time:</b></div>
<div style="display: table-cell; text-align: right; width: 70px;">{(float(self.get_qduration()) - float(self.queue_time)):.6f}</div>
<div style="display: table-cell; ">(seconds)</div>
</div>
</div>
<div style="margin-top: 4px;">
<div style="display: table-row;">
<div style="display: table-cell; "><b>Transaction ID:</b></div>
<div style="display: table-cell; text-align: left; width: 70px; padding-left: 5px;">{self.transaction_id}</div>
</div>
<div style="display: table-row;">
<div style="display: table-cell; "><b>Statement ID:</b></div>
<div style="display: table-cell; text-align: left; width: 70px; padding-left: 5px;">{self.statement_id}</div>
</div>
<div><b>Target Schema:</b> {self.target_schema["v_internal"] if self.target_schema else ''}</div>
<div><b>Key ID:</b> {self.key_id}</div>
</div>
</div>
"""
)
self._query_display = widgets.VBox(
[
Expand Down Expand Up @@ -752,12 +781,41 @@ def _update_query_display(self):
current_query = self.get_request(print_sql=False, return_html=True)
self._query_display.children[0].value = current_query
self._query_display_info.value = f"""
<b>Query Execution Success:</b> {self._success_html if self.query_success else self._failure_html} <br>
<b>Execution Time:</b> {self.get_qduration()} (seconds)<br>
<b>Target Schema:</b> {self.target_schema["v_internal"] if self.target_schema else ''} <br>
<b>Transaction ID:</b> {self.transaction_id} <br>
<b>Statement ID:</b> {self.statement_id} <br>
<b>Key ID:</b> {self.key_id}
<div>
<div style="margin-bottom: 4px;">
<b>Query Execution Success:</b> {self._success_html if self.query_success else self._failure_html}
</div>

<div style="display: table; border-spacing: 0;">
<div style="display: table-row;">
<div style="display: table-cell; "><b>Completion Time:</b></div>
<div style="display: table-cell; text-align: right; width: 70px;">{float(self.get_qduration()):.6f}</div>
<div style="display: table-cell; ">(seconds)</div>
</div>
<div style="display: table-row;">
<div style="display: table-cell; "><b>Queue Time:</b></div>
<div style="display: table-cell; text-align: right; width: 70px;">{float(self.queue_time):.6f}</div>
<div style="display: table-cell; ">(seconds)</div>
</div>
<div style="display: table-row;">
<div style="display: table-cell; "><b>Run Time:</b></div>
<div style="display: table-cell; text-align: right; width: 70px;">{(float(self.get_qduration()) - float(self.queue_time)):.6f}</div>
<div style="display: table-cell; ">(seconds)</div>
</div>
</div>
<div style="margin-top: 4px;">
<div style="display: table-row;">
<div style="display: table-cell; "><b>Transaction ID:</b></div>
<div style="display: table-cell; text-align: left; width: 70px; padding-left: 5px;">{self.transaction_id}</div>
</div>
<div style="display: table-row;">
<div style="display: table-cell; "><b>Statement ID:</b></div>
<div style="display: table-cell; text-align: left; width: 70px; padding-left: 5px;">{self.statement_id}</div>
</div>
<div><b>Target Schema:</b> {self.target_schema["v_internal"] if self.target_schema else ''}</div>
<div><b>Key ID:</b> {self.key_id}</div>
</div>
</div>
"""

def _update_session_param_display(self):
Expand Down
5 changes: 4 additions & 1 deletion verticapy/tests_new/core/vdataframe/test_agg.py
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,10 @@ def test_vdf(self, titanic_vd, func_name, vpy_func, py_func):
print(
f"Function name: {vpy_func} \nVerticaPy Result: {vpy_res} \nPython Result :{py_res}\n"
)
assert vpy_res == pytest.approx(py_res, abs=1e-3)
if func_name in ["all", "any"]:
assert bool(vpy_res) == bool(py_res)
else:
assert vpy_res == pytest.approx(py_res, abs=1e-3)

@pytest.mark.parametrize(
"func_name",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,7 @@ def test_prc_curve(self, model_class, get_vpy_model, get_py_model):
py_model_obj = get_py_model(model_class)
precision, recall, _ = skl_metrics.precision_recall_curve(
y_true=py_model_obj.y.ravel(),
probas_pred=py_model_obj.pred_prob[:, 1].ravel(),
y_score=py_model_obj.pred_prob[:, 1].ravel(),
)
py_res = skl_metrics.auc(recall, precision)

Expand Down
Loading