Skip to content
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

Flatten table on sort #4685

Merged
merged 14 commits into from
Sep 29, 2023
Merged

Flatten table on sort #4685

merged 14 commits into from
Sep 29, 2023

Conversation

julieg18
Copy link
Contributor

@julieg18 julieg18 commented Sep 18, 2023

1/2 main <= this <= #4691

Demo

Screen.Recording.2023-09-19.at.10.50.32.AM.mov

To Do

Fixes #4620

@julieg18 julieg18 added the product PR that affects product label Sep 18, 2023
@julieg18 julieg18 self-assigned this Sep 18, 2023
@julieg18 julieg18 mentioned this pull request Sep 19, 2023
import { Experiment } from 'dvc/src/experiments/webview/contract'
import { TableBody } from './TableBody'

interface SortedTableContentProps {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar blocks of code found in 2 locations. Consider refactoring.

@@ -0,0 +1,348 @@
import { join } from '../../../util/path'
Copy link
Contributor Author

@julieg18 julieg18 Sep 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

The large numbers are mainly due to:

  • adding a new code fixture for Storybook (fixtures/expShow/sorted)
  • Moving the getRowModel mock function value outside of a describe block inside of TableContent.test.tsx

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably should have moved the storybook changes in a separate chain pr 😅

extension/src/experiments/model/index.ts Show resolved Hide resolved
import { TableData } from '../../../../experiments/webview/contract'

const data: TableData = {
...defaultData,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorted/tableData is a slightly simplified (no deps and no selected exps) version of base/tableData. We could simplify further though if preferred.

@@ -61,10 +62,7 @@ const tableData = getTableState({
selectedBranches: [],
selectedForPlotsCount: 2,
showOnlyChanged: false,
sorts: [
Copy link
Contributor Author

@julieg18 julieg18 Sep 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorts used to be a default addition to the storybooks but since tableData rows are different when there are sorted, I removed the default sorts array (sorts are still shown in our new sorted fixture and in the deeplyNested fixture).

@julieg18 julieg18 marked this pull request as ready for review September 26, 2023 14:37
@julieg18 julieg18 requested a review from sroy3 as a code owner September 26, 2023 14:37
this.applyFiltersToFlattenedCommits()
const rows = []

for (const { branch, sha } of this.rowOrder) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[C] Once the table is flattened we could have duplicate entries right next to each other. We will need a way to collapse these rows:

image

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only thing that will differ between records will be the branch/tags. I think we should consider concatenating the information on multiple lines into a single cell.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense! I will open a followup issue.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be fixed before moving on.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be fixed before moving on.

Oh, ok! Apologies, I misunderstood your comment.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in #4735

Copy link
Member

@mattseddon mattseddon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good work.

One item for follow up.

webview/src/test/mockRowModel.ts Show resolved Hide resolved
webview/src/test/mockRowModel.ts Show resolved Hide resolved
webview/src/test/mockRowModel.ts Show resolved Hide resolved
webview/src/test/mockRowModel.ts Show resolved Hide resolved
webview/src/test/mockRowModel.ts Show resolved Hide resolved
@julieg18
Copy link
Contributor Author

@tapadipti, @dberenbaum we might want to consider flattening the table for sorting in Studio:

Screen.Recording.2023-09-26.at.12.12.39.PM.mov

@julieg18
Copy link
Contributor Author

@julieg18 Will vs code have different ways to sort or will this be the default and only way to sort the table?

Currently flattening the rows is the only way to sort the table, but that could change depending on user feedback.

@mattseddon
Copy link
Member

In the flattened table, some of the existing functionality may become a bit confusing. Eg, when a parent commit is hidden, all its exps get thidden. This will not be easy to visualize in a flat table.

The extension uses different filtering logic in that it will keep a parent commit in the table if any of its children are unfiltered. We do however change the filtering logic when the table is flat. Each record is filtered individually.

We recently included experiments in sorting, and atm it applies it hierarchically. That is, exps within a commit are sorted (similar to how it is in vs code before this pr?). We have a https://github.com/iterative/studio/issues/7639 to improve this, and we could include flattening the table as one of the options. But I think we should limit some functions in this mode.

That is also how the extension sorts experiments. All the user feedback that we have gotten is that this does not really help.

}
} = cell as unknown as CellContext<Experiment, CellValue>

if (!branch) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar blocks of code found in 2 locations. Consider refactoring.

)
}

return (
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar blocks of code found in 2 locations. Consider refactoring.

)
}

return (
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar blocks of code found in 2 locations. Consider refactoring.

minSize: 115,
size: 115
}),
columnHelper.accessor(() => COMMIT_COLUMN_ID, {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar blocks of code found in 2 locations. Consider refactoring.


if (flattenTable) {
columns.push(
columnHelper.accessor(() => BRANCH_COLUMN_ID, {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar blocks of code found in 2 locations. Consider refactoring.

Copy link
Contributor Author

@julieg18 julieg18 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, going to merge this! Last things left to do are:

I'll open a followup issue and start looking into the second task this sprint :)

@julieg18 julieg18 enabled auto-merge (squash) September 29, 2023 22:14
minSize: 230,
size: 240
})
const getDefaultColumns = (flattenTable: boolean) => {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function getDefaultColumns has 47 lines of code (exceeds 40 allowed). Consider refactoring.

@codeclimate
Copy link

codeclimate bot commented Sep 29, 2023

Code Climate has analyzed commit abf9707 and detected 11 issues on this pull request.

Here's the issue category breakdown:

Category Count
Complexity 1
Duplication 10

The test coverage on the diff in this pull request is 98.1% (85% is the threshold).

This pull request will bring the total coverage in the repository to 95.0% (0.0% change).

View more on Code Climate.

@julieg18 julieg18 merged commit 9e7ea16 into main Sep 29, 2023
3 checks passed
@julieg18 julieg18 deleted the flatten-table-on-sort branch September 29, 2023 22:34
@julieg18 julieg18 mentioned this pull request Oct 2, 2023
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
product PR that affects product
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Apply sorting to the entire table
2 participants