Skip to content

Commit b436f5b

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 #32214 from Kimahriman/progress-bar-started. Authored-by: Adam Binford <[email protected]> Signed-off-by: Kousuke Saruta <[email protected]> (cherry picked from commit e55ff83) Signed-off-by: Kousuke Saruta <[email protected]>
1 parent a2b5fb3 commit b436f5b

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
@@ -460,13 +460,14 @@ private[spark] object UIUtils extends Logging {
460460
skipped: Int,
461461
reasonToNumKilled: Map[String, Int],
462462
total: Int): Seq[Node] = {
463-
val ratio = if (total == 0) 100.0 else (completed.toDouble/total)*100
463+
val ratio = if (total == 0) 100.0 else (completed.toDouble / total) * 100
464464
val completeWidth = "width: %s%%".format(ratio)
465465
// started + completed can be > total when there are speculative tasks
466466
val boundedStarted = math.min(started, total - completed)
467-
val startWidth = "width: %s%%".format((boundedStarted.toDouble/total)*100)
467+
val startRatio = if (total == 0) 0.0 else (boundedStarted.toDouble / total) * 100
468+
val startWidth = "width: %s%%".format(startRatio)
468469

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

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)