Skip to content

Commit 88b5ad2

Browse files
authored
Add deps to experiment table and columns tree (#1830)
* hack together deps data structure and get tests passing before refactoring * refactor the entirety of columns collection - MAXIMUM EFFORT * add colors into deps column headers * fix path selection column names * quick self review * collect dep changes * add dep test to build dynamic columns * replace dep usage of build metric or param path * rename name to label to be consistent * refactor function args * refactor column collection file * refactor function params for collect metric or param * refactor walk value tree * reorder more args * cut hash at 7 characters to match CLI
1 parent 5a66c09 commit 88b5ad2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+1581
-1295
lines changed

extension/package.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,14 @@
5454
},
5555
"contributes": {
5656
"colors": [
57+
{
58+
"id": "dvc.deps",
59+
"description": "Color to indicate a DVC dep column in the experiments table",
60+
"defaults": {
61+
"dark": "#b079e7",
62+
"light": "#4f1886"
63+
}
64+
},
5765
{
5866
"id": "dvc.metrics",
5967
"description": "Color to indicate a DVC metric column in the experiments table",

extension/src/cli/reader.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ type RelPathObject<T> = {
6969

7070
export type ValueTreeRoot = RelPathObject<ValueTreeOrError>
7171

72-
interface ValueTreeNode {
72+
export interface ValueTreeNode {
7373
[key: string]: Value | ValueTree
7474
}
7575

@@ -88,10 +88,12 @@ export interface BaseExperimentFields {
8888
type Dep = { hash: string; size: number; nfiles: null | number }
8989
type Out = Dep & { use_cache: boolean; is_data_source: boolean }
9090

91+
export type Deps = RelPathObject<Dep>
92+
9193
export interface ExperimentFields extends BaseExperimentFields {
9294
params?: ValueTreeRoot
9395
metrics?: ValueTreeRoot
94-
deps?: RelPathObject<Dep>
96+
deps?: Deps
9597
outs?: RelPathObject<Out>
9698
}
9799

extension/src/experiments/columns/collect.ts

Lines changed: 0 additions & 247 deletions
This file was deleted.
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import { sep } from 'path'
2+
import get from 'lodash.get'
3+
import {
4+
ColumnAccumulator,
5+
limitAncestorDepth,
6+
mergeAncestors,
7+
mergeValueColumn
8+
} from './util'
9+
import { buildDepPath } from '../paths'
10+
import { ColumnType } from '../../webview/contract'
11+
import { ExperimentFields } from '../../../cli/reader'
12+
import { getPathArray } from '../../../fileSystem/util'
13+
import { shortenForLabel } from '../../../util/string'
14+
15+
export const collectDeps = (acc: ColumnAccumulator, data: ExperimentFields) => {
16+
const { deps } = data
17+
if (!deps) {
18+
return
19+
}
20+
for (const [file, { hash }] of Object.entries(deps)) {
21+
const pathArray = getPathArray(file)
22+
const label = pathArray.pop() as string
23+
24+
const limitedDepthAncestors = limitAncestorDepth(pathArray, sep)
25+
const path = buildDepPath(file)
26+
27+
mergeAncestors(
28+
acc,
29+
ColumnType.DEPS,
30+
path,
31+
limitedDepthAncestors,
32+
(...pathArray: string[]) => buildDepPath(...pathArray)
33+
)
34+
35+
mergeValueColumn(
36+
acc,
37+
path,
38+
buildDepPath(...limitedDepthAncestors),
39+
[ColumnType.DEPS, file],
40+
label,
41+
shortenForLabel(hash)
42+
)
43+
}
44+
}
45+
46+
export const collectDepChanges = (
47+
changes: string[],
48+
workspaceData: ExperimentFields,
49+
commitData: ExperimentFields
50+
) => {
51+
for (const [file, { hash }] of Object.entries(
52+
workspaceData?.[ColumnType.DEPS] || {}
53+
)) {
54+
if (get(commitData?.[ColumnType.DEPS], [file, 'hash']) !== hash) {
55+
changes.push(buildDepPath(file))
56+
}
57+
}
58+
}

0 commit comments

Comments
 (0)