Skip to content

Commit

Permalink
Merge pull request #261 from vertica/query_profiler_tree_page_update_02
Browse files Browse the repository at this point in the history
Update QueryProfiler Tree Page - Advanced Display Options + Plots
  • Loading branch information
mail4umar authored May 23, 2024
2 parents 2400f62 + 93a71d7 commit d43484f
Showing 1 changed file with 194 additions and 71 deletions.
265 changes: 194 additions & 71 deletions project/ui/qprof-ui.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,10 @@
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"id": "c7fde2aa-9a00-43b2-8e83-dc89087fa142",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "02d833789e9d402d8b05bfcf10d8c179",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"HBox(children=(HTML(value=\"<a href='/lab/' style='text-decoration: none; padding: 8px; background-color: #007b…"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"outputs": [],
"source": [
"import ipywidgets as widgets\n",
"from IPython.display import display, HTML\n",
Expand Down Expand Up @@ -56,7 +41,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"id": "4d76e603-bb3e-4e2f-9664-56b67efd3edd",
"metadata": {},
"outputs": [],
Expand All @@ -72,7 +57,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": null,
"id": "0221f436-1e34-405a-b28c-293eac20c369",
"metadata": {
"scrolled": true
Expand Down Expand Up @@ -141,7 +126,75 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": null,
"id": "d012adaf-969e-469c-814c-ee1ef30ff125",
"metadata": {},
"outputs": [],
"source": [
"# Loading display settings\n",
"with output_initial:\n",
" # Initialize variables with default values\n",
" # count_widget_val = None\n",
" # footer_widget_val = None\n",
" # comma_widget_val = None\n",
" # percent_bar_widget_val = None\n",
" # max_cell_width_widget_val = None\n",
" # max_columns_widget_val = None\n",
" # max_rows_widget_val = None\n",
"\n",
" # Attempt to load stored variables\n",
" try:\n",
" %store -r count_widget_val\n",
" except KeyError:\n",
" pass\n",
" try:\n",
" %store -r footer_widget_val\n",
" except KeyError:\n",
" pass\n",
" try:\n",
" %store -r comma_widget_val\n",
" except KeyError:\n",
" pass\n",
" try:\n",
" %store -r percent_bar_widget_val\n",
" except KeyError:\n",
" pass\n",
" try:\n",
" %store -r max_cell_width_widget_val\n",
" except KeyError:\n",
" pass\n",
" try:\n",
" %store -r max_columns_widget_val\n",
" except KeyError:\n",
" pass\n",
" try:\n",
" %store -r max_rows_widget_val\n",
" except KeyError:\n",
" pass\n",
"\n",
" # Set options using the loaded or default values\n",
" try:\n",
" if count_widget_val is not None:\n",
" vp.set_option(\"count_on\", count_widget_val)\n",
" if footer_widget_val is not None:\n",
" vp.set_option(\"footer_on\", footer_widget_val)\n",
" if comma_widget_val is not None:\n",
" vp.set_option(\"insert_comma_numbers\", comma_widget_val)\n",
" if percent_bar_widget_val is not None:\n",
" vp.set_option(\"percent_bar\", percent_bar_widget_val)\n",
" if max_cell_width_widget_val is not None:\n",
" vp.set_option(\"max_cellwidth\", max_cell_width_widget_val)\n",
" if max_columns_widget_val is not None:\n",
" vp.set_option(\"max_columns\", max_columns_widget_val)\n",
" if max_rows_widget_val is not None:\n",
" vp.set_option(\"max_rows\", max_rows_widget_val)\n",
" except Exception as e:\n",
" print(e)\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "b74b0305-6612-4f85-aa18-ff0b36e5cd80",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -178,7 +231,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": null,
"id": "72beb96c-85b4-4331-8e92-c59be23ae5fb",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -219,7 +272,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": null,
"id": "ad4a224b-157f-4437-a053-45f3145eb584",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -252,7 +305,7 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": null,
"id": "da8af3a2-0c8c-4a82-a6ef-5edb15d53f72",
"metadata": {},
"outputs": [],
Expand All @@ -269,53 +322,10 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": null,
"id": "47599ae0-6ffa-41d9-b16a-f346b3f52d72",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "c8c3fc00be5244139de35530d14bb193",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"HBox(children=(HTML(value=\"<a href='/voila/render/ui/qprof_main.ipynb' style='text-decoration: none; padding: …"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "54b45da812df4224a1715f0880badfc7",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Output()"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "4f5abbe49dd64384865f86f9dff2865c",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Output()"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"outputs": [],
"source": [
"logging.info(f'[Query Profile Tree Page] Trying to display the back and \"save query plan\" button')\n",
"display(widgets.HBox([html_button1,button_download_report, button_qprof_save ]))\n",
Expand Down Expand Up @@ -471,19 +481,132 @@
{
"cell_type": "code",
"execution_count": null,
"id": "32cf2caa-2a1d-4545-81c2-76400e458032",
"id": "3e6fadfb-e275-4944-8926-cb8a33a9c866",
"metadata": {},
"outputs": [],
"source": [
"footer_widget = widgets.Checkbox(\n",
" value=True,\n",
" description='Footer on',\n",
" disabled=False,\n",
" indent=False\n",
")\n",
"count_widget = widgets.Checkbox(\n",
" value=False,\n",
" description='Count on',\n",
" disabled=False,\n",
" indent=False\n",
")\n",
"comma_widget = widgets.Checkbox(\n",
" value=False,\n",
" description='Insert commas for numbers',\n",
" disabled=False,\n",
" indent=False\n",
")\n",
"percent_bar_widget = widgets.Checkbox(\n",
" value=False,\n",
" description='Percent bar',\n",
" disabled=False,\n",
" indent=False\n",
")\n",
"max_cell_width_widget = widgets.BoundedIntText(\n",
" value=280,\n",
" min=250,\n",
" max=350,\n",
" step=1,\n",
" description='Maximum cell width:',\n",
" disabled=False,\n",
" layout=widgets.Layout(width='300px')\n",
")\n",
"max_cell_width_widget.style.description_width = '240px'\n",
"max_columns_widget = widgets.BoundedIntText(\n",
" value=50,\n",
" min=1,\n",
" max=150,\n",
" step=1,\n",
" description='Maximum number of columns to display:',\n",
" disabled=False,\n",
" layout=widgets.Layout(width='300px')\n",
")\n",
"max_columns_widget.style.description_width = '240px'\n",
"max_rows_widget = widgets.BoundedIntText(\n",
" value=100,\n",
" min=1,\n",
" max=4000,\n",
" step=1,\n",
" description='Maximum number of rows to display:',\n",
" disabled=False,\n",
" layout=widgets.Layout(width='300px')\n",
")\n",
"max_rows_widget.style.description_width = '240px'\n",
"warning_text = \"\"\"\n",
"<div style=\"background-color: #ffe5b3; color: #cc3300; padding: 10px; border: 1px solid #cc3300; border-radius: 5px;\">\n",
" <strong>Caution:</strong> These settings will reflect in your entire environment.\n",
"</div>\n",
"\"\"\"\n",
"\n",
"warning_message = widgets.HTML(value=warning_text)\n",
"advanced_display_settings = widgets.VBox([\n",
" warning_message,\n",
" footer_widget,\n",
" count_widget,\n",
" comma_widget,\n",
" percent_bar_widget,\n",
" max_cell_width_widget,\n",
" max_columns_widget,\n",
" max_rows_widget,\n",
" ],\n",
")\n",
"\n",
"\n",
"\n",
"update_advanced_display_options = widgets.Button(description=\"Update preferences\")\n",
"output_advanced_display_options = widgets.Output()\n",
"\n",
"def on_button_clicked_update_display_options(b):\n",
" output_advanced_display_options.clear_output(wait=True)\n",
" \n",
" # Capture widget values\n",
" with output_initial:\n",
" global count_widget_val, footer_widget_val, comma_widget_val, percent_bar_widget_val, max_cell_width_widget_val, max_columns_widget_val, max_rows_widget_val\n",
" count_widget_val = count_widget.value\n",
" footer_widget_val = footer_widget.value\n",
" comma_widget_val = comma_widget.value\n",
" percent_bar_widget_val = percent_bar_widget.value\n",
" max_cell_width_widget_val = max_cell_width_widget.value\n",
" max_columns_widget_val = max_columns_widget.value\n",
" max_rows_widget_val = max_rows_widget.value\n",
"\n",
" # Store the variables\n",
" with output_advanced_display_options:\n",
" %store count_widget_val footer_widget_val comma_widget_val percent_bar_widget_val max_cell_width_widget_val max_columns_widget_val max_rows_widget_val\n",
" alert_text = \"\"\"\n",
" <div style=\"background-color: #e6f7ff; color: #007bff; padding: 10px; border: 1px solid #007bff; border-radius: 5px;\">\n",
" <strong>Alert:</strong> Changes have been updated. Please refresh the page to see them.\n",
" </div>\n",
" \"\"\"\n",
" display(widgets.HTML(value=alert_text))\n",
"\n",
"update_advanced_display_options.on_click(on_button_clicked_update_display_options)\n",
"advanced_display_settings_widget = widgets.VBox([advanced_display_settings, update_advanced_display_options, output_advanced_display_options])"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "a8232375-7334-48eb-b691-c43312964439",
"metadata": {},
"outputs": [],
"source": [
"accordion = widgets.Accordion(children=[manual_query, output_initial], titles=('Manual Queries','Execution/Error Details',))\n",
"accordion = widgets.Accordion(children=[manual_query, output_initial, advanced_display_settings_widget], titles=('Manual Queries','Execution/Error Details','Advanced Output Settings'))\n",
"logging.info(f'[Query Profile Tree Page] Trying to display the error log at the bottom of the page')\n",
"accordion\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "3e6fadfb-e275-4944-8926-cb8a33a9c866",
"id": "48efab63-e87b-4fac-8891-67d28ed0b013",
"metadata": {},
"outputs": [],
"source": []
Expand Down

0 comments on commit d43484f

Please sign in to comment.