-
Notifications
You must be signed in to change notification settings - Fork 382
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
jarek/7470: handle failure in spark getOrCreate method (#7484)
* #7470: handle errors * #7470: SparkUI refactoring * #7470: adjust spinner * #7470: display error at the bottom of the form + add tooltip to spinner * #7470: move error next to start button
- Loading branch information
1 parent
6e49864
commit c277e4a
Showing
20 changed files
with
693 additions
and
224 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
const widgets = require('./widgets'); | ||
|
||
class SpinnerModel extends widgets.DOMWidgetModel { | ||
defaults() { | ||
return { | ||
...super.defaults(), | ||
_view_name: "SpinnerView", | ||
_model_name: "SpinnerModel", | ||
_model_module: 'beakerx', | ||
_view_module: 'beakerx', | ||
_model_module_version: BEAKERX_MODULE_VERSION, | ||
_view_module_version: BEAKERX_MODULE_VERSION | ||
}; | ||
} | ||
} | ||
|
||
class SpinnerView extends widgets.DOMWidgetView { | ||
public render() { | ||
let title = this.model.get('title'); | ||
|
||
this.el.innerHTML = `<div title="${title}" class="lds-css ng-scope">\n` + | ||
'<div class="lds-spinner" style="100%;height:100%"><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div></div>\n' + | ||
'<style type="text/css">@keyframes lds-spinner {\n' + | ||
' 0% {\n' + | ||
' opacity: 1;\n' + | ||
' }\n' + | ||
' 100% {\n' + | ||
' opacity: 0;\n' + | ||
' }\n' + | ||
'}\n' + | ||
'@-webkit-keyframes lds-spinner {\n' + | ||
' 0% {\n' + | ||
' opacity: 1;\n' + | ||
' }\n' + | ||
' 100% {\n' + | ||
' opacity: 0;\n' + | ||
' }\n' + | ||
'}\n' + | ||
'.lds-spinner {\n' + | ||
' position: relative;\n' + | ||
'}\n' + | ||
'.lds-spinner div {\n' + | ||
' left: 94px;\n' + | ||
' top: 48px;\n' + | ||
' position: absolute;\n' + | ||
' -webkit-animation: lds-spinner linear 1s infinite;\n' + | ||
' animation: lds-spinner linear 1s infinite;\n' + | ||
' background: #0055a5;\n' + | ||
' width: 12px;\n' + | ||
' height: 24px;\n' + | ||
' border-radius: 40%;\n' + | ||
' -webkit-transform-origin: 6px 52px;\n' + | ||
' transform-origin: 6px 52px;\n' + | ||
'}\n' + | ||
'.lds-spinner div:nth-child(1) {\n' + | ||
' -webkit-transform: rotate(0deg);\n' + | ||
' transform: rotate(0deg);\n' + | ||
' -webkit-animation-delay: -0.916666666666667s;\n' + | ||
' animation-delay: -0.916666666666667s;\n' + | ||
'}\n' + | ||
'.lds-spinner div:nth-child(2) {\n' + | ||
' -webkit-transform: rotate(30deg);\n' + | ||
' transform: rotate(30deg);\n' + | ||
' -webkit-animation-delay: -0.833333333333333s;\n' + | ||
' animation-delay: -0.833333333333333s;\n' + | ||
'}\n' + | ||
'.lds-spinner div:nth-child(3) {\n' + | ||
' -webkit-transform: rotate(60deg);\n' + | ||
' transform: rotate(60deg);\n' + | ||
' -webkit-animation-delay: -0.75s;\n' + | ||
' animation-delay: -0.75s;\n' + | ||
'}\n' + | ||
'.lds-spinner div:nth-child(4) {\n' + | ||
' -webkit-transform: rotate(90deg);\n' + | ||
' transform: rotate(90deg);\n' + | ||
' -webkit-animation-delay: -0.666666666666667s;\n' + | ||
' animation-delay: -0.666666666666667s;\n' + | ||
'}\n' + | ||
'.lds-spinner div:nth-child(5) {\n' + | ||
' -webkit-transform: rotate(120deg);\n' + | ||
' transform: rotate(120deg);\n' + | ||
' -webkit-animation-delay: -0.583333333333333s;\n' + | ||
' animation-delay: -0.583333333333333s;\n' + | ||
'}\n' + | ||
'.lds-spinner div:nth-child(6) {\n' + | ||
' -webkit-transform: rotate(150deg);\n' + | ||
' transform: rotate(150deg);\n' + | ||
' -webkit-animation-delay: -0.5s;\n' + | ||
' animation-delay: -0.5s;\n' + | ||
'}\n' + | ||
'.lds-spinner div:nth-child(7) {\n' + | ||
' -webkit-transform: rotate(180deg);\n' + | ||
' transform: rotate(180deg);\n' + | ||
' -webkit-animation-delay: -0.416666666666667s;\n' + | ||
' animation-delay: -0.416666666666667s;\n' + | ||
'}\n' + | ||
'.lds-spinner div:nth-child(8) {\n' + | ||
' -webkit-transform: rotate(210deg);\n' + | ||
' transform: rotate(210deg);\n' + | ||
' -webkit-animation-delay: -0.333333333333333s;\n' + | ||
' animation-delay: -0.333333333333333s;\n' + | ||
'}\n' + | ||
'.lds-spinner div:nth-child(9) {\n' + | ||
' -webkit-transform: rotate(240deg);\n' + | ||
' transform: rotate(240deg);\n' + | ||
' -webkit-animation-delay: -0.25s;\n' + | ||
' animation-delay: -0.25s;\n' + | ||
'}\n' + | ||
'.lds-spinner div:nth-child(10) {\n' + | ||
' -webkit-transform: rotate(270deg);\n' + | ||
' transform: rotate(270deg);\n' + | ||
' -webkit-animation-delay: -0.166666666666667s;\n' + | ||
' animation-delay: -0.166666666666667s;\n' + | ||
'}\n' + | ||
'.lds-spinner div:nth-child(11) {\n' + | ||
' -webkit-transform: rotate(300deg);\n' + | ||
' transform: rotate(300deg);\n' + | ||
' -webkit-animation-delay: -0.083333333333333s;\n' + | ||
' animation-delay: -0.083333333333333s;\n' + | ||
'}\n' + | ||
'.lds-spinner div:nth-child(12) {\n' + | ||
' -webkit-transform: rotate(330deg);\n' + | ||
' transform: rotate(330deg);\n' + | ||
' -webkit-animation-delay: 0s;\n' + | ||
' animation-delay: 0s;\n' + | ||
'}\n' + | ||
'.lds-spinner {\n' + | ||
' width: 30px !important;\n' + | ||
' height: 30px !important;\n' + | ||
' -webkit-transform: translate(-15px, -15px) scale(0.15) translate(15px, 15px);\n' + | ||
' transform: translate(-15px, -15px) scale(0.15) translate(15px, 15px);\n' + | ||
'}\n' + | ||
'</style></div>' | ||
} | ||
} | ||
|
||
export default { | ||
SpinnerModel, | ||
SpinnerView | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -198,4 +198,8 @@ | |
.bx-config-name input { | ||
text-align: right; | ||
} | ||
|
||
.bx-spark-connect-error { | ||
margin-left: 20px; | ||
} | ||
} |
60 changes: 60 additions & 0 deletions
60
kernel/base/src/main/java/com/twosigma/beakerx/kernel/msg/StacktraceHtmlPrinter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
* Copyright 2018 TWO SIGMA OPEN SOURCE, LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.twosigma.beakerx.kernel.msg; | ||
|
||
import org.apache.commons.text.StringEscapeUtils; | ||
|
||
import java.util.Arrays; | ||
|
||
public class StacktraceHtmlPrinter extends StacktracePrinter { | ||
|
||
private static final String FONT = "font-size: 14px;font-family: 'Roboto Mono', monospace, sans-serif; color: #B22B31;"; | ||
private static String END = "</div>"; | ||
|
||
private static final StacktracePrinter INSTANCE = new StacktraceHtmlPrinter(); | ||
|
||
public static String[] print(String[] input) { | ||
String[] escaped = Arrays.stream(input).map(StringEscapeUtils::escapeHtml4).toArray(String[]::new); | ||
return INSTANCE.doPrint(escaped); | ||
} | ||
|
||
public static String printRedBold(String input) { | ||
String escaped = StringEscapeUtils.escapeHtml4(input); | ||
return INSTANCE.startRedBold() + escaped + INSTANCE.endRedBold(); | ||
} | ||
|
||
@Override | ||
public String startRedBold() { | ||
return "<div style=\"font-weight: bold; " + FONT + "\">"; | ||
} | ||
|
||
@Override | ||
public String endRedBold() { | ||
return END; | ||
} | ||
|
||
@Override | ||
public String startRed() { | ||
return "<div style=\"" + FONT + "\">"; | ||
} | ||
|
||
@Override | ||
public String endRed() { | ||
return END; | ||
} | ||
|
||
|
||
} |
56 changes: 56 additions & 0 deletions
56
kernel/base/src/main/java/com/twosigma/beakerx/kernel/msg/StacktracePrinter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* Copyright 2018 TWO SIGMA OPEN SOURCE, LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.twosigma.beakerx.kernel.msg; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public abstract class StacktracePrinter { | ||
|
||
private static final String COM_TWOSIGMA_BEAKER = "com.twosigma.beaker"; | ||
|
||
protected String[] doPrint(String[] input) { | ||
if (input == null) { | ||
return new String[0]; | ||
} | ||
return mark(input); | ||
} | ||
|
||
private String[] mark(String[] input) { | ||
boolean shouldBeBold = true; | ||
List<String> ret = new ArrayList<>(); | ||
for (String line : input) { | ||
if (line != null) { | ||
if (!line.contains(COM_TWOSIGMA_BEAKER) && shouldBeBold) { | ||
ret.add(startRedBold() + line + endRedBold()); | ||
} else { | ||
shouldBeBold = false; | ||
ret.add(startRed() + line + endRed()); | ||
} | ||
} | ||
} | ||
return ret.toArray(new String[0]); | ||
} | ||
|
||
public abstract String startRedBold(); | ||
public abstract String endRedBold(); | ||
|
||
public abstract String startRed(); | ||
|
||
public abstract String endRed(); | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.