Skip to content

Commit

Permalink
Merge pull request #275 from vertica/nocode_ui_pages_update_08
Browse files Browse the repository at this point in the history
  • Loading branch information
oualib authored Jun 24, 2024
2 parents 0def35f + 1fca17f commit 3ccf527
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 25 deletions.
33 changes: 22 additions & 11 deletions project/ui/qprof-ui.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@
"import ipywidgets as widgets\n",
"from datetime import datetime, timezone\n",
"import time\n",
"import random\n",
"import string\n",
"import verticapy as vp\n",
"import plotly.graph_objects as go\n",
"from verticapy.performance.vertica import QueryProfilerInterface, QueryProfiler\n",
Expand All @@ -92,16 +94,19 @@
" %store -r transaction_statement_list_val\n",
"\n",
" if \"file_val\" in globals():\n",
" if not \"key_val\" in globals():\n",
" characters = string.ascii_letters + string.digits # includes 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'\n",
" key_val = ''.join(random.choice(characters) for _ in range(15))\n",
" logging.info(f'[Query Profile Tree Page] Importing profile using target_schema as {target_schema_val}, key_id as {key_val}, filename as{file_val}')\n",
" qprof = QueryProfiler.import_profile(target_schema=target_schema_val,\n",
" key_id=key_val,\n",
" key_id = key_val,\n",
" filename=file_val,\n",
" auto_initialize = False \n",
" )\n",
" logging.info(f'[Query Profile Tree Page] Creating qprof object using target_schema as {target_schema_val}, key_id as {key_val if \"key_val\" in globals() else None}.')\n",
" qprof = QueryProfilerInterface(\n",
" target_schema = target_schema_val,\n",
" key_id = key_val if \"key_val\" in globals() else None,\n",
" key_id = key_val,\n",
" )\n",
" elif \"target_schema_val\" in globals():\n",
" logging.info(f'[Query Profile Tree Page] Creating qprof object using target_schema as {target_schema_val}, key_id as {key_val}. [Query Profile Tree Page]')\n",
Expand Down Expand Up @@ -393,13 +398,19 @@
"except Exception as e:\n",
" tables = widgets.VBox([widgets.HTML(f\"<p style='color:red'>The following error occured: </p> <p> {e}</p>\")])\n",
"\n",
"try:\n",
" transactions_table_output = widgets.Output()\n",
" with transactions_table_output:\n",
" qprof.get_queries()[qprof.get_queries().get_columns(exclude_columns = \"is_current\")].idisplay()\n",
" transactions_table = widgets.VBox([transactions_table_output])\n",
"except Exception as e:\n",
" transactions_table = widgets.VBox([widgets.HTML(f\"<p style='color:red'>The following error occured: </p> <p> {e}</p>\")])"
"\n",
"button_get_queries = widgets.Button(description=\"Get Detailed Info\")\n",
"output_get_queries = widgets.Output()\n",
"\n",
"def on_button_clicked_get_queries(b):\n",
" output_get_queries.clear_output(wait=True)\n",
" with output_get_queries:\n",
" try:\n",
" qprof.get_queries()[qprof.get_queries().get_columns(exclude_columns = \"is_current\")].idisplay()\n",
" except Exception as e:\n",
" widgets.VBox([widgets.HTML(f\"<p style='color:red'>The following error occured: </p> <p> {e}</p>\")])\n",
"\n",
"button_get_queries.on_click(on_button_clicked_get_queries)"
]
},
{
Expand Down Expand Up @@ -443,7 +454,7 @@
"tabs = widgets.Tab()\n",
"\n",
"child_1 = widgets.VBox([output_tree])\n",
"child_2 = widgets.VBox([transactions_table])\n",
"child_2 = widgets.VBox([button_get_queries, output_get_queries])\n",
"child_3 = widgets.VBox([tables])\n",
"child_4 = widgets.VBox([plot_tabs])\n",
"tabs.children = [child_1, child_2, child_3, child_4]\n",
Expand Down Expand Up @@ -691,7 +702,7 @@
"</head>\n",
"<body>\n",
" <div class=\"version\">\n",
" Page version update date: 6/11/2024\n",
" Page version update date: 6/24/2024\n",
" </div>\n",
"</body>\n",
"</html>"
Expand Down
26 changes: 12 additions & 14 deletions project/ui/qprof_main.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -273,18 +273,6 @@
"schema_dropdown.observe(update_key_dropdown_options, names='value')"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "dc6abb5f-e563-470c-9348-f309bf3c0501",
"metadata": {},
"outputs": [],
"source": [
"schema_name = \"alu\"\n",
"query = f\"SELECT schema_name FROM v_catalog.schemata WHERE schema_name = '{schema_name}';\"\n",
"vdf = vp.vDataFrame(query)"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down Expand Up @@ -335,10 +323,12 @@
" output_3.clear_output(wait=True)\n",
" with output_3:\n",
" key_val = key.value if key.value else key_dropdown.value\n",
" if key_val == False:\n",
" key_val = None\n",
" target_schema_val = target_schema.value if target_schema.value else schema_dropdown.value\n",
" file_val = uploader.value\n",
" logging.info(f\"[Query Profile Main Page] For load from file option, saved key value as :{key_val}, target schema as {target_schema_val}, file name as {file_val}.\")\n",
" if target_schema_val == \"\" or file_val == \"\":\n",
" if target_schema_val == \"\" or file_val == \"\" or target_schema_val == None:\n",
" print(\"\\033[91m\\033[1m Error! You must provide a value for Schema and File. \\033[0m\\033[0m\")\n",
" return\n",
" elif check_if_schema_key_exist(target_schema_val, key_val):\n",
Expand Down Expand Up @@ -790,11 +780,19 @@
"</head>\n",
"<body>\n",
" <div class=\"version\">\n",
" Page version update date: 6/12/2024\n",
" Page version update date: 6/24/2024\n",
" </div>\n",
"</body>\n",
"</html>"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "b79ab78a-ce86-4026-af21-9143c30a570d",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand Down

0 comments on commit 3ccf527

Please sign in to comment.