{ "cells": [ { "cell_type": "code", "execution_count": 57, "metadata": {}, "outputs": [], "source": [ "from IPython.display import JSON\n", "import json\n", "\n", "import difflib\n", "import vdom\n", "from vdom import h1, h2, h3, p, pre, b, div" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "def extract(data):\n", " return data['cells'][3]['outputs'][1]['data']" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [], "source": [ "with open(\"./KQL-bug.ipynb\") as kb:\n", " kql_bug_data = json.load(kb)\n", " \n", "with open(\"./KQL-papermill.ipynb\") as kp:\n", " kql_papermill_data = json.load(kp)" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [], "source": [ "kql_bug_cell_3_outputs = kql_bug_data['cells'][3]['outputs']\n", "kql_pap_cell_3_outputs = kql_papermill_data['cells'][3]['outputs']" ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "True" ] }, "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ "len(kql_bug_cell_3_outputs) == len(kql_pap_cell_3_outputs)" ] }, { "cell_type": "code", "execution_count": 62, "metadata": {}, "outputs": [ { "data": { "application/vdom.v1+json": { "attributes": {}, "children": [ { "attributes": {}, "children": [ "Running analysis on cell with code" ], "tagName": "p" }, { "attributes": {}, "children": [ "%kql StormEvents | take 10\n" ], "tagName": "pre" } ], "tagName": "div" }, "text/html": [ "

Running analysis on cell with code

%kql StormEvents | take 10\n",
       "
" ], "text/plain": [ "

Running analysis on cell with code

%kql StormEvents | take 10\n",
       "
" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/vdom.v1+json": { "attributes": {}, "children": [ "Output 0: same" ], "tagName": "h2" }, "text/html": [ "

Output 0: same

" ], "text/plain": [ "

Output 0: same

" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/vdom.v1+json": { "attributes": {}, "children": [ "Output 1: same" ], "tagName": "h2" }, "text/html": [ "

Output 1: same

" ], "text/plain": [ "

Output 1: same

" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/vdom.v1+json": { "attributes": {}, "children": [ "Output 2: NOT the same" ], "tagName": "h2" }, "text/html": [ "

Output 2: NOT the same

" ], "text/plain": [ "

Output 2: NOT the same

" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/vdom.v1+json": { "attributes": {}, "children": [ "Comparing keys" ], "tagName": "h3" }, "text/html": [ "

Comparing keys

" ], "text/plain": [ "

Comparing keys

" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/vdom.v1+json": { "attributes": {}, "children": [ { "attributes": {}, "children": [ "data" ], "tagName": "b" }, " - ", { "attributes": { "style": { "font-family": "monospace" } }, "children": [ "False" ], "tagName": "span" } ], "tagName": "div" }, "text/html": [ "
data - False
" ], "text/plain": [ "
data - False
" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/vdom.v1+json": { "attributes": {}, "children": [ { "attributes": {}, "children": [ "metadata" ], "tagName": "b" }, " - ", { "attributes": { "style": { "font-family": "monospace" } }, "children": [ "True" ], "tagName": "span" } ], "tagName": "div" }, "text/html": [ "
metadata - True
" ], "text/plain": [ "
metadata - True
" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/vdom.v1+json": { "attributes": {}, "children": [ { "attributes": {}, "children": [ "output_type" ], "tagName": "b" }, " - ", { "attributes": { "style": { "font-family": "monospace" } }, "children": [ "True" ], "tagName": "span" } ], "tagName": "div" }, "text/html": [ "
output_type - True
" ], "text/plain": [ "
output_type - True
" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/vdom.v1+json": { "attributes": {}, "children": [ "Output 3: NOT the same" ], "tagName": "h2" }, "text/html": [ "

Output 3: NOT the same

" ], "text/plain": [ "

Output 3: NOT the same

" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/vdom.v1+json": { "attributes": {}, "children": [ "Comparing keys" ], "tagName": "h3" }, "text/html": [ "

Comparing keys

" ], "text/plain": [ "

Comparing keys

" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/vdom.v1+json": { "attributes": {}, "children": [ { "attributes": {}, "children": [ "data" ], "tagName": "b" }, " - ", { "attributes": { "style": { "font-family": "monospace" } }, "children": [ "True" ], "tagName": "span" } ], "tagName": "div" }, "text/html": [ "
data - True
" ], "text/plain": [ "
data - True
" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/vdom.v1+json": { "attributes": {}, "children": [ { "attributes": {}, "children": [ "execution_count" ], "tagName": "b" }, " - ", { "attributes": { "style": { "font-family": "monospace" } }, "children": [ "False" ], "tagName": "span" } ], "tagName": "div" }, "text/html": [ "
execution_count - False
" ], "text/plain": [ "
execution_count - False
" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/vdom.v1+json": { "attributes": {}, "children": [ { "attributes": {}, "children": [ "metadata" ], "tagName": "b" }, " - ", { "attributes": { "style": { "font-family": "monospace" } }, "children": [ "True" ], "tagName": "span" } ], "tagName": "div" }, "text/html": [ "
metadata - True
" ], "text/plain": [ "
metadata - True
" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/vdom.v1+json": { "attributes": {}, "children": [ { "attributes": {}, "children": [ "output_type" ], "tagName": "b" }, " - ", { "attributes": { "style": { "font-family": "monospace" } }, "children": [ "True" ], "tagName": "span" } ], "tagName": "div" }, "text/html": [ "
output_type - True
" ], "text/plain": [ "
output_type - True
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "display(\n", " div(\n", " p(\"Running analysis on cell with code\"),\n", " pre(kql_bug_data['cells'][3]['source'])\n", " )\n", ")\n", "\n", "for (idx, _) in enumerate(kql_bug_cell_3_outputs):\n", " output_b = kql_bug_cell_3_outputs[idx]\n", " output_p = kql_pap_cell_3_outputs[idx]\n", " \n", " outputs_are_same = output_b == output_p\n", " if outputs_are_same:\n", " display(h2(f\"Output {idx}: same\"))\n", " else:\n", " display(h2(f\"Output {idx}: NOT the same\"))\n", " \n", " display(h3(\"Comparing keys\"))\n", " for k in output_b:\n", " display(div(b(k), \" - \", vdom.span(f\"{output_b[k] == output_p[k]}\", style={\"font-family\": \"monospace\"})))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Since output 3's only difference is the execution count, let's take a look at output 2 which has a difference in the data." ] }, { "cell_type": "code", "execution_count": 64, "metadata": {}, "outputs": [], "source": [ "bo_2 = kql_bug_cell_3_outputs[2]\n", "po_2 = kql_pap_cell_3_outputs[2]" ] }, { "cell_type": "code", "execution_count": 67, "metadata": {}, "outputs": [ { "data": { "application/vdom.v1+json": { "attributes": {}, "children": [ { "attributes": {}, "children": [ "text/html" ], "tagName": "h3" }, { "attributes": {}, "children": [ " \n", " \n", " \n", " \n", " \n", " \n", "-

Done (00:00.838): 10 records

\n", "? ^^\n", "+

Done (00:00.278): 10 records

\n", "? ^^\n", " \n", " " ], "tagName": "pre" } ], "tagName": "div" }, "text/html": [ "

text/html

  <html>\n",
       "          <head>\n",
       "              \n",
       "              \n",
       "          </head>\n",
       "          <body>\n",
       "-             <div><p style='padding: 10px; color: #3a87ad; background-color: #d9edf7; border-color: #bce9f1'>Done&nbsp;(00:00.838):&nbsp;10&nbsp;records</p></div>\n",
       "?                                                                                                                              ^^\n",
       "+             <div><p style='padding: 10px; color: #3a87ad; background-color: #d9edf7; border-color: #bce9f1'>Done&nbsp;(00:00.278):&nbsp;10&nbsp;records</p></div>\n",
       "?                                                                                                                              ^^\n",
       "          </body>\n",
       "          </html>
" ], "text/plain": [ "

text/html

  <html>\n",
       "          <head>\n",
       "              \n",
       "              \n",
       "          </head>\n",
       "          <body>\n",
       "-             <div><p style='padding: 10px; color: #3a87ad; background-color: #d9edf7; border-color: #bce9f1'>Done&nbsp;(00:00.838):&nbsp;10&nbsp;records</p></div>\n",
       "?                                                                                                                              ^^\n",
       "+             <div><p style='padding: 10px; color: #3a87ad; background-color: #d9edf7; border-color: #bce9f1'>Done&nbsp;(00:00.278):&nbsp;10&nbsp;records</p></div>\n",
       "?                                                                                                                              ^^\n",
       "          </body>\n",
       "          </html>
" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/vdom.v1+json": { "attributes": {}, "children": [ { "attributes": {}, "children": [ "text/plain" ], "tagName": "h3" }, { "attributes": {}, "children": [ " " ], "tagName": "pre" } ], "tagName": "div" }, "text/html": [ "

text/plain

  <IPython.core.display.HTML object>
" ], "text/plain": [ "

text/plain

  <IPython.core.display.HTML object>
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "for k in bo_2['data']:\n", " display(\n", " div(\n", " h3(k),\n", " pre(list(difflib.ndiff(bo_2['data'][k], po_2['data'][k])))\n", " )\n", " )" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.7.7" } }, "nbformat": 4, "nbformat_minor": 4 }