-
Notifications
You must be signed in to change notification settings - Fork 29
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
Add Custom Plots Section #3342
Conversation
} from 'dvc/src/plots/webview/contract' | ||
import { addPlotsWithSnapshots, removePlots } from '../plotDataStore' | ||
|
||
export interface CustomPlotsState extends Omit<CustomPlotsData, 'plots'> { |
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.
Similar blocks of code found in 2 locations. Consider refactoring.
size: DEFAULT_SECTION_SIZES[Section.CUSTOM_PLOTS] | ||
} | ||
|
||
export const customPlotsSlice = createSlice({ |
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.
Similar blocks of code found in 2 locations. Consider refactoring.
} | ||
|
||
return items.length > 0 ? ( | ||
<div |
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.
Similar blocks of code found in 2 locations. Consider refactoring.
dispatch(changeDisabledDragIds(enabled ? [] : [id])) | ||
} | ||
|
||
return ( |
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.
Similar blocks of code found in 2 locations. Consider refactoring.
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.
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.
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.
@@ -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') |
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.
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?
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.
expect the result to have length 2?
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.
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!
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.
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) { |
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.
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?
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.
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.
dispatch(changeDisabledDragIds(enabled ? [] : [id])) | ||
} | ||
|
||
return ( |
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.
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.
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? |
extension/src/plots/model/index.ts
Outdated
) | ||
|
||
if (plotAlreadyExists) { | ||
return Toast.showError('Custom plot already exists.') |
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.
[I] Ideally this class is responsible for data/data manipulation. Plots
should use Toast
and inform the user when there is a problem.
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.
Maybe we could remove the choice from the list instead of letting them select something that already exists.
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.
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!
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.
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.
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. |
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.
Screen.Recording.2023-02-28.at.10.10.12.AM.mov
The order is not persisted like other sections
extension/src/plots/model/index.ts
Outdated
) | ||
|
||
if (plotAlreadyExists) { | ||
return Toast.showError('Custom plot already exists.') |
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.
Maybe we could remove the choice from the list instead of letting them select something that already exists.
@@ -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') |
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.
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) { |
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.
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/customPlots/CustomPlotsWrapper.tsx
Outdated
Show resolved
Hide resolved
Forgot to add the logic for reordering 😅. Thanks for spotting that! Added |
setPlotsIdsOrder(changeOrderWithDraggedInfo(order, draggedRef)) | ||
} | ||
|
||
return items.length > 0 ? ( |
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.
Similar blocks of code found in 2 locations. Consider refactoring.
setOrder(pastOrder => performSimpleOrderedUpdate(pastOrder, plotsIds)) | ||
}, [plotsIds]) | ||
|
||
const setPlotsIdsOrder = (order: string[]): void => { |
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.
Similar blocks of code found in 2 locations. Consider refactoring.
Not sure what to call this kind of plot. When I see This is currently a different and pretty specific type of plot. Maybe |
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. |
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! |
Code Climate has analyzed commit 74e70a0 and detected 15 issues on this pull request. Here's the issue category breakdown:
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. |
Demo
https://user-images.githubusercontent.com/43496356/221732462-d4ad0eec-9cb7-4e5e-95fb-96268be7ec79.movScreen.Recording.2023-02-28.at.3.18.46.PM.mov
Fixes #2139