Skip to content

Commit

Permalink
Change progress bar back to highlight ratio of tasks in progress
Browse files Browse the repository at this point in the history
  • Loading branch information
Kimahriman committed Apr 17, 2021
1 parent 2e1e1f8 commit 5d68544
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
4 changes: 2 additions & 2 deletions core/src/main/resources/org/apache/spark/ui/static/webui.css
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ table.sortable td {
box-shadow: inset 1px 0 0 rgba(0,0,0,.15), inset 0 -1px 0 rgba(0,0,0,.15);
}

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

.progress .progress-bar {
.progress .progress-bar.progress-completed {
background-color: #3EC0FF;
background-image: -moz-linear-gradient(top, #44CBFF, #34B0EE);
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#44CBFF), to(#34B0EE));
Expand Down
8 changes: 5 additions & 3 deletions core/src/main/scala/org/apache/spark/ui/UIUtils.scala
Original file line number Diff line number Diff line change
Expand Up @@ -464,9 +464,10 @@ private[spark] object UIUtils extends Logging {
val completeWidth = "width: %s%%".format(ratio)
// started + completed can be > total when there are speculative tasks
val boundedStarted = math.min(started, total - completed)
val startWidth = "width: %s%%".format((boundedStarted.toDouble/total)*100)
val startRatio = if (total == 0) 0.0 else (boundedStarted.toDouble/total)*100
val startWidth = "width: %s%%".format(startRatio)

<div class={ if (started > 0) s"progress progress-started" else s"progress" }>
<div class="progress">
<span style="text-align:center; position:absolute; width:100%;">
{completed}/{total}
{ if (failed == 0 && skipped == 0 && started > 0) s"($started running)" }
Expand All @@ -477,7 +478,8 @@ private[spark] object UIUtils extends Logging {
}
}
</span>
<div class="progress-bar" style={completeWidth}></div>
<div class="progress-bar progress-completed" style={completeWidth}></div>
<div class="progress-bar progress-started" style={startWidth}></div>
</div>
}

Expand Down
3 changes: 2 additions & 1 deletion core/src/test/scala/org/apache/spark/ui/UIUtilsSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ class UIUtilsSuite extends SparkFunSuite {
test("SPARK-11906: Progress bar should not overflow because of speculative tasks") {
val generated = makeProgressBar(2, 3, 0, 0, Map.empty, 4).head.child.filter(_.label == "div")
val expected = Seq(
<div class="progress-bar" style="width: 75.0%"></div>
<div class="progress-bar progress-completed" style="width: 75.0%"></div>,
<div class="progress-bar progress-started" style="width: 25.0%"></div>
)
assert(generated.sameElements(expected),
s"\nRunning progress bar should round down\n\nExpected:\n$expected\nGenerated:\n$generated")
Expand Down

0 comments on commit 5d68544

Please sign in to comment.