Skip to content

Commit e55ff83

Browse files
Kimahrimansarutak
authored andcommitted
[SPARK-35117][UI] Change progress bar back to highlight ratio of tasks in progress
### What changes were proposed in this pull request? Small UI update to add highlighting the number of tasks in progress in a stage/job instead of highlighting the whole in progress stage/job. This was the behavior pre Spark 3.1 and the bootstrap 4 upgrade. ### Why are the changes needed? To add back in functionality lost between 3.0 and 3.1. This provides a great visual queue of how much of a stage/job is currently being run. ### Does this PR introduce _any_ user-facing change? Small UI change. Before: ![image](https://user-images.githubusercontent.com/3536454/115216189-3fddaa00-a0d2-11eb-88e0-e3be925c92f0.png) After (and pre Spark 3.1): ![image](https://user-images.githubusercontent.com/3536454/115216216-48ce7b80-a0d2-11eb-9953-2adb3b377133.png) ### How was this patch tested? Updated existing UT. Closes apache#32214 from Kimahriman/progress-bar-started. Authored-by: Adam Binford <[email protected]> Signed-off-by: Kousuke Saruta <[email protected]>
1 parent 9a6d773 commit e55ff83

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

core/src/main/resources/org/apache/spark/ui/static/webui.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ table.sortable td {
113113
box-shadow: inset 1px 0 0 rgba(0,0,0,.15), inset 0 -1px 0 rgba(0,0,0,.15);
114114
}
115115

116-
.progress.progress-started {
116+
.progress .progress-bar.progress-started {
117117
background-color: #A0DFFF;
118118
background-image: -moz-linear-gradient(top, #A4EDFF, #94DDFF);
119119
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#A4EDFF), to(#94DDFF));
@@ -124,7 +124,7 @@ table.sortable td {
124124
filter: progid:dximagetransform.microsoft.gradient(startColorstr='#FFA4EDFF', endColorstr='#FF94DDFF', GradientType=0);
125125
}
126126

127-
.progress .progress-bar {
127+
.progress .progress-bar.progress-completed {
128128
background-color: #3EC0FF;
129129
background-image: -moz-linear-gradient(top, #44CBFF, #34B0EE);
130130
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#44CBFF), to(#34B0EE));

core/src/main/scala/org/apache/spark/ui/UIUtils.scala

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -461,13 +461,14 @@ private[spark] object UIUtils extends Logging {
461461
skipped: Int,
462462
reasonToNumKilled: Map[String, Int],
463463
total: Int): Seq[Node] = {
464-
val ratio = if (total == 0) 100.0 else (completed.toDouble/total)*100
464+
val ratio = if (total == 0) 100.0 else (completed.toDouble / total) * 100
465465
val completeWidth = "width: %s%%".format(ratio)
466466
// started + completed can be > total when there are speculative tasks
467467
val boundedStarted = math.min(started, total - completed)
468-
val startWidth = "width: %s%%".format((boundedStarted.toDouble/total)*100)
468+
val startRatio = if (total == 0) 0.0 else (boundedStarted.toDouble / total) * 100
469+
val startWidth = "width: %s%%".format(startRatio)
469470

470-
<div class={ if (started > 0) s"progress progress-started" else s"progress" }>
471+
<div class="progress">
471472
<span style="text-align:center; position:absolute; width:100%;">
472473
{completed}/{total}
473474
{ if (failed == 0 && skipped == 0 && started > 0) s"($started running)" }
@@ -478,7 +479,8 @@ private[spark] object UIUtils extends Logging {
478479
}
479480
}
480481
</span>
481-
<div class="progress-bar" style={completeWidth}></div>
482+
<div class="progress-bar progress-completed" style={completeWidth}></div>
483+
<div class="progress-bar progress-started" style={startWidth}></div>
482484
</div>
483485
}
484486

core/src/test/scala/org/apache/spark/ui/UIUtilsSuite.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,8 @@ class UIUtilsSuite extends SparkFunSuite {
113113
test("SPARK-11906: Progress bar should not overflow because of speculative tasks") {
114114
val generated = makeProgressBar(2, 3, 0, 0, Map.empty, 4).head.child.filter(_.label == "div")
115115
val expected = Seq(
116-
<div class="progress-bar" style="width: 75.0%"></div>
116+
<div class="progress-bar progress-completed" style="width: 75.0%"></div>,
117+
<div class="progress-bar progress-started" style="width: 25.0%"></div>
117118
)
118119
assert(generated.sameElements(expected),
119120
s"\nRunning progress bar should round down\n\nExpected:\n$expected\nGenerated:\n$generated")

0 commit comments

Comments
 (0)