-
Notifications
You must be signed in to change notification settings - Fork 28.9k
[SPARK-4070] [WIP] Add WebUITableBuilder to simplify table-building code #2852
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This significantly simplifies / abstracts the web UI's table construction code, which seems to account for the majority of the UI code. I haven't converted all tables to use this yet; this commit just provides the basic framework and a few example usages in the master web UI.
|
QA tests have started for PR 2852 at commit
|
|
QA tests have finished for PR 2852 at commit
|
|
Test FAILed. |
|
QA tests have started for PR 2852 at commit
|
|
QA tests have finished for PR 2852 at commit
|
|
Test FAILed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
super nit: import ordering
|
This looks awesome! Will it be hard to add classes to rows / columns (as is needed in #2867, for example) with this? That's one thing that was pretty cumbersome with the current code, and I'm wondering if this will make things like that harder or easier. |
|
@kayousterhout In general, I think that this should simplify special formatting rules for rows / columns by allowing us to centralize that logic in a single place. I could easily add hooks to let you apply custom per-row formatting rules based on user-defined conditions, such as highlighting "bad" rows in red. I'm going to push some examples of this in a little bit. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
an extra star?
|
Looks pretty cool overall. I made some comments, mostly around clarity of the code. |
Make build() into a paren method.
- memCol -> sizeCol - 4 spaces for parameter indentation - move `case` statements
|
QA tests have started for PR 2852 at commit
|
|
QA tests have finished for PR 2852 at commit
|
|
Test FAILed. |
This removes the messy "custom col" stuff and allows for a somewhat more "declarative"-looking style when customizing markup rendering, sorting, etc.
|
My latest commit cleans up the messy private val workerTable: UITable[WorkerInfo] = {
val t = new UITableBuilder[WorkerInfo]()
t.col("ID") (identity) withMarkup { worker =>
<a href={worker.webUiAddress}>{worker.id}</a>
}
t.col("Address") { worker => s"${worker.host}:${worker.port}"}
t.col("State") { _.state.toString }
t.col("Cores") { _.coresUsed } formatWith { c: Int => s"$c Used" }
t.col("Memory") (identity) sortBy { worker =>
s"${worker.memory}:${worker.memoryUsed}"
} withMarkup { worker =>
Text(Utils.megabytesToString(worker.memory)) ++
Text(Utils.megabytesToString(worker.memoryUsed))
}
t.build()
}I know that a lot of folks dislike the infix syntax; I'm a fan of it here for these |
|
Oh, and to be clear, the full grammar is something like t.col(column name)(function for extracting field) withSort (function for transforming extracted field into a sort key) formatWith (function for transforming extracted field for display in table cell) [isSortable()] I'll add a comment to clarify this. There's only one table left to go (the main stages table), plus some testing, then I think this should be good to merge. |
|
QA tests have started for PR 2852 at commit
|
|
QA tests have finished for PR 2852 at commit
|
|
Test PASSed. |
|
Going to close this for now. I've looked into it some more and there are a few corner-cases in the job info page that this doesn't handle super-cleanly. Since this is a kind of leaky abstraction, it might be more confusing than what we have now; we can revisit this later. |
This work-in-progress commit illustrates a weekend hack project that I came up with for significantly simplifying the web UI's table rendering code. See the huge block comment in
WebUITableBuilderfor more details. This isn't ready to merge yet; I wanted to get some feedback before converting the rest of the table construction code to use this (I know that I should open a JIRA for this, too; I'll do it tomorrow).Essentially, this commit adds a small builder class for constructing objects that know how to render web UI tables. This builder helps us to avoid several sources of errors / maintenance headaches, such as duplicate/boilerplate markup, inconsistent formatting of columns in different tables (e.g. durations or memory being displayed differently), separation of column names from column data values, etc. This is best illustrated by some sample code; this new framework lets you write
to render the "applications" table in the standalone Master UI. I find this significantly easier to understand and maintain than the old code. For example, this makes it trivial to re-order columns.
TODO: