Skip to content

Commit

Permalink
fix all integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mattseddon committed Apr 12, 2023
1 parent e8415a0 commit cdd871a
Show file tree
Hide file tree
Showing 59 changed files with 13,705 additions and 14,072 deletions.
6 changes: 3 additions & 3 deletions extension/src/cli/dvc/viewer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@ export class DvcViewer extends Disposable implements ICli {
return this.createProcess(name, cwd, args)
}

public queueLogs(cwd: string, expName: string) {
public queueLogs(cwd: string, id: string) {
return this.run(
`${expName} logs`,
`${id} logs`,
cwd,
Command.QUEUE,
QueueSubCommand.LOGS,
expName,
id,
Flag.FOLLOW
)
}
Expand Down
80 changes: 10 additions & 70 deletions extension/src/experiments/columns/collect/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
/* eslint-disable sort-keys-fix/sort-keys-fix */
import { join } from 'path'
import { collectChanges, collectColumns } from '.'
import {
collectChanges,
collectChanges_,
collectColumns,
collectColumns_
} from '.'
import { timestampColumn } from '../constants'
import { buildDepPath, buildMetricOrParamPath } from '../paths'
import { buildMetricOrParamPath } from '../paths'
import { Column, ColumnType } from '../../webview/contract'
import outputFixture from '../../../test/fixtures/expShow/base/output'
import outputFixture from '../../../test/fixtures/expShow/base/output_'
import columnsFixture from '../../../test/fixtures/expShow/base/columns'
import workspaceChangesFixture from '../../../test/fixtures/expShow/base/workspaceChanges'
import uncommittedDepsFixture from '../../../test/fixtures/expShow/uncommittedDeps/output'
Expand All @@ -23,7 +27,7 @@ mockedGetConfigValue.mockImplementation(() => 5)

describe('collectColumns', () => {
it('should return a value equal to the columns fixture when given the output fixture', () => {
const columns = collectColumns(outputFixture)
const columns = collectColumns_(outputFixture)
expect(columns).toStrictEqual(columnsFixture)
})

Expand Down Expand Up @@ -429,70 +433,6 @@ describe('collectColumns', () => {

expect(onlyHasPrimitiveChild).toBeUndefined()
})

it('should collect all params and metrics from the test fixture', () => {
expect(collectColumns(outputFixture).map(({ path }) => path)).toStrictEqual(
[
timestampColumn.path,
buildMetricOrParamPath(ColumnType.METRICS, 'summary.json'),
buildMetricOrParamPath(ColumnType.METRICS, 'summary.json', 'loss'),
buildMetricOrParamPath(ColumnType.METRICS, 'summary.json', 'accuracy'),
buildMetricOrParamPath(ColumnType.METRICS, 'summary.json', 'val_loss'),
buildMetricOrParamPath(
ColumnType.METRICS,
'summary.json',
'val_accuracy'
),
buildMetricOrParamPath(ColumnType.PARAMS, 'params.yaml'),
buildMetricOrParamPath(ColumnType.PARAMS, 'params.yaml', 'code_names'),
buildMetricOrParamPath(ColumnType.PARAMS, 'params.yaml', 'epochs'),
buildMetricOrParamPath(
ColumnType.PARAMS,
'params.yaml',
'learning_rate'
),
buildMetricOrParamPath(
ColumnType.PARAMS,
'params.yaml',
'dvc_logs_dir'
),
buildMetricOrParamPath(ColumnType.PARAMS, 'params.yaml', 'log_file'),
buildMetricOrParamPath(ColumnType.PARAMS, 'params.yaml', 'dropout'),
buildMetricOrParamPath(ColumnType.PARAMS, 'params.yaml', 'process'),
buildMetricOrParamPath(
ColumnType.PARAMS,
'params.yaml',
'process',
'threshold'
),
buildMetricOrParamPath(
ColumnType.PARAMS,
'params.yaml',
'process',
'test_arg'
),
buildMetricOrParamPath(
ColumnType.PARAMS,
join('nested', 'params.yaml')
),
buildMetricOrParamPath(
ColumnType.PARAMS,
join('nested', 'params.yaml'),
'test'
),
buildDepPath('data'),
buildDepPath('data', 'data.xml'),
buildDepPath('src'),
buildDepPath('src', 'prepare.py'),
buildDepPath('data', 'prepared'),
buildDepPath('src', 'featurization.py'),
buildDepPath('data', 'features'),
buildDepPath('src', 'train.py'),
buildDepPath('model.pkl'),
buildDepPath('src', 'evaluate.py')
]
)
})
})

describe('collectChanges', () => {
Expand Down Expand Up @@ -523,7 +463,7 @@ describe('collectChanges', () => {
})

it('should return the expected data from the output fixture', () => {
const changes = collectChanges(outputFixture)
const changes = collectChanges_(outputFixture)
expect(changes).toStrictEqual(workspaceChangesFixture)
})

Expand Down
6 changes: 5 additions & 1 deletion extension/src/experiments/columns/collect/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,16 @@ export const getData_ = (expState: ExpState): ExpStateData | undefined => {
if (hasError(expState)) {
return
}
return expState?.data
return expState.data
}

export const collectChanges_ = (output: ExpShowOutput): string[] => {
const changes: string[] = []

if (!(output.length > 1)) {
return changes
}

const [workspaceData, currentCommitData] = output
const workspace = getData_(workspaceData)
const currentCommit = getData_(currentCommitData)
Expand Down
14 changes: 7 additions & 7 deletions extension/src/experiments/columns/model.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ 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/base/output'
import outputFixture from '../../test/fixtures/expShow/base/output_'
import columnsFixture from '../../test/fixtures/expShow/base/columns'
import {
deeplyNestedColumnsWithHeightOf10,
Expand Down Expand Up @@ -64,7 +64,7 @@ describe('ColumnsModel', () => {
buildMockMemento(),
mockedColumnsOrderOrStatusChanged
)
await model.transformAndSet(outputFixture)
await model.transformAndSet_(outputFixture)
expect(mockedGetConfigValue).toHaveBeenCalled()
expect(model.getSelected()).toStrictEqual(columnsFixture)
})
Expand Down Expand Up @@ -284,7 +284,7 @@ describe('ColumnsModel', () => {
}),
mockedColumnsOrderOrStatusChanged
)
await model.transformAndSet(outputFixture)
await model.transformAndSet_(outputFixture)

expect(model.getFirstThreeColumnOrder()).toStrictEqual(
persistedState.slice(1, 4)
Expand All @@ -303,7 +303,7 @@ describe('ColumnsModel', () => {
buildMockMemento(),
mockedColumnsOrderOrStatusChanged
)
await model.transformAndSet(outputFixture)
await model.transformAndSet_(outputFixture)

expect(model.getFirstThreeColumnOrder()).toStrictEqual([
'Created',
Expand Down Expand Up @@ -398,7 +398,7 @@ describe('ColumnsModel', () => {
mockMemento,
mockedColumnsOrderOrStatusChanged
)
await model.transformAndSet(outputFixture)
await model.transformAndSet_(outputFixture)
expect(model.getSelected()).toStrictEqual(columnsFixture)

const parentPath = 'params:params.yaml:process'
Expand All @@ -419,7 +419,7 @@ describe('ColumnsModel', () => {
mockMemento,
mockedColumnsOrderOrStatusChanged
)
await model.transformAndSet(outputFixture)
await model.transformAndSet_(outputFixture)
expect(model.getSelected()).not.toStrictEqual(columnsFixture)

model.toggleStatus(parentPath)
Expand All @@ -437,7 +437,7 @@ describe('ColumnsModel', () => {
mockMemento,
mockedColumnsOrderOrStatusChanged
)
await model.transformAndSet(outputFixture)
await model.transformAndSet_(outputFixture)
expect(model.getSelected()).toStrictEqual(columnsFixture)

const parentPath = 'metrics:summary.json'
Expand Down
10 changes: 1 addition & 9 deletions extension/src/experiments/columns/model.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { EventEmitter, Memento } from 'vscode'
import {
collectChanges,
collectChanges_,
collectColumns,
collectColumns_,
Expand Down Expand Up @@ -60,10 +59,7 @@ export class ColumnsModel extends PathSelectionModel<Column> {
}

public transformAndSet(data: ExperimentsOutput) {
return Promise.all([
this.transformAndSetColumns(data),
this.transformAndSetChanges(data)
])
return Promise.all([this.transformAndSetColumns(data)])
}

public transformAndSet_(data: ExpShowOutput) {
Expand Down Expand Up @@ -201,10 +197,6 @@ export class ColumnsModel extends PathSelectionModel<Column> {
this.paramsFiles = paramsFiles
}

private transformAndSetChanges(data: ExperimentsOutput) {
this.columnsChanges = collectChanges(data)
}

private transformAndSetChanges_(data: ExpShowOutput) {
this.columnsChanges = collectChanges_(data)
}
Expand Down
12 changes: 4 additions & 8 deletions extension/src/experiments/commands/register.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,7 @@ const registerExperimentNameCommands = (
internalCommands.registerExternalCliCommand(
RegisteredCliCommands.EXPERIMENT_VIEW_APPLY,
({ dvcRoot, id }: ExperimentDetails) =>
experiments.getExpNameThenRun(
AvailableCommands.EXPERIMENT_APPLY,
dvcRoot,
id
)
experiments.runCommand(AvailableCommands.EXPERIMENT_APPLY, dvcRoot, id)
)

internalCommands.registerExternalCliCommand(
Expand Down Expand Up @@ -164,7 +160,7 @@ const registerExperimentInputCommands = (
internalCommands.registerExternalCliCommand(
RegisteredCliCommands.EXPERIMENT_VIEW_BRANCH,
({ dvcRoot, id }: ExperimentDetails) =>
experiments.getExpNameAndInputThenRun(
experiments.getInputAndRun(
getBranchExperimentCommand(experiments),
Title.ENTER_BRANCH_NAME,
dvcRoot,
Expand All @@ -184,7 +180,7 @@ const registerExperimentInputCommands = (
internalCommands.registerExternalCliCommand(
RegisteredCliCommands.EXPERIMENT_VIEW_SHARE_AS_BRANCH,
({ dvcRoot, id }: ExperimentDetails) =>
experiments.getExpNameAndInputThenRun(
experiments.getInputAndRun(
getShareExperimentAsBranchCommand(internalCommands),
Title.ENTER_BRANCH_NAME,
dvcRoot,
Expand All @@ -204,7 +200,7 @@ const registerExperimentInputCommands = (
internalCommands.registerExternalCliCommand(
RegisteredCliCommands.EXPERIMENT_VIEW_SHARE_AS_COMMIT,
({ dvcRoot, id }: ExperimentDetails) =>
experiments.getExpNameAndInputThenRun(
experiments.getInputAndRun(
getShareExperimentAsCommitCommand(internalCommands),
Title.ENTER_COMMIT_MESSAGE,
dvcRoot,
Expand Down
4 changes: 4 additions & 0 deletions extension/src/experiments/data/collect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ export const collectFiles = (
output: ExpShowOutput,
existingFiles: string[]
): string[] => {
if (!output?.length) {
return existingFiles
}

const [workspace] = output

const data = getData_(workspace)
Expand Down
Loading

0 comments on commit cdd871a

Please sign in to comment.