Skip to content

Commit

Permalink
[SPARK-35117][UI] Change progress bar back to highlight ratio of task…
Browse files Browse the repository at this point in the history
…s 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]>
  • Loading branch information
Kimahriman authored and sarutak committed Apr 20, 2021
1 parent a2b5fb3 commit b436f5b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 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
10 changes: 6 additions & 4 deletions core/src/main/scala/org/apache/spark/ui/UIUtils.scala
Original file line number Diff line number Diff line change
Expand Up @@ -460,13 +460,14 @@ private[spark] object UIUtils extends Logging {
skipped: Int,
reasonToNumKilled: Map[String, Int],
total: Int): Seq[Node] = {
val ratio = if (total == 0) 100.0 else (completed.toDouble/total)*100
val ratio = if (total == 0) 100.0 else (completed.toDouble / total) * 100
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 b436f5b

Please sign in to comment.