Skip to content

Commit

Permalink
Merge branch 'main' into fix-show-only-changed
Browse files Browse the repository at this point in the history
  • Loading branch information
mattseddon committed Aug 8, 2023
2 parents b125766 + 82628c9 commit cacb4f0
Show file tree
Hide file tree
Showing 34 changed files with 1,979 additions and 909 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

All notable changes to this project will be documented in this file.

## [1.0.35] - 2023-08-08

### 🔨 Maintenance

- Add GIT_OPTIONAL_LOCKS=0 to all Git calls [#4440](https://github.com/iterative/vscode-dvc/pull/4440) by [@mattseddon](https://github.com/mattseddon)
- Reduce calls to Git (Setup webview) [#4441](https://github.com/iterative/vscode-dvc/pull/4441) by [@mattseddon](https://github.com/mattseddon)

## [1.0.34] - 2023-08-07

### 🚀 New Features and Enhancements
Expand Down
2 changes: 1 addition & 1 deletion demo
Submodule demo updated 1 files
+2 −2 requirements.txt
14 changes: 7 additions & 7 deletions extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"extensionDependencies": [
"vscode.git"
],
"version": "1.0.34",
"version": "1.0.35",
"license": "Apache-2.0",
"readme": "./README.md",
"repository": {
Expand Down Expand Up @@ -1705,7 +1705,7 @@
"vscode-languageclient": "8.1.0"
},
"devDependencies": {
"@swc/core": "1.3.72",
"@swc/core": "1.3.73",
"@swc/jest": "0.2.27",
"@types/chai": "4.3.5",
"@types/chai-as-promised": "7.1.5",
Expand All @@ -1729,10 +1729,10 @@
"@types/vscode": "1.64.0",
"@vscode/test-electron": "2.3.4",
"@vscode/vsce": "2.20.0",
"@wdio/cli": "8.13.14",
"@wdio/local-runner": "8.13.13",
"@wdio/mocha-framework": "8.13.13",
"@wdio/spec-reporter": "8.12.2",
"@wdio/cli": "8.14.2",
"@wdio/local-runner": "8.14.2",
"@wdio/mocha-framework": "8.14.0",
"@wdio/spec-reporter": "8.14.0",
"chai": "4.3.7",
"chai-as-promised": "7.1.1",
"clean-webpack-plugin": "4.0.0",
Expand All @@ -1749,7 +1749,7 @@
"ts-loader": "9.4.4",
"vscode-uri": "3.0.7",
"wdio-vscode-service": "5.2.1",
"webdriverio": "8.13.13",
"webdriverio": "8.14.2",
"webpack": "5.88.2",
"webpack-cli": "5.1.4"
},
Expand Down
2 changes: 1 addition & 1 deletion extension/src/cli/dvc/contract.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Plot } from '../../plots/webview/contract'

export const MIN_CLI_VERSION = '2.58.1'
export const LATEST_TESTED_CLI_VERSION = '3.12.0'
export const LATEST_TESTED_CLI_VERSION = '3.13.2'

type ErrorContents = { type: string; msg: string }

Expand Down
2 changes: 1 addition & 1 deletion extension/src/cli/git/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const getOptions = ({
}

if (env) {
options.env = env
options.env = { ...env, GIT_OPTIONAL_LOCKS: '0' }
}

return options
Expand Down
2 changes: 1 addition & 1 deletion extension/src/cli/git/reader.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ describe('GitReader', () => {
expect(mockedCreateProcess).toHaveBeenCalledWith({
args: ['branch'],
cwd,
env: { LANG: 'en_US.UTF-8' },
env: { GIT_OPTIONAL_LOCKS: '0', LANG: 'en_US.UTF-8' },
executable: 'git'
})
})
Expand Down
8 changes: 1 addition & 7 deletions extension/src/experiments/columns/collect/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { join } from 'path'
import get from 'lodash.get'
import isEqual from 'lodash.isequal'
import { ColumnAccumulator } from './util'
import { collectDepChanges, collectDeps } from './deps'
Expand All @@ -8,13 +7,13 @@ import {
collectMetricsAndParams
} from './metricsAndParams'
import { Column, ColumnType, Commit, Experiment } from '../../webview/contract'
import { getValue } from '../util'
import {
ExpRange,
ExpShowOutput,
ExpState,
ExpData,
experimentHasError,
Value,
EXPERIMENT_WORKSPACE_ID
} from '../../../cli/dvc/contract'
import { standardizePath } from '../../../fileSystem/path'
Expand Down Expand Up @@ -141,11 +140,6 @@ export const collectRelativeMetricsFiles = (
return uniqueValues(files)
}

const getValue = (
experiment: Commit | Experiment,
pathArray: string[]
): Value => get(experiment, pathArray) as Value

const collectChangedPath = (
acc: string[],
path: string,
Expand Down
4 changes: 2 additions & 2 deletions extension/src/experiments/columns/like.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ export const addStarredToColumns = (
}

return [
starredColumnLike,
...columns.map(({ label, path, firstValueType }) => ({
firstValueType,
label,
path
})),
starredColumnLike
}))
]
}
46 changes: 46 additions & 0 deletions extension/src/experiments/columns/util.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { getValue } from './util'
import rowsFixture from '../../test/fixtures/expShow/base/rows'
import columnsFixture from '../../test/fixtures/expShow/base/columns'
import { ColumnType } from '../webview/contract'

describe('getValue', () => {
const experiment = rowsFixture[0]

const getPathArrayFromType = (columnType: ColumnType) => {
const column = columnsFixture.find(
({ type, hasChildren }) => type === columnType && !hasChildren
)

if (!column) {
throw new Error('column not defined')
}
const { pathArray } = column
expect(pathArray).toBeDefined()
if (!pathArray) {
throw new Error('pathArray not defined')
}
return pathArray
}

it('should return the expected value for an experiment given a metric', () => {
const pathArray = getPathArrayFromType(ColumnType.METRICS)
expect(getValue(experiment, pathArray)).toStrictEqual(1.775016188621521)
})

it('should return the expected value for an experiment given a param', () => {
const pathArray = getPathArrayFromType(ColumnType.PARAMS)
expect(getValue(experiment, pathArray)).toStrictEqual([0, 1])
})

it('should return the expected value for an experiment given a dep', () => {
const pathArray = getPathArrayFromType(ColumnType.DEPS)
expect(getValue(experiment, pathArray)).toStrictEqual('22a1a29')
})

it('should not mutate the original array', () => {
const pathArray = getPathArrayFromType(ColumnType.DEPS)
const copy = [...pathArray]
getValue(experiment, pathArray)
expect(pathArray).toStrictEqual(copy)
})
})
11 changes: 10 additions & 1 deletion extension/src/experiments/columns/util.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ColumnType } from '../webview/contract'
import get from 'lodash.get'
import { ColumnType, Experiment } from '../webview/contract'

export const MAX_SUMMARY_ORDER_LENGTH = 3

Expand Down Expand Up @@ -27,3 +28,11 @@ export const limitSummaryOrder = (acc: SummaryAcc): string[] => [
...acc.params.slice(0, MAX_SUMMARY_ORDER_LENGTH),
...acc.metrics.slice(0, MAX_SUMMARY_ORDER_LENGTH)
]

export const getValue = (experiment: Experiment, pathArray: string[]) => {
const copy = [...pathArray]
if (pathArray[0] === String(ColumnType.DEPS)) {
copy.push('value')
}
return get(experiment, copy) as string | number | boolean
}
26 changes: 25 additions & 1 deletion extension/src/experiments/model/filterBy/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { join } from 'path'
import { FilterDefinition, filterExperiment, Operator } from '.'
import { buildMetricOrParamPath } from '../../columns/paths'
import rowsFixture from '../../../test/fixtures/expShow/base/rows'
import { buildDepPath, buildMetricOrParamPath } from '../../columns/paths'
import { Experiment, ColumnType } from '../../webview/contract'

describe('filterExperiment', () => {
Expand Down Expand Up @@ -268,4 +270,26 @@ describe('filterExperiment', () => {

expect(unfiltered.map(experiment => experiment.id)).toStrictEqual([])
})

it('should correctly filter using a dep', () => {
const path = join('data', 'data.xml')
const depPath = buildDepPath(path)

const experiment = rowsFixture[0]
const value = experiment.deps?.[join('data', 'data.xml')]?.value
expect(value).toBeDefined()

const unfiltered = filterExperiment(
[{ operator: Operator.EQUAL, path: depPath, value }],
experiment
)
expect(unfiltered).toStrictEqual(experiment)

expect(
filterExperiment(
[{ operator: Operator.NOT_EQUAL, path: depPath, value }],
experiment
)
).toBeUndefined()
})
})
4 changes: 2 additions & 2 deletions extension/src/experiments/model/filterBy/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import get from 'lodash.get'
import { compareDateStrings } from './date'
import { Experiment } from '../../webview/contract'
import { definedAndNonEmpty } from '../../../util/array'
import { splitColumnPath } from '../../columns/paths'
import { getValue } from '../../columns/util'

export enum Operator {
EQUAL = '=',
Expand Down Expand Up @@ -112,7 +112,7 @@ const buildFilter =
experiment => {
const firstFailure = filterDefinitions.find(filter => {
const pathArray = splitColumnPath(filter.path)
const value = get(experiment, pathArray) as string | number | boolean
const value = getValue(experiment, pathArray)

return !evaluate<typeof value>(
value,
Expand Down
2 changes: 1 addition & 1 deletion extension/src/experiments/model/filterBy/quickPick.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ export const pickColumnToFilter = (
columns: ColumnLike[] | undefined
): Thenable<ColumnLike | undefined> =>
pickFromColumnLikes(columns, {
title: Title.SELECT_PARAM_OR_METRIC_FILTER
title: Title.SELECT_COLUMN_FILTER
})

export const pickFilterToAdd = async ({
Expand Down
42 changes: 41 additions & 1 deletion extension/src/experiments/model/sortBy/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import get from 'lodash.get'
import { sortExperiments } from '.'
import { buildMetricOrParamPath } from '../../columns/paths'
import { buildDepPath, buildMetricOrParamPath } from '../../columns/paths'
import { Experiment, ColumnType } from '../../webview/contract'

describe('sortExperiments', () => {
Expand Down Expand Up @@ -253,4 +253,44 @@ describe('sortExperiments', () => {
])
})
})

it('should reorder experiments when provided a dep', () => {
const testData = [
{
...irrelevantExperimentData,
deps: {
'train.py': {
changes: true,
value: 'e804f48'
}
}
},
{
...irrelevantExperimentData,
deps: {
'train.py': {
changes: true,
value: 'e804f41'
}
}
},
{
...irrelevantExperimentData,
deps: {
'train.py': {
changes: true,
value: 'fd5998e'
}
}
}
]

const result = sortExperiments(
[{ descending: true, path: buildDepPath('train.py') }],
testData
)
expect(
result.map(experiment => get(experiment, ['deps', 'train.py', 'value']))
).toStrictEqual(['fd5998e', 'e804f48', 'e804f41'])
})
})
8 changes: 4 additions & 4 deletions extension/src/experiments/model/sortBy/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import get from 'lodash.get'
import { splitColumnPath } from '../../columns/paths'
import { Experiment } from '../../webview/contract'
import { getValue } from '../../columns/util'

export interface SortDefinition {
descending: boolean
Expand All @@ -10,12 +10,12 @@ export interface SortDefinition {
type SortFunction = (a: Experiment, b: Experiment) => number

const compareExperimentsByPath = (
path: string[],
pathArray: string[],
a: Experiment,
b: Experiment
): number => {
const valueA = get(a, path) as string | number
const valueB = get(b, path) as string | number
const valueA = getValue(a, pathArray) as string | number
const valueB = getValue(b, pathArray) as string | number
if (valueA === valueB) {
return 0
}
Expand Down
2 changes: 1 addition & 1 deletion extension/src/experiments/model/sortBy/quickPick.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { pickFromColumnLikes } from '../../columns/quickPick'

export const pickSortToAdd = async (columns: ColumnLike[] | undefined) => {
const picked = await pickFromColumnLikes(columns, {
title: Title.SELECT_PARAM_OR_METRIC_SORT
title: Title.SELECT_COLUMN_SORT
})
if (picked === undefined) {
return
Expand Down
Loading

0 comments on commit cacb4f0

Please sign in to comment.