-
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
Fix plots not showing on first experiment run #4412
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,19 +51,10 @@ const collectType = (plots: Plot[]) => { | |
? type.add(PathType.TEMPLATE_MULTI) | ||
: type.add(PathType.TEMPLATE_SINGLE) | ||
} | ||
|
||
return type | ||
} | ||
|
||
const getType = ( | ||
data: PlotsData, | ||
hasChildren: boolean, | ||
path: string | ||
): Set<PathType> | undefined => { | ||
if (hasChildren) { | ||
return | ||
} | ||
|
||
const getType = (data: PlotsData, path: string): Set<PathType> | undefined => { | ||
const plots = data[path] | ||
if (!definedAndNonEmpty(plots)) { | ||
return | ||
|
@@ -118,6 +109,46 @@ const collectPathRevisions = (data: PlotsData, path: string): Set<string> => { | |
return revisions | ||
} | ||
|
||
const collectPlotPathType = ( | ||
plotPath: PlotPath, | ||
data: PlotsData, | ||
hasChildren: boolean, | ||
path: string | ||
) => { | ||
if (hasChildren) { | ||
return | ||
} | ||
|
||
const type = getType(data, path) | ||
|
||
if (type) { | ||
plotPath.type = type | ||
} | ||
} | ||
|
||
const updateExistingPlotPath = ( | ||
acc: PlotPath[], | ||
data: PlotsData, | ||
hasChildren: boolean, | ||
revisions: Set<string>, | ||
path: string | ||
) => | ||
acc.map(existing => { | ||
const plotPath = { ...existing } | ||
|
||
if (existing.path !== path) { | ||
return plotPath | ||
} | ||
|
||
plotPath.revisions = new Set([...existing.revisions, ...revisions]) | ||
|
||
if (!plotPath.type) { | ||
collectPlotPathType(plotPath, data, hasChildren, path) | ||
} | ||
|
||
return plotPath | ||
}) | ||
|
||
const collectOrderedPath = ( | ||
acc: PlotPath[], | ||
data: PlotsData, | ||
|
@@ -126,31 +157,20 @@ const collectOrderedPath = ( | |
idx: number | ||
): PlotPath[] => { | ||
const path = getPath(pathArray, idx) | ||
const hasChildren = idx !== pathArray.length | ||
|
||
if (acc.some(({ path: existingPath }) => existingPath === path)) { | ||
return acc.map(existing => | ||
existing.path === path | ||
? { | ||
...existing, | ||
revisions: new Set([...existing.revisions, ...revisions]) | ||
} | ||
: existing | ||
) | ||
return updateExistingPlotPath(acc, data, hasChildren, revisions, path) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [I] In There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. *I realise that this change is just expanding on what the old code was doing but we can still improve/update. |
||
} | ||
|
||
const hasChildren = idx !== pathArray.length | ||
|
||
const plotPath: PlotPath = { | ||
hasChildren, | ||
parentPath: getParent(pathArray, idx), | ||
path, | ||
revisions | ||
} | ||
|
||
const type = getType(data, hasChildren, path) | ||
if (type) { | ||
plotPath.type = type | ||
} | ||
collectPlotPathType(plotPath, data, hasChildren, path) | ||
|
||
acc.push(plotPath) | ||
return acc | ||
|
@@ -228,7 +248,6 @@ export const collectPaths = ( | |
if (errors?.length) { | ||
acc = collectErrorPaths(acc, data, errors) | ||
} | ||
|
||
return acc | ||
} | ||
|
||
|
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.
Not sure how common this bug is but when adding the plots to dvc.yaml in example-get-started and running an experiment,
plot diff
will first send plots withfile not found
errors. This causes us to build our plot paths without types that never get added since the code only updates revisions if the path already exists.I updated it to check the existing path's type existence but there might be a better way to handle this.
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 we can remove the
!plotPath.type
check.