Skip to content

Commit 730d442

Browse files
authored
Highlight changed hashes for Deps columns (#2029)
* Highlight changed hashes for deps columns * Use ValueWithChanges for deps values * Create separate style for deps changes * Improve code style
1 parent 53f21f3 commit 730d442

File tree

7 files changed

+223
-153
lines changed

7 files changed

+223
-153
lines changed

extension/src/experiments/columns/extract.ts

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import { Deps, ExperimentFields, ValueTreeRoot } from '../../cli/reader'
22
import { shortenForLabel } from '../../util/string'
3-
import { DepColumns, MetricOrParamColumns } from '../webview/contract'
3+
import {
4+
DepColumns,
5+
Experiment,
6+
MetricOrParamColumns
7+
} from '../webview/contract'
48

59
const extractMetricsOrParams = (
610
columns?: ValueTreeRoot
@@ -21,28 +25,36 @@ const extractMetricsOrParams = (
2125
return acc
2226
}
2327

24-
const extractDeps = (columns?: Deps): DepColumns | undefined => {
28+
const extractDeps = (
29+
columns?: Deps,
30+
branch?: Experiment
31+
): DepColumns | undefined => {
2532
if (!columns) {
2633
return
2734
}
2835

2936
const acc: DepColumns = {}
3037

3138
for (const [path, { hash }] of Object.entries(columns)) {
32-
acc[path] = shortenForLabel(hash)
39+
const value = shortenForLabel(hash)
40+
acc[path] = {
41+
changes: !!value && !!branch && branch?.deps?.[path].value !== value,
42+
value
43+
}
3344
}
3445

3546
return acc
3647
}
3748

3849
export const extractColumns = (
39-
experiment: ExperimentFields
50+
experiment: ExperimentFields,
51+
branch?: Experiment
4052
): {
4153
deps: DepColumns | undefined
4254
metrics: MetricOrParamColumns | undefined
4355
params: MetricOrParamColumns | undefined
4456
} => ({
45-
deps: extractDeps(experiment.deps),
57+
deps: extractDeps(experiment.deps, branch),
4658
metrics: extractMetricsOrParams(experiment.metrics),
4759
params: extractMetricsOrParams(experiment.params)
4860
})

extension/src/experiments/model/collect.ts

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,10 @@ const getCheckpointTipId = (
112112

113113
const transformColumns = (
114114
experiment: Experiment,
115-
experimentFields: ExperimentFields
115+
experimentFields: ExperimentFields,
116+
branch?: Experiment
116117
) => {
117-
const { metrics, params, deps } = extractColumns(experimentFields)
118+
const { metrics, params, deps } = extractColumns(experimentFields, branch)
118119

119120
if (metrics) {
120121
experiment.metrics = metrics
@@ -133,7 +134,8 @@ const transformExperimentData = (
133134
label: string | undefined,
134135
sha?: string,
135136
displayNameOrParent?: string,
136-
logicalGroupName?: string
137+
logicalGroupName?: string,
138+
branch?: Experiment
137139
): Experiment => {
138140
const experiment = {
139141
id,
@@ -153,7 +155,7 @@ const transformExperimentData = (
153155
experiment.sha = sha
154156
}
155157

156-
transformColumns(experiment, experimentFields)
158+
transformColumns(experiment, experimentFields, branch)
157159

158160
return experiment
159161
}
@@ -162,7 +164,8 @@ const transformExperimentOrCheckpointData = (
162164
sha: string,
163165
experimentData: ExperimentFieldsOrError,
164166
experimentsObject: ExperimentsObject,
165-
branchSha: string
167+
branchSha: string,
168+
branch: Experiment
166169
): {
167170
checkpointTipId?: string
168171
experiment: Experiment | undefined
@@ -187,7 +190,8 @@ const transformExperimentOrCheckpointData = (
187190
shortenForLabel(sha),
188191
sha,
189192
getDisplayNameOrParent(sha, branchSha, experimentsObject),
190-
getLogicalGroupName(sha, branchSha, experimentsObject)
193+
getLogicalGroupName(sha, branchSha, experimentsObject),
194+
branch
191195
)
192196
}
193197
}
@@ -222,14 +226,17 @@ const collectFromExperimentsObject = (
222226
acc: ExperimentsAccumulator,
223227
experimentsObject: ExperimentsObject,
224228
branchSha: string,
225-
branchName: string
229+
branch: Experiment
226230
) => {
231+
const branchName = branch.label
232+
227233
for (const [sha, experimentData] of Object.entries(experimentsObject)) {
228234
const { checkpointTipId, experiment } = transformExperimentOrCheckpointData(
229235
sha,
230236
experimentData,
231237
experimentsObject,
232-
branchSha
238+
branchSha,
239+
branch
233240
)
234241
if (!experiment) {
235242
continue
@@ -257,7 +264,7 @@ const collectFromBranchesObject = (
257264
const branch = transformExperimentData(name, experimentFields, name, sha)
258265

259266
if (branch) {
260-
collectFromExperimentsObject(acc, experimentsObject, sha, branch.label)
267+
collectFromExperimentsObject(acc, experimentsObject, sha, branch)
261268
collectHasRunningExperiment(acc, branch)
262269

263270
acc.branches.push(branch)

extension/src/experiments/webview/contract.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,13 @@ export interface MetricOrParamColumns {
66
[filename: string]: ValueTree
77
}
88

9+
export interface ValueWithChanges {
10+
value: string | number
11+
changes: boolean
12+
}
13+
914
export interface DepColumns {
10-
[path: string]: string
15+
[path: string]: ValueWithChanges
1116
}
1217

1318
export interface Experiment extends BaseExperimentFields {

0 commit comments

Comments
 (0)