Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QueryProfiler UI Update #241

Merged
merged 7 commits into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
4 changes: 2 additions & 2 deletions project/ui/conn.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -254,8 +254,8 @@
"from IPython.display import display, HTML\n",
"\n",
"# Define the URLs for the links\n",
"url1 = \"http://127.0.0.1:8889/lab/workspaces/auto-3\"\n",
"url2 = \"http://127.0.0.1:8889/voila/render/ui/qprof_main.ipynb\"\n",
"url1 = \"/lab/workspaces/auto-3\"\n",
roypaulin marked this conversation as resolved.
Show resolved Hide resolved
"url2 = \"/voila/render/ui/qprof_main.ipynb\"\n",
"\n",
"# Define the button labels\n",
"button_label1 = \"Go to Home Page\"\n",
Expand Down
16 changes: 11 additions & 5 deletions project/ui/qprof-ui.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": null,
"execution_count": 1,
"id": "0221f436-1e34-405a-b28c-293eac20c369",
"metadata": {
"scrolled": true
Expand All @@ -22,6 +22,8 @@
" %store -r transaction_val\n",
" %store -r statement_val\n",
" %store -r file_val\n",
" %store -r target_schema_val_2\n",
" %store -r key_val_2\n",
"\n",
" if \"file_val\" in globals():\n",
" qprof = QueryProfiler.import_profile(target_schema=target_schema_val,\n",
Expand All @@ -31,7 +33,7 @@
" )\n",
" qprof = QueryProfilerInterface(\n",
" target_schema = target_schema_val,\n",
" key_id = key_val,\n",
" key_id = key_val if \"key_val\" in globals() else None,\n",
" )\n",
" elif \"target_schema_val\" in globals():\n",
" qprof = QueryProfilerInterface(\n",
Expand All @@ -40,11 +42,15 @@
" )\n",
" elif \"query_val\" in globals():\n",
" qprof = QueryProfilerInterface(\n",
" query_val\n",
" query_val,\n",
" target_schema = target_schema_val_2 if \"target_schema_val_2\" in globals() else None,\n",
" key_id = key_val_2 if \"key_val_2\" in globals() else None, \n",
" )\n",
" elif \"transaction_val\" in globals():\n",
" qprof = QueryProfilerInterface(\n",
" transactions = (transaction_val, statement_val)\n",
" transactions = (transaction_val, statement_val),\n",
" target_schema = target_schema_val_2 if \"target_schema_val_2\" in globals() else None,\n",
" key_id = key_val_2 if \"key_val_2\" in globals() else None,\n",
" )"
]
},
Expand Down Expand Up @@ -121,7 +127,7 @@
"outputs": [],
"source": [
"# Define the URLs for the links\n",
"url1 = \"http://127.0.0.1:8889/voila/render/ui/qprof_main.ipynb\"\n",
"url1 = \"/voila/render/ui/qprof_main.ipynb\"\n",
"# Define the button labels\n",
"button_label1 = \"Go Back\"\n",
"# Define HTML links for button\n",
Expand Down
178 changes: 55 additions & 123 deletions project/ui/qprof_main.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"id": "df021d4b-5dc7-4c43-b223-e5ba20728ab0",
"metadata": {},
"outputs": [],
Expand All @@ -21,12 +21,12 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"id": "535b9b43-6aa3-4fa1-b6ef-1cff6048478d",
"metadata": {},
"outputs": [],
"source": [
"def reset_values(query_val = None, key_val = None, target_schema_val = None, transaction_val = None, statement_val = None, file_val = None): \n",
"def reset_values(query_val = None, key_val = None, target_schema_val = None, transaction_val = None, statement_val = None, file_val = None, key_val_2 = None, target_schema_val_2 = None): \n",
" if query_val:\n",
" %store query_val\n",
" else:\n",
Expand All @@ -51,49 +51,35 @@
" %store file_val\n",
" else:\n",
" %store -d file_val\n",
" if key_val_2:\n",
" %store key_val_2\n",
" else: \n",
" %store -d key_val_2\n",
" if target_schema_val_2:\n",
" %store target_schema_val_2\n",
" else:\n",
" %store -d target_schema_val_2\n",
" notebook_url = '/voila/render/ui/qprof-ui.ipynb'\n",
" display(HTML(f\"<script>window.open('{notebook_url}');window.close();</script>\"))"
]
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": null,
"id": "c5dbc921-631c-452e-bc3f-2dd91bdbef39",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<h2> Connection Info </h2>\n"
],
"text/plain": [
"<IPython.core.display.HTML object>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"outputs": [],
"source": [
"%%html\n",
"<h2> Connection Info </h2>"
]
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": null,
"id": "8d23fd76-3f33-494b-8fe4-49f45de9ec31",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1mDatabase\u001b[0m: vdash\n",
"\u001b[1mUsername\u001b[0m: sfduty_rw\n"
]
}
],
"outputs": [],
"source": [
"print(\"\\033[1mDatabase\\033[0m:\", vp.current_connection().options['database'])\n",
"print(\"\\033[1mUsername\\033[0m:\", vp.current_connection().options['user'])"
Expand All @@ -117,7 +103,7 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": null,
"id": "f2df8e39-73e2-463c-b450-eacccd1823b0",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -152,8 +138,8 @@
" key_val = key.value\n",
" target_schema_val = target_schema.value\n",
" file_val = uploader.value\n",
" if key_val == \"\" or target_schema_val == \"\" or file_val == \"\":\n",
" print(\"Error! You must provide value for all: Schema, Key and File.\")\n",
" if target_schema_val == \"\" or file_val == \"\":\n",
" print(\"Error! You must provide a value for Schema and File.\")\n",
" return\n",
" else:\n",
" reset_values(key_val = key_val, target_schema_val = target_schema_val, file_val = file_val)\n",
Expand All @@ -163,22 +149,10 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": null,
"id": "b0f623e0-05df-4752-ae85-6fdbe29be943",
"metadata": {},
"outputs": [
{
"ename": "NameError",
"evalue": "name 'button_2' is not defined",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
"Cell \u001b[0;32mIn[6], line 11\u001b[0m\n\u001b[1;32m 7\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mipyfilechooser\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m FileChooser\n\u001b[1;32m 10\u001b[0m tab \u001b[38;5;241m=\u001b[39m widgets\u001b[38;5;241m.\u001b[39mTab()\n\u001b[0;32m---> 11\u001b[0m child_1 \u001b[38;5;241m=\u001b[39m widgets\u001b[38;5;241m.\u001b[39mVBox([target_schema,key,\u001b[43mbutton_2\u001b[49m, output_2])\n\u001b[1;32m 12\u001b[0m child_2 \u001b[38;5;241m=\u001b[39m widgets\u001b[38;5;241m.\u001b[39mVBox([target_schema,key,uploader,button_3, output_3])\n\u001b[1;32m 13\u001b[0m tab\u001b[38;5;241m.\u001b[39mchildren \u001b[38;5;241m=\u001b[39m [child_1, child_2]\n",
"\u001b[0;31mNameError\u001b[0m: name 'button_2' is not defined"
]
}
],
"outputs": [],
"source": [
"key = widgets.Text(description = \"Key\", placeholder = \"Enter Key\", layout=widgets.Layout(width='300px'))\n",
"key.style.description_width = '100px'\n",
Expand Down Expand Up @@ -215,39 +189,10 @@
},
{
"cell_type": "code",
"execution_count": 20,
"execution_count": null,
"id": "3cff15cf-0b8d-4651-89dd-026b4e8c9121",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "f827b937f2f649b6a08f66f84139fc46",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Button(description='Query Request Table', layout=Layout(width='auto'), style=ButtonStyle())"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "497a25493a024a7488cf5b266eccdb95",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Output()"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"outputs": [],
"source": [
"button_01 = widgets.Button(description=\"Query Request Table\", layout=widgets.Layout(width='auto'))\n",
"output_01 = widgets.Output()\n",
Expand All @@ -266,7 +211,7 @@
},
{
"cell_type": "code",
"execution_count": 21,
"execution_count": null,
"id": "59c1d00b-0ecd-429f-8d39-af3b0ca8f215",
"metadata": {},
"outputs": [],
Expand All @@ -279,7 +224,20 @@
},
{
"cell_type": "code",
"execution_count": 22,
"execution_count": null,
"id": "c18c43b6-9bae-4371-aec1-87d35a30160e",
"metadata": {},
"outputs": [],
"source": [
"key_2 = widgets.Text(description = \"Key\", placeholder = \"Enter Key (Optional)\", layout=widgets.Layout(width='300px'))\n",
"key_2.style.description_width = '100px'\n",
"target_schema_2 = widgets.Text(description = \"Target Schema (Optional)\", placeholder = \"Enter Schema\",layout=widgets.Layout(width='300px'))\n",
"target_schema_2.style.description_width = '100px'"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "69be4766-8633-4bd9-8588-42967d27a6fb",
"metadata": {},
"outputs": [],
Expand All @@ -288,21 +246,26 @@
"output_1 = widgets.Output()\n",
"transaction_val = None\n",
"statement_val = None\n",
"target_schema_val_2 = None\n",
"key_val_2 = None\n",
"\n",
"def on_button_clicked_1(b):\n",
" output_1.clear_output(wait=True)\n",
" global target_schema_val_2, key_val_2, statement_val, transaction_val\n",
" with output_1:\n",
" target_schema_val_2 = target_schema_2.value\n",
" key_val_2 = key_2.value\n",
" transaction_val = transaction.value\n",
" statement_val = statement.value\n",
" reset_values(statement_val = statement_val, transaction_val = transaction_val)\n",
" reset_values(statement_val = statement_val, transaction_val = transaction_val, target_schema_val_2 = target_schema_val_2, key_val_2 = key_val_2)\n",
"\n",
"button_1.on_click(on_button_clicked_1)\n",
"create_0 = widgets.VBox([transaction,statement, button_1, output_1])"
"create_0 = widgets.VBox([target_schema_2, key_2,transaction,statement, button_1, output_1])"
]
},
{
"cell_type": "code",
"execution_count": 23,
"execution_count": null,
"id": "19e7defc-558f-455a-bc6e-4c6bc2cade65",
"metadata": {},
"outputs": [],
Expand All @@ -317,7 +280,7 @@
},
{
"cell_type": "code",
"execution_count": 24,
"execution_count": null,
"id": "f82c652f-0dca-48ce-a2f7-3c5eda71f3fe",
"metadata": {},
"outputs": [],
Expand All @@ -328,36 +291,23 @@
"\n",
"def on_button_clicked_0(b):\n",
" output_0.clear_output(wait=True)\n",
" global query_val\n",
" global query_val, target_schema_val_2, key_val_2\n",
" with output_0:\n",
" target_schema_val_2 = target_schema_2.value\n",
" key_val_2 = key_2.value\n",
" query_val = query.value\n",
" reset_values(query_val = query_val)\n",
" reset_values(query_val = query_val, target_schema_val_2 = target_schema_val_2, key_val_2 = key_val_2)\n",
"\n",
"button.on_click(on_button_clicked_0)\n",
"create_1 = widgets.VBox([query, button, output_0])\n"
"create_1 = widgets.VBox([target_schema_2, key_2, query, button, output_0])\n"
]
},
{
"cell_type": "code",
"execution_count": 25,
"execution_count": null,
"id": "fbb6fb85-5802-4786-a656-c98f1b5645eb",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "ccce0cb35655426799a680f3ff24dc8d",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Tab(children=(VBox(children=(Text(value='', description='Transaction ID', layout=Layout(width='300px'), placeh…"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"outputs": [],
"source": [
"tab_2 = widgets.Tab()\n",
"tab_2.children = [create_0, create_1]\n",
Expand All @@ -375,28 +325,10 @@
},
{
"cell_type": "code",
"execution_count": 26,
"execution_count": null,
"id": "94c36c65-098c-4bfd-9820-156c8cbc0d81",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"<style>\n",
".jupyter-widgets.widget-tab > .lm-TabBar .lm-TabBar-tab {\n",
" flex: 0 1 auto\n",
"}\n",
"</style>\n"
],
"text/plain": [
"<IPython.core.display.HTML object>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"outputs": [],
"source": [
"from IPython.display import HTML\n",
"\n",
Expand Down
Loading