Skip to content

Commit bcf0919

Browse files
authored
Account for null being an object in workspace change data collection (#2617)
1 parent 7c7e9fd commit bcf0919

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

extension/src/experiments/columns/collect/index.test.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -693,6 +693,32 @@ describe('collectChanges', () => {
693693
).toStrictEqual(['params:params.yaml:a.b'])
694694
})
695695

696+
it('should handle when a parameter has a null value', () => {
697+
const nullParam = {
698+
param_tuning: {
699+
logistic_regression: null
700+
}
701+
}
702+
703+
expect(
704+
collectChanges({
705+
workspace: updateParams(nullParam),
706+
'9c6ba26745d2fbc286a13b99011d5126b5a245dc': updateParams(nullParam)
707+
})
708+
).toStrictEqual([])
709+
710+
expect(
711+
collectChanges({
712+
workspace: updateParams(nullParam),
713+
'9c6ba26745d2fbc286a13b99011d5126b5a245dc': updateParams({
714+
param_tuning: {
715+
logistic_regression: 1
716+
}
717+
})
718+
})
719+
).toStrictEqual(['params:params.yaml:param_tuning.logistic_regression'])
720+
})
721+
696722
it('should compare against the most recent commit', () => {
697723
const matchingParams = {
698724
lr: 0.1

extension/src/experiments/columns/collect/metricsAndParams.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ const collectChange = (
110110
commitData: ExperimentFields,
111111
ancestors: string[] = []
112112
) => {
113-
if (!Array.isArray(value) && typeof value === 'object') {
113+
if (value && !Array.isArray(value) && typeof value === 'object') {
114114
for (const [childKey, childValue] of Object.entries(value as ValueTree)) {
115115
collectChange(changes, type, file, childKey, childValue, commitData, [
116116
...ancestors,

0 commit comments

Comments
 (0)