Skip to content

Commit 0504e1a

Browse files
Show stdout when job fails with exception (#265)
![Screenshot 2022-12-01 at 15 11 29](https://user-images.githubusercontent.com/40952/205074472-3288da0d-c97b-4c4f-8892-89c6da7867c0.png) Co-authored-by: Kartik Gupta <88345179+kartikgupta-db@users.noreply.github.com>
1 parent f8bd630 commit 0504e1a

File tree

2 files changed

+42
-42
lines changed

2 files changed

+42
-42
lines changed

packages/databricks-vscode/resources/webview-ui/job.html

Lines changed: 41 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@
8383
padding: 8px;
8484
width: auto;
8585
flex: 1;
86-
overflow: scroll;
8786
margin: 0;
8887
border: none;
8988
display: none;
@@ -153,31 +152,33 @@
153152
sandbox="allow-same-origin allow-pointer-lock allow-scripts allow-downloads allow-forms"
154153
allow="cross-origin-isolated; clipboard-read; clipboard-write;"
155154
></iframe>
156-
<pre id="stdout"></pre>
157-
<div class="alert-error" id="error">
158-
<span class="error-icon">
159-
<svg
160-
width="1em"
161-
height="1em"
162-
viewBox="0 0 24 24"
163-
fill="none"
164-
xmlns="http://www.w3.org/2000/svg"
165-
aria-hidden="true"
166-
focusable="false"
167-
class=""
168-
>
169-
<path
170-
fill-rule="evenodd"
171-
clip-rule="evenodd"
172-
d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 11c-.55 0-1-.45-1-1V8c0-.55.45-1 1-1s1 .45 1 1v4c0 .55-.45 1-1 1zm-1 2v2h2v-2h-2z"
173-
fill="currentColor"
174-
></path>
175-
</svg>
176-
</span>
177-
<div>
178-
<b id="error-description"></b>
179-
<div id="error-stack"></div>
155+
<div style="overflow: scroll">
156+
<div class="alert-error" id="error">
157+
<span class="error-icon">
158+
<svg
159+
width="1em"
160+
height="1em"
161+
viewBox="0 0 24 24"
162+
fill="none"
163+
xmlns="http://www.w3.org/2000/svg"
164+
aria-hidden="true"
165+
focusable="false"
166+
class=""
167+
>
168+
<path
169+
fill-rule="evenodd"
170+
clip-rule="evenodd"
171+
d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 11c-.55 0-1-.45-1-1V8c0-.55.45-1 1-1s1 .45 1 1v4c0 .55-.45 1-1 1zm-1 2v2h2v-2h-2z"
172+
fill="currentColor"
173+
></path>
174+
</svg>
175+
</span>
176+
<div>
177+
<b id="error-description"></b>
178+
<div id="error-stack"></div>
179+
</div>
180180
</div>
181+
<pre id="stdout"></pre>
181182
</div>
182183
</div>
183184
<div class="details">
@@ -259,8 +260,6 @@
259260
setOutputHtml(html) {
260261
var cl = document.getElementById("output").classList;
261262
cl.remove("spinner");
262-
cl.remove("stdout");
263-
cl.remove("error");
264263
cl.add("html");
265264

266265
const frameEl = document.getElementById("frame");
@@ -331,8 +330,6 @@
331330
setStdout(stdout) {
332331
var cl = document.getElementById("output").classList;
333332
cl.remove("spinner");
334-
cl.remove("html");
335-
cl.remove("error");
336333
cl.add("stdout");
337334

338335
document.getElementById("stdout").innerText = stdout;
@@ -341,8 +338,6 @@
341338
setError(message, stack) {
342339
var cl = document.getElementById("output").classList;
343340
cl.remove("spinner");
344-
cl.remove("html");
345-
cl.remove("stdout");
346341
cl.add("error");
347342

348343
document.getElementById("error-description").innerText =
@@ -400,27 +395,31 @@
400395
page.setError(
401396
`SyntaxError: invalid syntax (hello.py, line 10)`,
402397
`SyntaxError: invalid syntax (hello.py, line 9)
403-
Traceback <span style="color:#0AA">(most recent call last)</span>:
398+
Traceback <span style="color:#0AA">(most recent call last)</span>:
404399
405-
File <b><span style="color:#0A0">"/databricks/python/lib/python3.9/site-packages/IPython/core/interactiveshell.py"</span></b>, line <b><span style="color:#0A0">3524</span></b>, in <b><span style="color:#A0A">run_code</span></b>
406-
exec(code_obj, self.user_global_ns, self.user_ns)
400+
File <b><span style="color:#0A0">"/databricks/python/lib/python3.9/site-packages/IPython/core/interactiveshell.py"</span></b>, line <b><span style="color:#0A0">3524</span></b>, in <b><span style="color:#A0A">run_code</span></b>
401+
exec(code_obj, self.user_global_ns, self.user_ns)
407402
408-
<span style="color:#0AA"> File </span><span style="color:#0A0">"<command--1>"</span><span style="color:#0AA">, line </span><span style="color:#0A0">8</span><span style="color:#0AA">, in </span><span style="color:#A0A"><cell line: 7></span><span style="color:#0AA"></span>
409-
<span style="color:#A00"> exec(compile(f.read(), filename, 'exec'))</span>
403+
<span style="color:#0AA"> File </span><span style="color:#0A0">"<command--1>"</span><span style="color:#0AA">, line </span><span style="color:#0A0">8</span><span style="color:#0AA">, in </span><span style="color:#A0A"><cell line: 7></span><span style="color:#0AA"></span>
404+
<span style="color:#A00"> exec(compile(f.read(), filename, 'exec'))</span>
410405
411-
<span style="color:#0AA"> File </span><span style="color:#0A0">"/Workspace/Repos/fabian.jakobs@databricks.com/ide-best-practices/jobs/hello.py"</span><span style="color:#0AA">, line </span><span style="color:#0A0">9</span>
412-
<span style="color:#A00"> pr int("Hi Deco")</span>
413-
^
414-
<span style="color:#A00">SyntaxError</span><span style="color:#A00">:</span> invalid syntax`
406+
<span style="color:#0AA"> File </span><span style="color:#0A0">"/Workspace/Repos/fabian.jakobs@databricks.com/ide-best-practices/jobs/hello.py"</span><span style="color:#0AA">, line </span><span style="color:#0A0">9</span>
407+
<span style="color:#A00"> pr int("Hi Deco")</span>
408+
^
409+
<span style="color:#A00">SyntaxError</span><span style="color:#A00">:</span> invalid syntax`
415410
);
416-
stop();
411+
412+
let stdout = "";
413+
for (let i = 0; i < 100; i++) {
414+
stdout += `Hello World ${i}\n`;
415+
}
416+
page.setStdout(stdout);
417417
}, 3000);
418418

419419
setTimeout(() => {
420420
page.setOutputHtml(
421421
`<html><body><h1>Hello World</h1><p>This is a test</p></body></html>`
422422
);
423-
stop();
424423
}, 5000);
425424
}
426425
</script>

packages/databricks-vscode/src/run/WorkflowRunner.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ export class WorkflowRunner implements Disposable {
139139
? new Convert().toHtml(e.response.error_trace)
140140
: undefined,
141141
});
142+
panel.showStdoutResult(e.response.logs || "");
142143
} else {
143144
panel.showError({
144145
message: (e as any).message,

0 commit comments

Comments
 (0)