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

Add Custom Plots Section #3342

Merged
merged 29 commits into from
Mar 1, 2023
Merged

Add Custom Plots Section #3342

merged 29 commits into from
Mar 1, 2023

Conversation

julieg18
Copy link
Contributor

@julieg18 julieg18 commented Feb 23, 2023

  • adds a new section to plots called "Custom" that allows the user to add plots to compare a chosen metric and param.

Demo

https://user-images.githubusercontent.com/43496356/221732462-d4ad0eec-9cb7-4e5e-95fb-96268be7ec79.mov

Screen.Recording.2023-02-28.at.3.18.46.PM.mov

Fixes #2139

@julieg18 julieg18 added the product PR that affects product label Feb 23, 2023
@julieg18 julieg18 self-assigned this Feb 23, 2023
} from 'dvc/src/plots/webview/contract'
import { addPlotsWithSnapshots, removePlots } from '../plotDataStore'

export interface CustomPlotsState extends Omit<CustomPlotsData, 'plots'> {
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.

extension/src/plots/model/quickPick.ts Outdated Show resolved Hide resolved
size: DEFAULT_SECTION_SIZES[Section.CUSTOM_PLOTS]
}

export const customPlotsSlice = createSlice({
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 items.length > 0 ? (
<div
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.

dispatch(changeDisabledDragIds(enabled ? [] : [id]))
}

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right now, the CustomPlots and CheckpointPlot components are very similar. I figured we could lower code duplication in a followup when I move the trends plots inside of Custom.

Copy link
Member

Choose a reason for hiding this comment

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

Remember to update the docs/walkthrough when you do that:

image

@@ -350,7 +352,10 @@ describe('App', () => {
expect(screen.getByText('Trends')).toBeInTheDocument()
expect(screen.getByText('Data Series')).toBeInTheDocument()
expect(screen.getByText('Images')).toBeInTheDocument()
expect(screen.getByText('No Plots to Display')).toBeInTheDocument()
expect(screen.getByText('Custom')).toBeInTheDocument()
const noPlotsToDisplayElements = screen.getAllByText('No Plots to Display')
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since we now have three sections that show the "No plots to Display" text, I had to update the tests accordingly. Is there a better way to check for the array elements being in the document?

Copy link
Member

Choose a reason for hiding this comment

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

expect the result to have length 2?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

expect the result to have length 2?

Now that I look at the documentation, I see that we don't need to do the actual check for toBeInTheDocument. Length would indeed be enough, thanks!

Copy link
Contributor

Choose a reason for hiding this comment

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

We'd probably still need to map them to their respective section though. Something like within(screen.getByTestId('custom-section')).getByText('No Plots to Display').

})
}

if (removePlotsButton) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

For now, I've placed the custom plot actions in menu items but these are rather small and possibly could be missed 🤔 Is there some better options to place these actions?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's good for the "add" button. For the "remove" one, I feel like it would be better if it were associated to the plot itself. We do not have anything for this yet, though. We can keep this as is for now until we find something to add actions to a plot.

webview/src/plots/components/PlotsContainer.tsx Outdated Show resolved Hide resolved
dispatch(changeDisabledDragIds(enabled ? [] : [id]))
}

return (
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right now, the CustomPlots and CheckpointPlot components are very similar. I figured we could lower code duplication in a followup when I move the trends plots inside of Custom.

webview/src/plots/store.ts Show resolved Hide resolved
webview/src/plots/components/App.test.tsx Show resolved Hide resolved
@julieg18 julieg18 marked this pull request as ready for review February 28, 2023 02:09
@julieg18 julieg18 requested a review from shcheklein February 28, 2023 02:09
@shcheklein
Copy link
Member

Thanks @julieg18 ! Looks like a great progress.

Q: to double check. On the plot It seems not all experiments are present (I see 3 dots while there are 4 experiments in the side panel). Is it expected?

)

if (plotAlreadyExists) {
return Toast.showError('Custom plot already exists.')
Copy link
Member

Choose a reason for hiding this comment

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

[I] Ideally this class is responsible for data/data manipulation. Plots should use Toast and inform the user when there is a problem.

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we could remove the choice from the list instead of letting them select something that already exists.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe we could remove the choice from the list instead of letting them select something that already exists.

Definitely doable by looping over the custom plots and checking for what exists already!

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.

I did a first pass. Please take a look at the bug here.

After removing trends/de-duplicating and cleaning all of the code we will need to think about the UX of this feature. To me, this emphasises the fragmented nature of experiments + plots. E.g to use I would need to do this:

Screen.Recording.2023-02-28.at.2.03.33.pm.mov

There might not be much that we can do but we should at least consider how we can add something into the experiments table to shortcut the process.

@julieg18
Copy link
Contributor Author

Q: to double check. On the plot It seems not all experiments are present (I see 3 dots while there are 4 experiments in the side panel). Is it expected?

Yes, it's expected. Two experiments have the exact same params/metrics so they overlap each other, causing the plot to show only three dots.

Copy link
Contributor

@sroy3 sroy3 left a comment

Choose a reason for hiding this comment

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

Screen.Recording.2023-02-28.at.10.10.12.AM.mov

The order is not persisted like other sections

)

if (plotAlreadyExists) {
return Toast.showError('Custom plot already exists.')
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we could remove the choice from the list instead of letting them select something that already exists.

extension/src/plots/webview/messages.ts Outdated Show resolved Hide resolved
webview/src/plots/components/App.test.tsx Show resolved Hide resolved
@@ -350,7 +352,10 @@ describe('App', () => {
expect(screen.getByText('Trends')).toBeInTheDocument()
expect(screen.getByText('Data Series')).toBeInTheDocument()
expect(screen.getByText('Images')).toBeInTheDocument()
expect(screen.getByText('No Plots to Display')).toBeInTheDocument()
expect(screen.getByText('Custom')).toBeInTheDocument()
const noPlotsToDisplayElements = screen.getAllByText('No Plots to Display')
Copy link
Contributor

Choose a reason for hiding this comment

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

We'd probably still need to map them to their respective section though. Something like within(screen.getByTestId('custom-section')).getByText('No Plots to Display').

})
}

if (removePlotsButton) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's good for the "add" button. For the "remove" one, I feel like it would be better if it were associated to the plot itself. We do not have anything for this yet, though. We can keep this as is for now until we find something to add actions to a plot.

webview/src/plots/components/PlotsContainer.tsx Outdated Show resolved Hide resolved
@julieg18
Copy link
Contributor Author

The order is not persisted like other sections

Forgot to add the logic for reordering 😅. Thanks for spotting that! Added

setPlotsIdsOrder(changeOrderWithDraggedInfo(order, draggedRef))
}

return items.length > 0 ? (
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.

setOrder(pastOrder => performSimpleOrderedUpdate(pastOrder, plotsIds))
}, [plotsIds])

const setPlotsIdsOrder = (order: string[]): void => {
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.

@dberenbaum
Copy link
Contributor

Not sure what to call this kind of plot. When I see Custom, I would expect that it allows me to plot any of the data I use for my other plots, but with some custom configuration.

This is currently a different and pretty specific type of plot. Maybe Metrics or Metric by Parameter?

@dberenbaum
Copy link
Contributor

Which experiments are included in this plot? The same ones that are selected for other plots? All experiments for the current commit? Something else?

@julieg18
Copy link
Contributor Author

Which experiments are included in this plot? The same ones that are selected for other plots? All experiments for the current commit? Something else?

Currently, all experiments shown in the table webview. In other words, all experiments from the past three commits.

@julieg18
Copy link
Contributor Author

julieg18 commented Mar 1, 2023

Alright, hopefully, the main issues have been resolved and other comments can be resolved in a followup! Will merge once the tests pass and open a followup issue detailing next steps!

@codeclimate
Copy link

codeclimate bot commented Mar 1, 2023

Code Climate has analyzed commit 74e70a0 and detected 15 issues on this pull request.

Here's the issue category breakdown:

Category Count
Complexity 3
Duplication 12

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

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

View more on Code Climate.

@julieg18 julieg18 merged commit 484a604 into main Mar 1, 2023
@julieg18 julieg18 deleted the add-metric-param-plots branch March 1, 2023 15:35
@julieg18 julieg18 mentioned this pull request Mar 1, 2023
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.

Add plots- metric vs hyperparameter values
5 participants