Skip to content

Commit

Permalink
Make deeply nested experiments table test fixture static (#1745)
Browse files Browse the repository at this point in the history
* make deeply nested experiments table test fixture static

* remove collect columns from webview test
  • Loading branch information
mattseddon authored May 20, 2022
1 parent 38fb548 commit 50b8243
Show file tree
Hide file tree
Showing 4 changed files with 341 additions and 61 deletions.
17 changes: 17 additions & 0 deletions extension/src/experiments/columns/model.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,27 @@ import { buildMockMemento } from '../../test/util'
import { Status } from '../../path/selection/model'
import { PersistenceKey } from '../../persistence/constants'
import { ColumnType } from '../webview/contract'
import outputFixture from '../../test/fixtures/expShow/output'
import columnsFixture from '../../test/fixtures/expShow/columns'
import {
deeplyNestedOutput,
columns as deeplyNestedColumns
} from '../../test/fixtures/expShow/deeplyNested'

describe('ColumnsModel', () => {
const exampleDvcRoot = 'test'

it('should return columns that equal the columns fixture when given the output fixture', () => {
const model = new ColumnsModel('', buildMockMemento())
model.transformAndSet(outputFixture)
expect(model.getSelected()).toStrictEqual(columnsFixture)
})

it('should return data that equal the deeply nested output fixture', () => {
const model = new ColumnsModel('', buildMockMemento())
model.transformAndSet(deeplyNestedOutput)
expect(model.getSelected()).toStrictEqual(deeplyNestedColumns)
})
describe('persistence', () => {
const paramsDotYamlPath = joinColumnPath(ColumnType.PARAMS, 'params.yaml')
const testParamPath = appendColumnToPath(paramsDotYamlPath, 'testparam')
Expand Down
10 changes: 10 additions & 0 deletions extension/src/experiments/model/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ import { copyOriginalColors } from './status/colors'
import { Operator } from './filterBy'
import outputFixture from '../../test/fixtures/expShow/output'
import rowsFixture from '../../test/fixtures/expShow/rows'
import {
deeplyNestedOutput,
rows as deeplyNestedRows
} from '../../test/fixtures/expShow/deeplyNested'
import { buildMockMemento } from '../../test/util'
import { joinColumnPath } from '../columns/paths'
import { Experiment, ColumnType } from '../webview/contract'
Expand Down Expand Up @@ -66,6 +70,12 @@ describe('ExperimentsModel', () => {
expect(model.getRowData()).toStrictEqual(rowsFixture)
})

it('should return data that equal the deeply nested output fixture', () => {
const model = new ExperimentsModel('', buildMockMemento())
model.transformAndSet(deeplyNestedOutput)
expect(model.getRowData()).toStrictEqual(deeplyNestedRows)
})

it('should continue to apply filters to new data if selection mode is set to use filters', () => {
const testPath = joinColumnPath(ColumnType.PARAMS, 'params.yaml', 'test')

Expand Down
216 changes: 207 additions & 9 deletions extension/src/test/fixtures/expShow/deeplyNested.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { ExperimentsOutput } from '../../../cli/reader'
import { collectColumns } from '../../../experiments/columns/collect'
import { collectExperiments } from '../../../experiments/model/collect'
import { copyOriginalColors } from '../../../experiments/model/status/colors'
import { TableData } from '../../../experiments/webview/contract'
import {
Column,
ColumnType,
TableData
} from '../../../experiments/webview/contract'

export const deeplyNestedOutput: ExperimentsOutput = {
workspace: {
Expand Down Expand Up @@ -70,13 +71,210 @@ export const deeplyNestedOutput: ExperimentsOutput = {
}
}

export const columns = collectColumns(deeplyNestedOutput)
export const columns: Column[] = [
{
hasChildren: true,
name: 'params.yaml',
parentPath: 'params',
path: 'params:params.yaml',
type: ColumnType.PARAMS
},
{
hasChildren: true,
name: 'nested1',
parentPath: 'params:params.yaml',
path: 'params:params.yaml:nested1',
type: ColumnType.PARAMS
},
{
hasChildren: false,
maxStringLength: 15,
name: 'doubled',
parentPath: 'params:params.yaml:nested1',
path: 'params:params.yaml:nested1.doubled',
pathArray: ['params', 'params.yaml', 'nested1', 'doubled'],
type: ColumnType.PARAMS,
types: ['string']
},
{
hasChildren: true,
name: 'nested1.nested2.nested3.nested4',
parentPath: 'params:params.yaml',
path: 'params:params.yaml:nested1%2Enested2%2Enested3%2Enested4',
type: ColumnType.PARAMS
},
{
hasChildren: true,
name: 'nested5',
parentPath: 'params:params.yaml:nested1%2Enested2%2Enested3%2Enested4',
path: 'params:params.yaml:nested1%2Enested2%2Enested3%2Enested4.nested5',
type: ColumnType.PARAMS
},
{
hasChildren: true,
name: 'nested6',
parentPath:
'params:params.yaml:nested1%2Enested2%2Enested3%2Enested4.nested5',
path: 'params:params.yaml:nested1%2Enested2%2Enested3%2Enested4.nested5.nested6',
type: ColumnType.PARAMS
},
{
hasChildren: false,
maxStringLength: 6,
name: 'nested7',
parentPath:
'params:params.yaml:nested1%2Enested2%2Enested3%2Enested4.nested5.nested6',
path: 'params:params.yaml:nested1%2Enested2%2Enested3%2Enested4.nested5.nested6.nested7',
pathArray: [
'params',
'params.yaml',
'nested1',
'nested2',
'nested3',
'nested4',
'nested5',
'nested6',
'nested7'
],
type: ColumnType.PARAMS,
types: ['string']
},
{
hasChildren: true,
name: 'nested1.nested2.nested3',
parentPath: 'params:params.yaml',
path: 'params:params.yaml:nested1%2Enested2%2Enested3',
type: ColumnType.PARAMS
},
{
hasChildren: true,
name: 'nested4',
parentPath: 'params:params.yaml:nested1%2Enested2%2Enested3',
path: 'params:params.yaml:nested1%2Enested2%2Enested3.nested4',
type: ColumnType.PARAMS
},
{
hasChildren: true,
name: 'nested5b',
parentPath: 'params:params.yaml:nested1%2Enested2%2Enested3.nested4',
path: 'params:params.yaml:nested1%2Enested2%2Enested3.nested4.nested5b',
type: ColumnType.PARAMS
},
{
hasChildren: false,
maxStringLength: 23,
name: 'nested6',
parentPath:
'params:params.yaml:nested1%2Enested2%2Enested3.nested4.nested5b',
path: 'params:params.yaml:nested1%2Enested2%2Enested3.nested4.nested5b.nested6',
pathArray: [
'params',
'params.yaml',
'nested1',
'nested2',
'nested3',
'nested4',
'nested5b',
'nested6'
],
type: ColumnType.PARAMS,
types: ['string']
},
{
hasChildren: false,
maxStringLength: 16,
name: 'doubled',
parentPath:
'params:params.yaml:nested1%2Enested2%2Enested3.nested4.nested5b',
path: 'params:params.yaml:nested1%2Enested2%2Enested3.nested4.nested5b.doubled',
pathArray: [
'params',
'params.yaml',
'nested1',
'nested2',
'nested3',
'nested4',
'nested5b',
'doubled'
],
type: ColumnType.PARAMS,
types: ['string']
},
{
hasChildren: false,
maxStringLength: 1,
name: 'outlier',
parentPath: 'params:params.yaml',
path: 'params:params.yaml:outlier',
pathArray: ['params', 'params.yaml', 'outlier'],
type: ColumnType.PARAMS,
types: ['number'],
maxNumber: 1,
minNumber: 1
}
]

const { workspace, branches } = collectExperiments(deeplyNestedOutput)
const colors = copyOriginalColors()
export const rows = [
{ ...workspace, displayColor: colors[0] },
...branches.map((branch, i) => ({ ...branch, displayColor: colors[i + 1] }))
{
id: 'workspace',
label: 'workspace',
timestamp: null,
queued: false,
running: false,
executor: null,
params: {
'params.yaml': {
nested1: {
doubled: 'first instance!',
nested2: {
nested3: {
nested4: {
nested5: { nested6: { nested7: 'Lucky!' } },
nested5b: {
nested6: 'Wow!!!!!!!!!!!!!!!!!!!!',
doubled: 'second instance!'
}
}
}
}
},
outlier: 1
}
},
displayColor: '#945dd6',
selected: true
},
{
id: 'main',
label: 'main',
timestamp: '2020-11-21T19:58:22',
queued: false,
running: false,
executor: null,
name: 'main',
sha: '53c3851f46955fa3e2b8f6e1c52999acc8c9ea77',
params: {
'params.yaml': {
nested1: {
doubled: 'first instance!',
nested2: {
nested3: {
nested4: {
nested5: { nested6: { nested7: 'Lucky!' } },
nested5b: {
nested6: 'Wow!!!!!!!!!!!!!!!!!!!!',
doubled: 'second instance!'
}
}
}
}
},
outlier: 1
}
},
displayColor: '#13adc7',
selected: true
}
]

const deeplyNestedTableData: TableData = {
Expand Down
Loading

0 comments on commit 50b8243

Please sign in to comment.