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

Experiment table open to the side #1796

Merged
merged 9 commits into from
Jun 2, 2022
Merged

Conversation

wolmir
Copy link
Contributor

@wolmir wolmir commented May 30, 2022

This PR will add the option Open to the side to experiment table columns that represent parameters. This option will open the corresponding params file in a new side-by-side editor area.

Screen.Recording.2022-05-30.at.16.31.45.mov

@wolmir wolmir self-assigned this May 30, 2022
@wolmir wolmir force-pushed the exp-table-open-to-the-side branch 3 times, most recently from 9cfdfa9 to 337bbbb Compare May 30, 2022 19:22
@wolmir wolmir marked this pull request as ready for review May 30, 2022 19:30
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.

👍🏻

LGTM, just need to add an event for open openParamsFileToTheSide. The logic from that function could also be moved out to somewhere in the columns folder but that is just personal preference for me.

@@ -380,6 +382,13 @@ export class Experiments extends BaseRepository<TableData> {
)
}

private async openParamsFileToTheSide(path: string) {
const [, fileSegment] = splitColumnPath(path)
await window.showTextDocument(Uri.file(join(this.dvcRoot, fileSegment)), {
Copy link
Member

Choose a reason for hiding this comment

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

[I] Potentially we could rename and re-use RegisteredCommands.TRACKED_EXPLORER_OPEN_TO_THE_SIDE here. If not this should have its own analytics event.

Copy link
Member

Choose a reason for hiding this comment

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

Probably better to just give this its own event.

@@ -0,0 +1,3 @@
export function pushIf<T>(array: T[], condition: boolean, elements: T[]) {
Copy link
Member

Choose a reason for hiding this comment

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

[N] We only use function instead of const/arrow function if we have to.

}
}
]

Copy link
Member

Choose a reason for hiding this comment

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

[C] Would be good to get a divider between these two. Same for row context menus, we can follow up though.

@wolmir wolmir force-pushed the exp-table-open-to-the-side branch from 337bbbb to 2a8c56e Compare May 31, 2022 02:27
@sroy3
Copy link
Contributor

sroy3 commented May 31, 2022

I get the option to open to the side when I right click params.yml, but clicking it does not do anything (it also shows hide column and it does not do anything).

Out of scope, but I also noticed this while reviewing:
Screen Shot 2022-05-31 at 9 43 00 AM

@wolmir
Copy link
Contributor Author

wolmir commented May 31, 2022

I get the option to open to the side when I right click params.yml, but clicking it does not do anything (it also shows hide column and it does not do anything).

Out of scope, but I also noticed this while reviewing: Screen Shot 2022-05-31 at 9 43 00 AM

Thanks, I'll verify it now!

Copy link
Contributor

@rogermparent rogermparent left a comment

Choose a reason for hiding this comment

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

Looks good so far! I decided to manually test non-default param file names to ensure we won't run into issues in the future, and everything looks solid!

Scenarios I tried:

  • additional param file named otherparams.yaml
  • nested additional param file names nested/params.yaml
  • param file name with a space in it
  • removing the params key entirely from dvc.yaml and relying on default behavior

All of these scenarios work perfectly fine! We may want to add automated tests for these scenarios for future refactors, though.

Aside from that, I confirmed that what @sroy3 pointed out with params.yaml headers also happens on my machine, and think it should be fixed either in this PR or an immediate follow-up, preferably the former since the issue doesn't exist on main.

Comment on lines 394 to 414
it('should be able to handle a message to open the source params file from a column path', async () => {
const { experiments } = setupExperimentsAndMockCommands()

const mockShowTextDocument = stub(window, 'showTextDocument')
const webview = await experiments.showWebview()
const mockMessageReceived = getMessageReceivedEmitter(webview)
const mockColumnId = 'params:params.yaml:lr'

mockMessageReceived.fire({
payload: mockColumnId,
type: MessageFromWebviewType.OPEN_PARAMS_FILE_TO_THE_SIDE
})

expect(mockShowTextDocument).to.be.calledOnce
expect(mockShowTextDocument).to.be.calledWithExactly(
Uri.file(join(dvcDemoPath, 'params.yaml')),
{
viewColumn: ViewColumn.Beside
}
)
})
Copy link
Contributor

Choose a reason for hiding this comment

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

Could be good to test non-default params file names, just in case we refactor in the future.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks! I already changed this test to use paths with appended numbers like React table does so I can simulate this issue you guys found.
I will also add a test for non-default files now because it's easy to do.

@wolmir
Copy link
Contributor Author

wolmir commented May 31, 2022

@mattseddon @rogermparent @sroy3
While I was fixing the issue that @sroy3 found I encountered this use case:
Screen Shot 2022-05-31 at 16 52 12

To clarify:
I reordered the columns by splitting the params.yaml group and then opened the context-menu.
What should happen when I select the Hide column option?

  1. Hide the entire params.yaml group (same as in the columns tree view)
  2. Hide only the columns in that subgroup of the table

@wolmir wolmir force-pushed the exp-table-open-to-the-side branch from cc9c6bb to f45831d Compare May 31, 2022 20:06
@mattseddon
Copy link
Member

mattseddon commented Jun 1, 2022

@mattseddon @rogermparent @sroy3 While I was fixing the issue that @sroy3 found I encountered this use case: Screen Shot 2022-05-31 at 16 52 12

To clarify: I reordered the columns by splitting the params.yaml group and then opened the context-menu. What should happen when I select the Hide column option?

  1. Hide the entire params.yaml group (same as in the columns tree view)
  2. Hide only the columns in that subgroup of the table

I would say definitely option 2 as it would be the least unexpecting thing to do. I would suggest that we limit "Hide Column" to leaves only as the first step.

@wolmir wolmir force-pushed the exp-table-open-to-the-side branch from f45831d to e0e6ad8 Compare June 1, 2022 14:56
@mattseddon mattseddon added the product PR that affects product label Jun 2, 2022
@mattseddon mattseddon enabled auto-merge (squash) June 2, 2022 01:05
@mattseddon mattseddon changed the title Exp table open to the side Experiment table open to the side Jun 2, 2022
@mattseddon mattseddon requested review from maxagin and shcheklein June 2, 2022 01:07
@mattseddon mattseddon disabled auto-merge June 2, 2022 01:07
@codeclimate
Copy link

codeclimate bot commented Jun 2, 2022

Code Climate has analyzed commit a58ed20 and detected 0 issues on this pull request.

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

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

View more on Code Climate.

@mattseddon mattseddon merged commit 1d572b5 into main Jun 2, 2022
@mattseddon mattseddon deleted the exp-table-open-to-the-side branch June 2, 2022 01:21
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.

4 participants