From 962848c97846875b1123f6bfe947c56e33153114 Mon Sep 17 00:00:00 2001 From: saravmajestic Date: Thu, 3 Oct 2024 14:21:38 +0530 Subject: [PATCH 1/2] fix: custom model tests --- .../altimateWebviewProvider.ts | 2 +- .../components/test/AddCustomTest.tsx | 30 ++++++++++++++----- .../queryPanel/QueryPanelDefaultView.tsx | 17 +++++++++-- 3 files changed, 38 insertions(+), 11 deletions(-) diff --git a/src/webview_provider/altimateWebviewProvider.ts b/src/webview_provider/altimateWebviewProvider.ts index 5e1c522ed..f1020eeb1 100644 --- a/src/webview_provider/altimateWebviewProvider.ts +++ b/src/webview_provider/altimateWebviewProvider.ts @@ -446,7 +446,7 @@ export class AltimateWebviewProvider implements WebviewViewProvider { infoMessage: string; items: any[]; }; - window.showErrorMessage(args.infoMessage, ...args.items); + window.showErrorMessage(args.infoMessage, ...(args.items || [])); break; case "showWarningMessage": this.handleWarningMessage( diff --git a/webview_panels/src/modules/dataPilot/components/test/AddCustomTest.tsx b/webview_panels/src/modules/dataPilot/components/test/AddCustomTest.tsx index 375ba93a4..31719d5db 100644 --- a/webview_panels/src/modules/dataPilot/components/test/AddCustomTest.tsx +++ b/webview_panels/src/modules/dataPilot/components/test/AddCustomTest.tsx @@ -7,7 +7,10 @@ import { updatePackageVersions, upsertFollowup, } from "@modules/dataPilot/dataPilotSlice"; -import { executeRequestInSync } from "@modules/app/requestExecutor"; +import { + executeRequestInAsync, + executeRequestInSync, +} from "@modules/app/requestExecutor"; import { panelLogger } from "@modules/logger"; const DependentPackages = ["dbt_expectations", "dbt_utils"]; @@ -50,6 +53,23 @@ const AddCustomTest = (): JSX.Element | null => { } const { meta } = chat; + if (!meta?.column && !meta?.model) { + executeRequestInAsync("showErrorMessage", { + infoMessage: + "Missing column and model information. Please try again after reloading vscode.", + }); + return; + } + + const userPrompt = meta.column + ? `Add Custom Test for column: ${meta.column as string}` + : `Add Custom Test for model: ${meta.model as string}`; + const response = meta.column + ? `Generate Tests for column “${meta?.column as string}” in model “${ + meta?.model as string + }“` + : `Generate Tests for model “${meta?.model as string}“`; + dispatch( upsertFollowup({ sessionId: chat?.id, @@ -58,12 +78,8 @@ const AddCustomTest = (): JSX.Element | null => { datapilotTitle: " Datapilot response", actions: [], state: RequestState.COMPLETED, - userPrompt: `Add Custom Test for column: ${meta?.column as string}`, - response: `Generate Tests for column “${ - meta?.column as string - }” in model “${ - meta?.model as string - }“ \n\r Please provide more information about which tests you need`, + userPrompt, + response: `${response} \n\r Please provide more information about which tests you need`, hideFeedback: true, }, }), diff --git a/webview_panels/src/modules/queryPanel/QueryPanelDefaultView.tsx b/webview_panels/src/modules/queryPanel/QueryPanelDefaultView.tsx index 9aaf91c29..1ec3ede77 100644 --- a/webview_panels/src/modules/queryPanel/QueryPanelDefaultView.tsx +++ b/webview_panels/src/modules/queryPanel/QueryPanelDefaultView.tsx @@ -10,11 +10,22 @@ const QueryPanelDefaultView = (): JSX.Element => {
-

Upcoming Feature Alert: Enhanced Support for dbt SQL Execution in Notebooks

-

We're excited to announce that soon, you'll be able to execute dbt SQL directly within notebooks. This new feature will empower you to create data-driven stories, streamline debugging processes, and optimize your workflows—all within VSCode. Stay tuned for more updates and contact us if you would like an early access!

+

+ Upcoming Feature Alert: Enhanced Support for dbt SQL Execution in + Notebooks +

+

+ We're excited to announce that soon, you'll be able to + execute dbt SQL directly within notebooks. This new feature will + empower you to create data-driven stories, streamline debugging + processes, and optimize your workflows—all within VSCode. Stay tuned + for more updates and{" "} + contact us if you + would like an early access! +

Query History, Bookmarks, and More

{/* TODO: get the actual text from Pradnesh */} -

+


Execute any SQL query with the "+ New Query" button. Every query you run in the current VSCode session is stored in your query From 38fd50c4ad7f73c1ec634976f04754086f7e0719 Mon Sep 17 00:00:00 2001 From: saravmajestic Date: Thu, 3 Oct 2024 16:00:49 +0530 Subject: [PATCH 2/2] fix: notebook demo content --- src/lib/index.js | 1215 +++++++++-------- .../RunAdhocQueryButton.tsx | 9 +- 2 files changed, 646 insertions(+), 578 deletions(-) diff --git a/src/lib/index.js b/src/lib/index.js index 657c7d383..8e1e0d48e 100644 --- a/src/lib/index.js +++ b/src/lib/index.js @@ -2,34 +2,34 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" }); const l = require("vscode"), u = require("@extension"), - L = require("python-bridge"), + B = require("python-bridge"), H = require("fs"), J = require("@nteract/messaging/lib/wire-protocol"); -function Y(n) { +function Y(r) { const e = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } }); - if (n) { - for (const t in n) + if (r) { + for (const t in r) if (t !== "default") { - const r = Object.getOwnPropertyDescriptor(n, t); + const o = Object.getOwnPropertyDescriptor(r, t); Object.defineProperty( e, t, - r.get ? r : { enumerable: !0, get: () => n[t] }, + o.get ? o : { enumerable: !0, get: () => r[t] }, ); } } - return (e.default = n), Object.freeze(e); + return (e.default = r), Object.freeze(e); } const $ = Y(J), - G = (n) => ("getCells" in n ? n.getCells() : n.cells), - Q = (n) => (n instanceof l.NotebookCellData ? n.value : n.document.getText()), - X = (n) => - n instanceof l.NotebookCellData ? n.languageId : n.document.languageId, - A = (n, e, t) => { - var o; - const r = []; - for (const i of G(n)) - r.push({ + G = (r) => ("getCells" in r ? r.getCells() : r.cells), + Q = (r) => (r instanceof l.NotebookCellData ? r.value : r.document.getText()), + X = (r) => + r instanceof l.NotebookCellData ? r.languageId : r.document.languageId, + A = (r, e, t) => { + var n; + const o = []; + for (const i of G(r)) + o.push({ cell_type: i.kind, source: Q(i).split(/\r?\n/g), languageId: X(i), @@ -37,12 +37,12 @@ const $ = Y(J), outputs: t ? i.outputs : void 0, }); return { - cells: r, + cells: o, metadata: { - ...n.metadata, + ...r.metadata, name: e, createdAt: - ((o = n.metadata) == null ? void 0 : o.createdAt) || + ((n = r.metadata) == null ? void 0 : n.createdAt) || new Date().toISOString(), updatedAt: new Date().toISOString(), }, @@ -50,36 +50,36 @@ const $ = Y(J), }, _ = () => Math.random().toString(36).substr(2, 9); function Z() { - const n = new Date(), - e = n.toLocaleDateString("en-GB").replace(/\//g, "-"), - t = n.toLocaleTimeString("en-GB", { hour12: !1 }).replace(/:/g, "-"); + const r = new Date(), + e = r.toLocaleDateString("en-GB").replace(/\//g, "-"), + t = r.toLocaleTimeString("en-GB", { hour12: !1 }).replace(/:/g, "-"); return `${e}-${t}`; } -var ee = function (n, e, t, r) { - var o = arguments.length, +var ee = function (r, e, t, o) { + var n = arguments.length, i = - o < 3 ? e : r === null ? (r = Object.getOwnPropertyDescriptor(e, t)) : r, + n < 3 ? e : o === null ? (o = Object.getOwnPropertyDescriptor(e, t)) : o, s; if (typeof Reflect == "object" && typeof Reflect.decorate == "function") - i = Reflect.decorate(n, e, t, r); + i = Reflect.decorate(r, e, t, o); else - for (var a = n.length - 1; a >= 0; a--) - (s = n[a]) && (i = (o < 3 ? s(i) : o > 3 ? s(e, t, i) : s(e, t)) || i); - return o > 3 && i && Object.defineProperty(e, t, i), i; + for (var a = r.length - 1; a >= 0; a--) + (s = r[a]) && (i = (n < 3 ? s(i) : n > 3 ? s(e, t, i) : s(e, t)) || i); + return n > 3 && i && Object.defineProperty(e, t, i), i; }; let E = class { dispose() { throw new Error("Method not implemented."); } async deserializeNotebook(e, t) { - const r = new TextDecoder().decode(e); - let o; + const o = new TextDecoder().decode(e); + let n; try { - o = JSON.parse(r); + n = JSON.parse(o); } catch { - o = { cells: [] }; + n = { cells: [] }; } - const i = o.cells.map((a) => { + const i = n.cells.map((a) => { var d; const c = new l.NotebookCellData( a.cell_type, @@ -92,19 +92,19 @@ let E = class { return (c.metadata = a.metadata), (c.outputs = a.outputs), c; }), s = new l.NotebookData(i); - return (s.metadata = o.metadata), s; + return (s.metadata = n.metadata), s; } async serializeNotebook(e, t) { - const r = A(e); - return new TextEncoder().encode(JSON.stringify(r)); + const o = A(e); + return new TextEncoder().encode(JSON.stringify(o)); } }; E = ee([u.provideSingleton(E)], E); var g; -(function (n) { - (n.error = "application/vnd.code.notebook.error"), - (n.stderr = "application/vnd.code.notebook.stderr"), - (n.stdout = "application/vnd.code.notebook.stdout"); +(function (r) { + (r.error = "application/vnd.code.notebook.error"), + (r.stderr = "application/vnd.code.notebook.stderr"), + (r.stdout = "application/vnd.code.notebook.stdout"); })(g || (g = {})); const te = ["text/plain", "text/markdown", g.stderr, g.stdout], F = [ @@ -124,212 +124,212 @@ const te = ["text/plain", "text/markdown", g.stderr, g.stdout], "text/plain", ], k = new Map(); -k.set("display_data", S); +k.set("display_data", M); k.set("error", de); -k.set("execute_result", S); +k.set("execute_result", M); k.set("stream", ue); -k.set("update_display_data", S); -function M(n) { - const e = k.get(n.output_type); +k.set("update_display_data", M); +function S(r) { + const e = k.get(r.output_type); let t; return ( e - ? (t = e(n)) + ? (t = e(r)) : (console.warn( - `Unable to translate cell from ${n.output_type} to NotebookCellData for VS Code.`, + `Unable to translate cell from ${r.output_type} to NotebookCellData for VS Code.`, ), - (t = S(n))), + (t = M(r))), t ); } -function W(n) { - const e = { outputType: n.output_type }; - switch ((n.transient && (e.transient = n.transient), n.output_type)) { +function W(r) { + const e = { outputType: r.output_type }; + switch ((r.transient && (e.transient = r.transient), r.output_type)) { case "display_data": case "execute_result": case "update_display_data": { - (e.executionCount = n.execution_count), - (e.metadata = n.metadata ? JSON.parse(JSON.stringify(n.metadata)) : {}); + (e.executionCount = r.execution_count), + (e.metadata = r.metadata ? JSON.parse(JSON.stringify(r.metadata)) : {}); break; } } return e; } -function S(n) { - const e = W(n); - ("image/svg+xml" in n.data || "image/png" in n.data) && +function M(r) { + const e = W(r); + ("image/svg+xml" in r.data || "image/png" in r.data) && (e.__displayOpenPlotIcon = !0); const t = []; - if (n.data) for (const r in n.data) t.push(ne(r, n.data[r])); - return new l.NotebookCellOutput(re(t), e); + if (r.data) for (const o in r.data) t.push(re(o, r.data[o])); + return new l.NotebookCellOutput(oe(t), e); } -function re(n) { - return n.sort((e, t) => { - const r = (s, a) => ( +function oe(r) { + return r.sort((e, t) => { + const o = (s, a) => ( s.endsWith(".*") && (s = s.substr(0, s.indexOf(".*"))), a.startsWith(s) ); - let o = F.findIndex((s) => r(s, e.mime)), - i = F.findIndex((s) => r(s, t.mime)); + let n = F.findIndex((s) => o(s, e.mime)), + i = F.findIndex((s) => o(s, t.mime)); return ( - B(e) && (o = -1), - B(t) && (i = -1), - (o = o === -1 ? 100 : o), + q(e) && (n = -1), + q(t) && (i = -1), + (n = n === -1 ? 100 : n), (i = i === -1 ? 100 : i), - o - i + n - i ); }); } -function B(n) { - if (n.mime.startsWith("application/vnd.")) +function q(r) { + if (r.mime.startsWith("application/vnd.")) try { - return new TextDecoder().decode(n.data).length === 0; + return new TextDecoder().decode(r.data).length === 0; } catch {} return !1; } -function ne(n, e) { - if (!e) return l.NotebookCellOutputItem.text("", n); +function re(r, e) { + if (!e) return l.NotebookCellOutputItem.text("", r); try { if ( - (n.startsWith("text/") || te.includes(n)) && + (r.startsWith("text/") || te.includes(r)) && (Array.isArray(e) || typeof e == "string") ) { const t = Array.isArray(e) ? D(e) : e; - return l.NotebookCellOutputItem.text(t, n); + return l.NotebookCellOutputItem.text(t, r); } else - return n.startsWith("image/") && + return r.startsWith("image/") && typeof e == "string" && - n !== "image/svg+xml" - ? new l.NotebookCellOutputItem(oe(e), n) + r !== "image/svg+xml" + ? new l.NotebookCellOutputItem(ne(e), r) : typeof e == "object" && e !== null && !Array.isArray(e) - ? l.NotebookCellOutputItem.text(JSON.stringify(e), n) + ? l.NotebookCellOutputItem.text(JSON.stringify(e), r) : ((e = Array.isArray(e) ? D(e) : e), - l.NotebookCellOutputItem.text(e, n)); + l.NotebookCellOutputItem.text(e, r)); } catch (t) { return ( console.error( - `Failed to convert ${n} output to a buffer ${typeof e}, ${e}`, + `Failed to convert ${r} output to a buffer ${typeof e}, ${e}`, t, ), l.NotebookCellOutputItem.text("") ); } } -function oe(n) { +function ne(r) { return typeof Buffer < "u" && typeof Buffer.from == "function" - ? Buffer.from(n, "base64") - : Uint8Array.from(atob(n), (e) => e.charCodeAt(0)); + ? Buffer.from(r, "base64") + : Uint8Array.from(atob(r), (e) => e.charCodeAt(0)); } -function D(n) { - if (Array.isArray(n)) { +function D(r) { + if (Array.isArray(r)) { let e = ""; - for (let t = 0; t < n.length; t += 1) { - const r = n[t]; - t < n.length - 1 && - !r.endsWith(` + for (let t = 0; t < r.length; t += 1) { + const o = r[t]; + t < r.length - 1 && + !o.endsWith(` `) - ? (e = e.concat(`${r} + ? (e = e.concat(`${o} `)) - : (e = e.concat(r)); + : (e = e.concat(o)); } return e; } - return n.toString(); + return r.toString(); } -function ie(n) { - let e = n; - do (n = e), (e = n.replace(/[^\n]\x08/gm, "")); - while (e.length < n.length); - return n; +function ie(r) { + let e = r; + do (r = e), (e = r.replace(/[^\n]\x08/gm, "")); + while (e.length < r.length); + return r; } -function ae(n) { +function ae(r) { for ( - n = n.replace( + r = r.replace( /\r+\n/gm, ` `, ); - n.search(/\r[^$]/g) > -1; + r.search(/\r[^$]/g) > -1; ) { - const e = n.match(/^(.*)\r+/m)[1]; - let t = n.match(/\r+(.*)$/m)[1]; + const e = r.match(/^(.*)\r+/m)[1]; + let t = r.match(/\r+(.*)$/m)[1]; (t = t + e.slice(t.length, e.length)), - (n = n.replace(/\r+.*$/m, "\r").replace(/^.*\r/m, t)); + (r = r.replace(/\r+.*$/m, "\r").replace(/^.*\r/m, t)); } - return n; + return r; } -function se(n) { - return ae(ie(n)); +function se(r) { + return ae(ie(r)); } -function N(n) { - if (n.parent_header && "msg_id" in n.parent_header) - return n.parent_header.msg_id; +function N(r) { + if (r.parent_header && "msg_id" in r.parent_header) + return r.parent_header.msg_id; } -function le(n) { - if (n.hasOwnProperty("text/html")) { - const e = n["text/html"]; +function le(r) { + if (r.hasOwnProperty("text/html")) { + const e = r["text/html"]; typeof e == "string" && e.includes('