Skip to content

Commit d664a83

Browse files
authored
Bypass filters on missing values (for queued experiments) (#1732)
* add logic into filter to bypass undefined (for queued experiments) * fix auto apply filter behaviour
1 parent e2b3def commit d664a83

File tree

4 files changed

+54
-10
lines changed

4 files changed

+54
-10
lines changed

extension/src/experiments/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,9 @@ export class Experiments extends BaseRepository<TableData> {
252252
this.experiments.setSelectionMode(useFilters)
253253

254254
if (useFilters) {
255-
const filteredExperiments = this.experiments.getFilteredExperiments()
255+
const filteredExperiments = this.experiments
256+
.getFilteredExperiments()
257+
.filter(exp => !exp.queued)
256258
if (tooManySelected(filteredExperiments)) {
257259
await this.warnAndDoNotAutoApply(filteredExperiments)
258260
} else {

extension/src/experiments/model/filterBy/index.test.ts

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,40 @@ describe('filterExperiments', () => {
3131
id: 3,
3232
params: {
3333
'params.yaml': {
34+
bool: null,
3435
filter: 3,
35-
sort: 1
36+
sort: 1,
37+
text: 'not missing'
3638
}
3739
}
3840
}
3941
] as unknown as Experiment[]
4042

43+
it('should not filter experiments if they do not have the provided value (for queued experiments)', () => {
44+
const unfilteredQueuedExperiments = filterExperiments(
45+
[
46+
{
47+
operator: Operator.IS_FALSE,
48+
path: joinColumnPath(ColumnType.METRICS, 'metrics.json', 'acc'),
49+
value: undefined
50+
}
51+
],
52+
experiments
53+
)
54+
55+
expect(
56+
experiments
57+
.map(
58+
experiment => experiment[ColumnType.METRICS]?.['metrics.json']?.acc
59+
)
60+
.filter(Boolean)
61+
).toHaveLength(0)
62+
63+
expect(
64+
unfilteredQueuedExperiments.map(experiment => experiment.id)
65+
).toStrictEqual([1, 2, 3])
66+
})
67+
4168
it('should return the original experiments if no filters are provided', () => {
4269
const unFilteredExperiments = filterExperiments([], experiments)
4370
expect(unFilteredExperiments).toStrictEqual(experiments)

extension/src/experiments/model/filterBy/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ const evaluate = <T>(
4545
operator: Operator,
4646
filterValue: T
4747
): boolean => {
48+
if (valueToEvaluate === undefined) {
49+
return true
50+
}
4851
switch (operator) {
4952
case Operator.GREATER_THAN:
5053
return valueToEvaluate > filterValue

extension/src/test/suite/experiments/model/filterBy/tree.test.ts

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ suite('Experiments Filter By Tree Test Suite', () => {
3737
disposable.dispose()
3838
})
3939

40+
// eslint-disable-next-line sonarjs/cognitive-complexity
4041
describe('ExperimentsFilterByTree', () => {
4142
it('should appear in the UI', async () => {
4243
await expect(
@@ -80,15 +81,26 @@ suite('Experiments Filter By Tree Test Suite', () => {
8081
subRows: main.subRows
8182
?.filter(experiment => {
8283
const accuracy = experiment.metrics?.['summary.json']?.accuracy
83-
return accuracy && accuracy >= 0.45
84+
return !!(
85+
accuracy === undefined ||
86+
(accuracy && accuracy >= 0.45)
87+
)
8488
})
85-
.map(experiment => ({
86-
...experiment,
87-
subRows: experiment.subRows?.filter(checkpoint => {
88-
const accuracy = checkpoint.metrics?.['summary.json']?.accuracy
89-
return accuracy && accuracy >= 0.45
90-
})
91-
}))
89+
.map(experiment =>
90+
experiment.queued
91+
? experiment
92+
: {
93+
...experiment,
94+
subRows: experiment.subRows?.filter(checkpoint => {
95+
const accuracy =
96+
checkpoint.metrics?.['summary.json']?.accuracy
97+
return !!(
98+
accuracy === undefined ||
99+
(accuracy && accuracy >= 0.45)
100+
)
101+
})
102+
}
103+
)
92104
}
93105
]
94106

0 commit comments

Comments
 (0)