Skip to content

Commit

Permalink
Show plots errors in plots tree
Browse files Browse the repository at this point in the history
  • Loading branch information
mattseddon committed Mar 22, 2023
1 parent f2eda8c commit e7c905f
Show file tree
Hide file tree
Showing 10 changed files with 245 additions and 55 deletions.
90 changes: 60 additions & 30 deletions extension/src/experiments/columns/tree.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,23 +124,26 @@ describe('ExperimentsColumnsTree', () => {
dvcRoot: mockedDvcRoot,
iconPath: mockedSelectedCheckbox,
label: timestampColumn.label,
path: timestampColumn.path
path: timestampColumn.path,
tooltip: undefined
},
{
collapsibleState: 1,
description: undefined,
dvcRoot: mockedDvcRoot,
iconPath: mockedSelectedCheckbox,
label: 'summary.json',
path: buildMetricOrParamPath(ColumnType.METRICS, 'summary.json')
path: buildMetricOrParamPath(ColumnType.METRICS, 'summary.json'),
tooltip: undefined
},
{
collapsibleState: 1,
description: undefined,
dvcRoot: mockedDvcRoot,
iconPath: mockedSelectedCheckbox,
label: 'params.yaml',
path: buildMetricOrParamPath(ColumnType.PARAMS, 'params.yaml')
path: buildMetricOrParamPath(ColumnType.PARAMS, 'params.yaml'),
tooltip: undefined
},
{
collapsibleState: 1,
Expand All @@ -151,31 +154,35 @@ describe('ExperimentsColumnsTree', () => {
path: buildMetricOrParamPath(
ColumnType.PARAMS,
join('nested', 'params.yaml')
)
),
tooltip: undefined
},
{
collapsibleState: 1,
description: undefined,
dvcRoot: mockedDvcRoot,
iconPath: mockedSelectedCheckbox,
label: 'data',
path: buildDepPath('data')
path: buildDepPath('data'),
tooltip: undefined
},
{
collapsibleState: 1,
description: undefined,
dvcRoot: mockedDvcRoot,
iconPath: mockedSelectedCheckbox,
label: 'src',
path: buildDepPath('src')
path: buildDepPath('src'),
tooltip: undefined
},
{
collapsibleState: 0,
description: undefined,
dvcRoot: mockedDvcRoot,
iconPath: mockedSelectedCheckbox,
label: 'model.pkl',
path: buildDepPath('model.pkl')
path: buildDepPath('model.pkl'),
tooltip: undefined
}
])
})
Expand Down Expand Up @@ -211,23 +218,26 @@ describe('ExperimentsColumnsTree', () => {
dvcRoot: mockedDvcRoot,
iconPath: mockedSelectedCheckbox,
label: timestampColumn.label,
path: timestampColumn.path
path: timestampColumn.path,
tooltip: undefined
},
{
collapsibleState: 1,
description: undefined,
dvcRoot: mockedDvcRoot,
iconPath: mockedSelectedCheckbox,
label: 'summary.json',
path: buildMetricOrParamPath(ColumnType.METRICS, 'summary.json')
path: buildMetricOrParamPath(ColumnType.METRICS, 'summary.json'),
tooltip: undefined
},
{
collapsibleState: 1,
description: undefined,
dvcRoot: mockedDvcRoot,
iconPath: mockedSelectedCheckbox,
label: 'params.yaml',
path: paramsPath
path: paramsPath,
tooltip: undefined
},
{
collapsibleState: 1,
Expand All @@ -238,31 +248,35 @@ describe('ExperimentsColumnsTree', () => {
path: buildMetricOrParamPath(
ColumnType.PARAMS,
join('nested', 'params.yaml')
)
),
tooltip: undefined
},
{
collapsibleState: 1,
description: undefined,
dvcRoot: mockedDvcRoot,
iconPath: mockedSelectedCheckbox,
label: 'data',
path: buildDepPath('data')
path: buildDepPath('data'),
tooltip: undefined
},
{
collapsibleState: 1,
description: undefined,
dvcRoot: mockedDvcRoot,
iconPath: mockedSelectedCheckbox,
label: 'src',
path: buildDepPath('src')
path: buildDepPath('src'),
tooltip: undefined
},
{
collapsibleState: 0,
description: undefined,
dvcRoot: mockedDvcRoot,
iconPath: mockedSelectedCheckbox,
label: 'model.pkl',
path: buildDepPath('model.pkl')
path: buildDepPath('model.pkl'),
tooltip: undefined
}
])

Expand All @@ -276,15 +290,17 @@ describe('ExperimentsColumnsTree', () => {
descendantStatuses: [Status.UNSELECTED, Status.SELECTED],
hasChildren: true,
label: getLabel(param.path),
status: Status.INDETERMINATE
status: Status.INDETERMINATE,
tooltip: undefined
}
}
return {
...param,
descendantStatuses: undefined,
hasChildren: false,
label: getLabel(param.path),
status: Status.SELECTED
status: Status.SELECTED,
tooltip: undefined
}
})
)
Expand All @@ -295,7 +311,8 @@ describe('ExperimentsColumnsTree', () => {
dvcRoot: mockedDvcRoot,
iconPath: mockedSelectedCheckbox,
label: 'params.yaml',
path: paramsPath
path: paramsPath,
tooltip: undefined
})
expect(grandChildren).toStrictEqual([
{
Expand All @@ -304,55 +321,62 @@ describe('ExperimentsColumnsTree', () => {
dvcRoot: mockedDvcRoot,
iconPath: mockedSelectedCheckbox,
label: 'code_names',
path: appendColumnToPath(paramsPath, 'code_names')
path: appendColumnToPath(paramsPath, 'code_names'),
tooltip: undefined
},
{
collapsibleState: 0,
description: undefined,
dvcRoot: mockedDvcRoot,
iconPath: mockedSelectedCheckbox,
label: 'epochs',
path: appendColumnToPath(paramsPath, 'epochs')
path: appendColumnToPath(paramsPath, 'epochs'),
tooltip: undefined
},
{
collapsibleState: 0,
description: undefined,
dvcRoot: mockedDvcRoot,
iconPath: mockedSelectedCheckbox,
label: 'learning_rate',
path: appendColumnToPath(paramsPath, 'learning_rate')
path: appendColumnToPath(paramsPath, 'learning_rate'),
tooltip: undefined
},
{
collapsibleState: 0,
description: undefined,
dvcRoot: mockedDvcRoot,
iconPath: mockedSelectedCheckbox,
label: 'dvc_logs_dir',
path: appendColumnToPath(paramsPath, 'dvc_logs_dir')
path: appendColumnToPath(paramsPath, 'dvc_logs_dir'),
tooltip: undefined
},
{
collapsibleState: 0,
description: undefined,
dvcRoot: mockedDvcRoot,
iconPath: mockedSelectedCheckbox,
label: 'log_file',
path: appendColumnToPath(paramsPath, 'log_file')
path: appendColumnToPath(paramsPath, 'log_file'),
tooltip: undefined
},
{
collapsibleState: 0,
description: undefined,
dvcRoot: mockedDvcRoot,
iconPath: mockedSelectedCheckbox,
label: 'dropout',
path: appendColumnToPath(paramsPath, 'dropout')
path: appendColumnToPath(paramsPath, 'dropout'),
tooltip: undefined
},
{
collapsibleState: 1,
description: '1/2',
dvcRoot: mockedDvcRoot,
iconPath: mockedIndeterminateCheckbox,
label: 'process',
path: processPath
path: processPath,
tooltip: undefined
}
])

Expand All @@ -364,7 +388,8 @@ describe('ExperimentsColumnsTree', () => {
descendantStatuses: undefined,
hasChildren: false,
label: getLabel(param.path),
status: Status.SELECTED
status: Status.SELECTED,
tooltip: undefined
}))
)
const greatGrandChildren = await experimentsColumnsTree.getChildren({
Expand All @@ -373,7 +398,8 @@ describe('ExperimentsColumnsTree', () => {
dvcRoot: mockedDvcRoot,
iconPath: mockedIndeterminateCheckbox,
label: 'process',
path: processPath
path: processPath,
tooltip: undefined
})

expect(greatGrandChildren).toStrictEqual([
Expand All @@ -388,7 +414,8 @@ describe('ExperimentsColumnsTree', () => {
'params.yaml',
'process',
'threshold'
)
),
tooltip: undefined
},
{
collapsibleState: 0,
Expand All @@ -401,7 +428,8 @@ describe('ExperimentsColumnsTree', () => {
'params.yaml',
'process',
'test_arg'
)
),
tooltip: undefined
}
])
})
Expand Down Expand Up @@ -454,7 +482,8 @@ describe('ExperimentsColumnsTree', () => {
dvcRoot: mockedDvcRoot,
iconPath: mockedSelectedCheckbox,
label: filename,
path: relParamsPath
path: relParamsPath,
tooltip: undefined
}

const treeItem = experimentsColumnsTree.getTreeItem(columnsItem)
Expand Down Expand Up @@ -494,7 +523,8 @@ describe('ExperimentsColumnsTree', () => {
dvcRoot: mockedDvcRoot,
iconPath: mockedEmptyCheckbox,
label: filename,
path: relParamsPath
path: relParamsPath,
tooltip: undefined
}

const treeItem = experimentsColumnsTree.getTreeItem(columnsItem)
Expand Down
24 changes: 19 additions & 5 deletions extension/src/path/selection/tree.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {
Event,
MarkdownString,
TreeDataProvider,
TreeItem,
TreeItemCollapsibleState,
Expand All @@ -24,6 +25,7 @@ export type PathSelectionItem = {
label: string | undefined
path: string
iconPath: Resource | Uri
tooltip: MarkdownString | undefined
}

export abstract class BasePathSelectionTree<
Expand Down Expand Up @@ -76,7 +78,7 @@ export abstract class BasePathSelectionTree<
return new TreeItem(resourceUri, TreeItemCollapsibleState.Collapsed)
}

const { dvcRoot, path, description, iconPath } = element
const { dvcRoot, path, description, iconPath, tooltip } = element

const treeItem = this.getBaseTreeItem(element)

Expand All @@ -90,6 +92,9 @@ export abstract class BasePathSelectionTree<
if (description) {
treeItem.description = description
}
if (tooltip) {
treeItem.tooltip = tooltip
}

return treeItem
}
Expand Down Expand Up @@ -132,9 +137,17 @@ export abstract class BasePathSelectionTree<
path: string
status: Status
label?: string
tooltip?: MarkdownString
}) {
const { dvcRoot, descendantStatuses, hasChildren, path, status, label } =
element
const {
dvcRoot,
descendantStatuses,
hasChildren,
path,
status,
label,
tooltip
} = element

const description = this.getDescription(descendantStatuses, '/')
const iconPath = this.getIconPath(status)
Expand All @@ -148,8 +161,9 @@ export abstract class BasePathSelectionTree<
dvcRoot,
iconPath,
label,
path
} as PathSelectionItem
path,
tooltip
}
}

private updateDescriptionOnChange() {
Expand Down
30 changes: 30 additions & 0 deletions extension/src/plots/errors/collect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,33 @@ export const collectImageErrors = (

return msgs.join('\n')
}

const formatError = (acc: string[]): string | undefined => {
if (acc.length === 0) {
return
}

acc.sort()
if (acc.length > 1) {
acc.unshift('Errors')
}

return acc.join(' \n')
}

export const collectPathErrors = (
path: string,
selectedRevisions: string[],
errors: PlotError[]
): string | undefined => {
const acc: string[] = []
for (const error of errors) {
const { name, rev } = error
if (name !== path || !selectedRevisions.includes(rev)) {
continue
}

acc.push(`${rev}: ${getMessage(error)}`)
}
return formatError(acc)
}
Loading

0 comments on commit e7c905f

Please sign in to comment.