Skip to content

Commit

Permalink
Merge branch 'main' into export-raw-data-from-plots
Browse files Browse the repository at this point in the history
  • Loading branch information
julieg18 authored Jul 5, 2023
2 parents 522b5b3 + 51991e6 commit 6a750b3
Show file tree
Hide file tree
Showing 67 changed files with 1,475 additions and 1,289 deletions.
32 changes: 32 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,38 @@

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

## [1.0.12] - 2023-07-03

### 🚀 New Features and Enhancements

- Update plot smooth control background color [#4202](https://github.com/iterative/vscode-dvc/pull/4202) by [@julieg18](https://github.com/julieg18)

### 🐛 Bug Fixes

- Fix table webview stuck on error page [#4179](https://github.com/iterative/vscode-dvc/pull/4179) by [@julieg18](https://github.com/julieg18)
- Fix unresolved promises in local e2e tests [#4195](https://github.com/iterative/vscode-dvc/pull/4195) by [@julieg18](https://github.com/julieg18)

### 🔨 Maintenance

- Add CSS selector & variable naming rules [#4162](https://github.com/iterative/vscode-dvc/pull/4162) by [@julieg18](https://github.com/julieg18)
- Update latest tested version to `3.2.3` [#4197](https://github.com/iterative/vscode-dvc/pull/4197) by [@julieg18](https://github.com/julieg18)
- Update demo project and latest tested CLI version (3.3.1) [#4204](https://github.com/iterative/vscode-dvc/pull/4204) by [@mattseddon](https://github.com/mattseddon)

## [1.0.11] - 2023-06-26

### 🚀 New Features and Enhancements

- Use first three metrics and params in table tooltips & quick picks [#4155](https://github.com/iterative/vscode-dvc/pull/4155) by [@julieg18](https://github.com/julieg18)

### 🐛 Bug Fixes

- Handle Git not being installed (Setup) [#4165](https://github.com/iterative/vscode-dvc/pull/4165) by [@mattseddon](https://github.com/mattseddon)

### 🔨 Maintenance

- Further reduce the number of calls to Git [#4163](https://github.com/iterative/vscode-dvc/pull/4163) by [@mattseddon](https://github.com/mattseddon)
- Bypass process manager debounce in refresh plot revisions tests [#4166](https://github.com/iterative/vscode-dvc/pull/4166) by [@mattseddon](https://github.com/mattseddon)

## [1.0.10] - 2023-06-21

### 🚀 New Features and Enhancements
Expand Down
2 changes: 1 addition & 1 deletion demo
Submodule demo updated 1 files
+2 −2 requirements.txt
10 changes: 5 additions & 5 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.10",
"version": "1.0.12",
"license": "Apache-2.0",
"readme": "./README.md",
"repository": {
Expand Down Expand Up @@ -1658,7 +1658,7 @@
"vscode-languageclient": "8.1.0"
},
"devDependencies": {
"@swc/core": "1.3.64",
"@swc/core": "1.3.66",
"@swc/jest": "0.2.26",
"@types/chai": "4.3.5",
"@types/chai-as-promised": "7.1.5",
Expand Down Expand Up @@ -1693,17 +1693,17 @@
"fork-ts-checker-webpack-plugin": "8.0.0",
"jest": "29.5.0",
"jest-environment-node": "29.5.0",
"lint-staged": "13.2.2",
"lint-staged": "13.2.3",
"mocha": "10.2.0",
"mock-require": "3.0.3",
"shx": "0.3.4",
"sinon": "15.1.2",
"sinon": "15.2.0",
"sinon-chai": "3.7.0",
"ts-loader": "9.4.3",
"vscode-uri": "3.0.7",
"wdio-vscode-service": "5.1.0",
"webdriverio": "8.11.2",
"webpack": "5.87.0",
"webpack": "5.88.0",
"webpack-cli": "5.1.4"
},
"peerDependencies": {
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.1.0'
export const LATEST_TESTED_CLI_VERSION = '3.3.1'

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

Expand Down
3 changes: 2 additions & 1 deletion extension/src/cli/git/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ export enum Command {
LS_REMOTE = 'ls-remote',
RESET = 'reset',
REV_PARSE = 'rev-parse',
REV_LIST = 'rev-list'
REV_LIST = 'rev-list',
VERSION = 'version'
}

export enum Flag {
Expand Down
5 changes: 5 additions & 0 deletions extension/src/cli/git/executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ export class GitExecutor extends GitCli {

public async stageAll(cwd: string) {
const gitRoot = await this.getGitRepositoryRoot(cwd)

if (!gitRoot) {
return
}

const options = getOptions({ args: [Command.ADD, Flag.DOT], cwd: gitRoot })

return this.executeProcess(options)
Expand Down
5 changes: 4 additions & 1 deletion extension/src/cli/git/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ export class GitCli extends Cli {
cwd
})

return standardizePath(await this.executeProcess(options))
try {
const path = await this.executeProcess(options)
return standardizePath(path)
} catch {}
}
}
51 changes: 11 additions & 40 deletions extension/src/cli/git/reader.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Disposable, Disposer } from '@hediet/std/disposable'
import { GitReader } from './reader'
import { CliResult, CliStarted } from '..'
import { createProcess } from '../../process/execution'
import { getMockedProcess } from '../../test/util/jest'
import { getFailingMockedProcess, getMockedProcess } from '../../test/util/jest'

jest.mock('vscode')
jest.mock('@hediet/std/disposable')
Expand Down Expand Up @@ -70,59 +70,30 @@ describe('GitReader', () => {
})
})

describe('getCurrentBranch', () => {
it('should match the expected output', async () => {
describe('version', () => {
it('should return the expected output', async () => {
const cwd = __dirname
const branches = ['* main', 'exp-12', 'fix-bug-11', 'other']
mockedCreateProcess.mockReturnValueOnce(
getMockedProcess(branches.join('\n'))
getMockedProcess('git version 2.41.0')
)

const cliOutput = await gitReader.getCurrentBranch(cwd)
expect(cliOutput).toStrictEqual('main')
const cliOutput = await gitReader.gitVersion(cwd)
expect(cliOutput).toBeDefined()
expect(mockedCreateProcess).toHaveBeenCalledWith({
args: ['branch'],
args: ['version'],
cwd,
env: { LANG: 'en_US.UTF-8' },
executable: 'git'
})
})

it('should match the expected output for detached HEAD', async () => {
it('should not fail if git is not available', async () => {
const cwd = __dirname
const branches = [
'* (HEAD detached at 4d06da1b)',
'main',
'fix-bug-11',
'other'
]
mockedCreateProcess.mockReturnValueOnce(
getMockedProcess(branches.join('\n'))
getFailingMockedProcess('git is not available')
)

const cliOutput = await gitReader.getCurrentBranch(cwd)
expect(cliOutput).toStrictEqual('4d06da1b')
})

it('should return an empty string if the current branch cannot be found', async () => {
const cwd = __dirname
const branches = ['main', 'fix-bug-11', 'other']
mockedCreateProcess.mockReturnValueOnce(
getMockedProcess(branches.join('\n'))
)

const cliOutput = await gitReader.getCurrentBranch(cwd)
expect(cliOutput).toStrictEqual('')
})

it('should return an empty string if the cli returns any type of error', async () => {
const cwd = __dirname
mockedCreateProcess.mockImplementationOnce(() => {
throw new Error('unexpected error - something something')
})

const cliOutput = await gitReader.getCurrentBranch(cwd)
expect(cliOutput).toStrictEqual('')
const cliOutput = await gitReader.gitVersion(cwd)
expect(cliOutput).toBeUndefined()
})
})
})
40 changes: 11 additions & 29 deletions extension/src/cli/git/reader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ import { isDirectory } from '../../fileSystem'
export const autoRegisteredCommands = {
GIT_GET_BRANCHES: 'getBranches',
GIT_GET_COMMIT_MESSAGES: 'getCommitMessages',
GIT_GET_CURRENT_BRANCH: 'getCurrentBranch',
GIT_GET_NUM_COMMITS: 'getNumCommits',
GIT_GET_REMOTE_URL: 'getRemoteUrl',
GIT_GET_REPOSITORY_ROOT: 'getGitRepositoryRoot',
GIT_HAS_CHANGES: 'hasChanges',
GIT_HAS_NO_COMMITS: 'hasNoCommits',
GIT_LIST_UNTRACKED: 'listUntracked'
GIT_LIST_UNTRACKED: 'listUntracked',
GIT_VERSION: 'gitVersion'
} as const

export class GitReader extends GitCli {
Expand All @@ -39,9 +39,10 @@ export class GitReader extends GitCli {
args: [Command.REV_LIST, Flag.NUMBER, '1', Flag.ALL],
cwd
})
const output = await this.executeProcess(options)

return !output
try {
const output = await this.executeProcess(options)
return !output
} catch {}
}

public async getCommitMessages(
Expand Down Expand Up @@ -105,29 +106,17 @@ export class GitReader extends GitCli {
})
try {
const branches = await this.executeProcess(options)
return trimAndSplit(branches).map(branch =>
this.cleanUpBranchName(branch)
)
return trimAndSplit(branches)
} catch {
return []
}
}

public async getCurrentBranch(cwd: string): Promise<string> {
const options = getOptions({
args: [Command.BRANCH],
cwd,
env: { LANG: 'en_US.UTF-8' }
})
public async gitVersion(cwd: string) {
try {
const branches = await this.executeProcess(options)
const currentBranch = trimAndSplit(branches).find(
branch => branch.indexOf('*') === 0
)
return (currentBranch && this.cleanUpBranchName(currentBranch)) || ''
} catch {
return ''
}
const options = getOptions({ args: [Command.VERSION], cwd })
return await this.executeProcess(getOptions(options))
} catch {}
}

private async getUntrackedDirectories(cwd: string): Promise<string[]> {
Expand Down Expand Up @@ -161,11 +150,4 @@ export class GitReader extends GitCli {
private getUris(repositoryRoot: string, relativePaths: string[]) {
return relativePaths.map(path => resolve(repositoryRoot, path))
}

private cleanUpBranchName(branch: string) {
return branch
.replace('* ', '')
.replace(/\(HEAD\s\w+\s\w+\s/, '')
.replace(')', '')
}
}
38 changes: 27 additions & 11 deletions extension/src/experiments/columns/model.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,14 +258,16 @@ describe('ColumnsModel', () => {
expect(model.getColumnOrder()).toStrictEqual(persistedState)
})

it('should return the first three none hidden columns (minus created) from the persisted state', async () => {
it('should return the first three visible columns for both metrics and params from the persisted state', async () => {
const persistedState = [
'id',
'Created',
'params:params.yaml:dvc_logs_dir',
'params:params.yaml:process.threshold',
'params:params.yaml:process.test_arg',
'params:params.yaml:dropout',
'metrics:summary.json:loss',
'metrics:summary.json:accuracy',
'deps:src/prepare.py',
'deps:src/featurization.py'
]
Expand All @@ -280,34 +282,48 @@ describe('ColumnsModel', () => {
)
await model.transformAndSet(outputFixture)

expect(model.getFirstThreeColumnOrder()).toStrictEqual(
persistedState.slice(2, 5)
)
expect(model.getSummaryColumnOrder()).toStrictEqual([
'params:params.yaml:dvc_logs_dir',
'params:params.yaml:process.threshold',
'params:params.yaml:process.test_arg',
'metrics:summary.json:loss',
'metrics:summary.json:accuracy'
])

model.toggleStatus('params:params.yaml:dvc_logs_dir')

expect(model.getFirstThreeColumnOrder()).toStrictEqual(
persistedState.slice(3, 6)
)
expect(model.getSummaryColumnOrder()).toStrictEqual([
'params:params.yaml:process.threshold',
'params:params.yaml:process.test_arg',
'params:params.yaml:dropout',
'metrics:summary.json:loss',
'metrics:summary.json:accuracy'
])
})

it('should return the first three none hidden columns (minus created) collected from data if state is empty', async () => {
it('should return the first three metric and param columns (none hidden) collected from data if state is empty', async () => {
const model = new ColumnsModel(
exampleDvcRoot,
buildMockMemento(),
mockedColumnsOrderOrStatusChanged
)
await model.transformAndSet(outputFixture)

expect(model.getFirstThreeColumnOrder()).toStrictEqual([
expect(model.getSummaryColumnOrder()).toStrictEqual([
'params:params.yaml:code_names',
'params:params.yaml:epochs',
'params:params.yaml:learning_rate',
'metrics:summary.json:loss',
'metrics:summary.json:accuracy',
'metrics:summary.json:val_loss'
])

model.toggleStatus('Created')
model.toggleStatus('params:params.yaml:code_names')

expect(model.getFirstThreeColumnOrder()).toStrictEqual([
expect(model.getSummaryColumnOrder()).toStrictEqual([
'params:params.yaml:epochs',
'params:params.yaml:learning_rate',
'params:params.yaml:dvc_logs_dir',
'metrics:summary.json:loss',
'metrics:summary.json:accuracy',
'metrics:summary.json:val_loss'
Expand Down
23 changes: 16 additions & 7 deletions extension/src/experiments/columns/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
collectParamsFiles
} from './collect'
import { EXPERIMENT_COLUMN_ID, timestampColumn } from './constants'
import { SummaryAcc, collectFromColumnOrder } from './util'
import { Column, ColumnType } from '../webview/contract'
import { ExpShowOutput } from '../../cli/dvc/contract'
import { PersistenceKey } from '../../persistence/constants'
Expand Down Expand Up @@ -44,13 +45,21 @@ export class ColumnsModel extends PathSelectionModel<Column> {
return this.columnOrderState
}

public getFirstThreeColumnOrder(): string[] {
return this.columnOrderState
.filter(
path =>
this.status[path] && this.status[path] === 2 && path !== 'Created'
)
.slice(0, 3)
public getSummaryColumnOrder(): string[] {
const acc: SummaryAcc = { metrics: [], params: [] }
for (const path of this.columnOrderState) {
const reachedMaxSummaryOrderLength =
acc.metrics.length >= 3 && acc.params.length >= 3
if (
this.status[path] !== Status.SELECTED ||
reachedMaxSummaryOrderLength
) {
continue
}
collectFromColumnOrder(path, acc)
}

return [...acc.params.slice(0, 3), ...acc.metrics.slice(0, 3)]
}

public getColumnWidths(): Record<string, number> {
Expand Down
Loading

0 comments on commit 6a750b3

Please sign in to comment.