Skip to content

Commit

Permalink
Added new checkboxes based off the new parameter ``return_useful_cols…
Browse files Browse the repository at this point in the history
…`` in verticapy
  • Loading branch information
mail4umar committed Sep 4, 2024
1 parent fc8692b commit 7ea6ced
Showing 1 changed file with 48 additions and 59 deletions.
107 changes: 48 additions & 59 deletions project/ui/qprof-ui.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -466,66 +466,37 @@
"\n",
"engine_tab_summary_1 = widgets.Output()\n",
"\n",
"# List of checkbox tags\n",
"tags = [\n",
" \"blocks_analyzed_sip\",\n",
" \"clock_time_us\",\n",
" \"container_rows_filtered_sip\",\n",
" \"container_rows_filtered_pred\",\n",
" \"container_rows_pruned_sip\",\n",
" \"container_rows_pruned_pred\",\n",
" \"container_rows_pruned_valindex\",\n",
" \"exec_time_us\",\n",
" \"hash_tables_spilled_sort\",\n",
" \"join_inner_clock_time_us\",\n",
" \"join_inner_exec_time_us\",\n",
" \"join_outer_clock_time_us\",\n",
" \"join_outer_exec_time_us\",\n",
" \"mem_res_b\",\n",
" \"mem_all_b\",\n",
" \"network_wait_us\",\n",
" \"proc_rows\",\n",
" \"producer_stall_us\",\n",
" \"producer_wait_us\",\n",
" \"prod_rows\",\n",
" \"request_wait_us\",\n",
" \"response_wait_us\",\n",
" \"recv_net_time_us\",\n",
" \"recv_wait_us\",\n",
" \"rle_prod_rows\",\n",
" \"rows_filtered_sip\",\n",
" \"rows_pruned_valindex\",\n",
" \"rows_processed_sip\",\n",
" \"total_rows_read_join_sort\",\n",
" \"total_rows_read_sort\"\n",
"]\n",
"tags = sorted(qprof.get_qexecution_report(return_useful_cols=True))\n",
"\n",
"tags=sorted(tags)\n",
"\n",
"selected_checkboxes = [\"exec_time_us\", \"prod_rows\", \"proc_rows\", \"clock_time_us\"]\n",
"# Create checkboxes\n",
"checkboxes = [\n",
" widgets.Checkbox(value=(tag in [\"exec_time_us\", \"prod_rows\", \"proc_rows\", \"clock_time_us\", \"mem_all_b\"]), description=tag) \n",
" widgets.Checkbox(value=(tag in selected_checkboxes), description=tag) \n",
" for tag in tags\n",
"]\n",
"selected_checkboxes = [cb.description for cb in checkboxes if cb.value]\n",
"\n",
"\n",
"# Function to update based on selections\n",
"def on_checkbox_change(change):\n",
" global selected_checkboxes, summary_vdf, summary_vdf_main, granularity_level, granularity_column_list\n",
" selected_checkboxes = [cb.description for cb in checkboxes if cb.value]\n",
" if len(selected_checkboxes) > 6:\n",
" # Deselect the latest selection if limit is exceeded\n",
" change['owner'].value = False\n",
" return\n",
" global selected_checkboxes, summary_vdf, granularity_level\n",
" \n",
" # If the checkbox is being checked\n",
" if change['new']:\n",
" # If we already have 6 checkboxes selected, prevent this one from being checked\n",
" if len(selected_checkboxes) >= 6:\n",
" change['owner'].value = False\n",
" return\n",
" selected_checkboxes.append(change['owner'].description)\n",
" else:\n",
" # If the checkbox is being unchecked, remove it from the list\n",
" selected_checkboxes.remove(change['owner'].description)\n",
"\n",
" # Update the dataframe based on selected checkboxes\n",
" column_list = granularity_column_list.copy()\n",
" column_list.extend(selected_checkboxes.copy())\n",
" summary_vdf = qprof._get_vdf_summary()[granularity_level][column_list]\n",
" summary_vdf_main = summary_vdf\n",
" \n",
" # Update the table display\n",
" display_vdf_across_paths(path_id=summary_path_id_dropdown.value)\n",
" display_vdf_across_nodes(path_id=summary_path_id_dropdown.value, localplan_id=summary_localplan_id_dropdown.value, operator_name=summary_operator_name_dropdown.value)\n",
" detailed_update_table(node_name=summary_node_name_dropdown.value, \n",
" path_id=summary_path_id_dropdown.value, \n",
" localplan_id=summary_localplan_id_dropdown.value, \n",
" operator_name=summary_operator_name_dropdown.value)\n",
"\n",
"# Attach the observer to each checkbox\n",
"for cb in checkboxes:\n",
Expand Down Expand Up @@ -786,7 +757,7 @@
" operator_name=summary_operator_name_dropdown.value\n",
" )\n",
"engine_table_detailed_selection_switch.observe(on_detailed_view_change, names='value')\n",
"engine_table_detailed_widget = widgets.Output()\n",
"engine_table_detailed_widget = widgets.Output(layout=widgets.Layout(width='1400px'))\n",
"try:\n",
" query = (f\"\"\" \n",
" select node_name, path_id, localplan_id, operator_id, operator_name, counter_name, counter_value from v_monitor.execution_engine_profiles\n",
Expand All @@ -796,14 +767,17 @@
" detailed_vdf = vp.vDataFrame(query)\n",
" \n",
" def detailed_update_table(node_name=\"All\", path_id=\"All\", localplan_id=\"All\", operator_name=\"All\"):\n",
" global detailed_vdf, summary_vdf\n",
" global detailed_vdf, summary_vdf_main, selected_checkboxes\n",
" \n",
" with engine_table_detailed_widget:\n",
" engine_table_detailed_widget.clear_output(wait=True)\n",
" if engine_table_detailed_selection_switch.value == \"Raw Table\":\n",
" vdf = detailed_vdf.copy()\n",
" elif engine_table_detailed_selection_switch.value == \"Pivot Table\":\n",
" vdf = summary_vdf.copy()\n",
" vdf = summary_vdf_main.copy()\n",
" cols = [\"node_name\", \"path_id\", \"localplan_id\", \"operator_name\"]\n",
" cols.extend(selected_checkboxes)\n",
" vdf = vdf[cols]\n",
" if path_id != \"All\":\n",
" vdf = vdf[vdf[\"path_id\"] == path_id]\n",
" if node_name != \"All\":\n",
Expand All @@ -820,9 +794,11 @@
" engine_table_detailed_widget = widgets.HTML(f\"<p style='color:red'>The following error occured: </p> <p> {e}</p>\") \n",
"\n",
"engine_table_detailed_top = widgets.HBox([engine_table_summary_controls, engine_table_detailed_selection_title_switch])\n",
"engine_table_detailed = widgets.VBox([\n",
" engine_table_detailed_top,\n",
" engine_table_detailed_widget])\n",
"engine_table_detailed = widgets.VBox([\n",
" engine_table_detailed_top,\n",
" widgets.HBox([engine_table_detailed_widget ,widgets.VBox(checkboxes)]),\n",
" # checkboxes, engine_table_detailed_widget\n",
"])\n",
"\n",
"engine_table_tab = widgets.Tab()\n",
"engine_table_tab.children = [engine_tab_summary_all, engine_table_detailed]\n",
Expand Down Expand Up @@ -860,7 +836,7 @@
"engine_table_button = widgets.Button(description = \"Fetch data\", layout=widgets.Layout(margin='10px 0 10px 0'))\n",
"def on_engine_table_button_click(b):\n",
" engine_table_button.disabled = True\n",
" global summary_vdf, summary_vdf_main, vdf_across_paths, vdf_across_nodes\n",
" global summary_vdf, summary_vdf_main, vdf_across_paths, vdf_across_nodes, checkboxes\n",
" \n",
" try:\n",
" # Adjust the column list based on the current granularity level\n",
Expand All @@ -873,7 +849,8 @@
"\n",
" vdf_across_paths = qprof._get_vdf_summary()[2][\"path_id\", \"thread_count\", \"exec_time_us\", \"prod_rows\", \"proc_rows\", \"clock_time_us\", \"mem_all_b\"]\n",
" vdf_across_nodes = qprof._get_vdf_summary()[1][\"path_id\", \"baseplan_id\", \"operator_name\", \"thread_count\", \"exec_time_us\", \"prod_rows\", \"proc_rows\", \"clock_time_us\", \"mem_all_b\"]\n",
" summary_vdf = qprof._get_vdf_summary()[0][\"node_name\", \"path_id\", \"localplan_id\", \"operator_name\", \"thread_count\", \"exec_time_us\", \"prod_rows\", \"proc_rows\", \"clock_time_us\", \"mem_all_b\"]\n",
" summary_vdf_main = qprof._get_vdf_summary()[0]\n",
" summary_vdf = summary_vdf_main[\"node_name\", \"path_id\", \"localplan_id\", \"operator_name\", \"thread_count\", \"exec_time_us\", \"prod_rows\", \"proc_rows\", \"clock_time_us\", \"mem_all_b\"]\n",
"\n",
" # Update dropdowns\n",
" summary_node_name_dropdown.options = ['All'] + sorted(summary_vdf[\"node_name\"].distinct())\n",
Expand All @@ -882,11 +859,23 @@
" summary_operator_name_dropdown.options = ['All'] + sorted(summary_vdf[\"operator_name\"].distinct())\n",
" summary_baseplan_id_dropdown.options = ['All'] + sorted(vdf_across_nodes[\"baseplan_id\"].distinct())\n",
"\n",
" summary_vdf_main = summary_vdf\n",
"\n",
" # Initial table updates\n",
" display_vdf_across_paths()\n",
" detailed_update_table()\n",
"\n",
" tags = sorted(qprof.get_qexecution_report(return_useful_cols=True))\n",
"\n",
" # Create checkboxes\n",
" checkboxes = [\n",
" widgets.Checkbox(value=(tag in [\"exec_time_us\", \"prod_rows\", \"proc_rows\", \"clock_time_us\", \"mem_all_b\"]), description=tag) \n",
" for tag in tags\n",
" ]\n",
"\n",
" # Attach the observer to each checkbox\n",
" for cb in checkboxes:\n",
" cb.observe(on_checkbox_change, names='value')\n",
"\n",
" except Exception as e:\n",
" with engine_tab_summary_1:\n",
" engine_tab_summary_1.clear_output(wait=True)\n",
Expand Down

0 comments on commit 7ea6ced

Please sign in to comment.