-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a mapping from revision to branches while using only one exp show call #3980
Changes from 25 commits
04ce0b0
7cda324
e95a418
b54b8af
0dc0ac0
bfe1819
0f4a7d2
e649971
99e1334
364c6de
d9dc99a
1a88bde
73c9a29
1d38dfa
ed6e81c
2d87949
f14c017
8f76d4c
2fd16d5
53e1eda
dc851f7
5c08bfc
06acc91
fe8d5cf
ba12bde
9002047
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,15 +49,19 @@ export class GitReader extends GitCli { | |
return !output | ||
} | ||
|
||
public async getCommitMessages(cwd: string, sha: string): Promise<string> { | ||
public async getCommitMessages( | ||
cwd: string, | ||
revision: string, | ||
revisions: string | ||
): Promise<string> { | ||
const options = getOptions( | ||
cwd, | ||
Command.LOG, | ||
sha, | ||
revision, | ||
Flag.PRETTY_FORMAT_COMMIT_MESSAGE, | ||
Flag.SEPARATE_WITH_NULL, | ||
Flag.NUMBER, | ||
'1' | ||
revisions | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [F] Now we're getting the logs in fewer calls to git. This does include merge commits. We might want to get rid of those later. |
||
) | ||
try { | ||
return await this.executeProcess(options) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,8 +9,14 @@ import { uniqueValues } from '../util/array' | |
import { DeferredDisposable } from '../class/deferred' | ||
import { isSameOrChild } from '../fileSystem' | ||
|
||
export type ExperimentsOutput = { | ||
expShow: ExpShowOutput | ||
rowOrder: { branch: string; sha: string }[] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [F] |
||
gitLog: string | ||
} | ||
|
||
export abstract class BaseData< | ||
T extends { data: PlotsOutputOrError; revs: string[] } | ExpShowOutput | ||
T extends { data: PlotsOutputOrError; revs: string[] } | ExperimentsOutput | ||
> extends DeferredDisposable { | ||
public readonly onDidUpdate: Event<T> | ||
public readonly onDidChangeDvcYaml: Event<void> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,7 +33,7 @@ import { DecorationProvider } from './model/decorationProvider' | |
import { starredFilter } from './model/filterBy/constants' | ||
import { ResourceLocator } from '../resourceLocator' | ||
import { AvailableCommands, InternalCommands } from '../commands/internal' | ||
import { EXPERIMENT_WORKSPACE_ID, ExpShowOutput } from '../cli/dvc/contract' | ||
import { ExperimentsOutput } from '../data' | ||
import { ViewKey } from '../webview/constants' | ||
import { BaseRepository } from '../webview/repository' | ||
import { Title } from '../vscode/title' | ||
|
@@ -43,7 +43,6 @@ import { Toast } from '../vscode/toast' | |
import { ConfigKey } from '../vscode/config' | ||
import { checkSignalFile, pollSignalFileForProcess } from '../fileSystem' | ||
import { DVCLIVE_ONLY_RUNNING_SIGNAL_FILE } from '../cli/dvc/constants' | ||
import { COMMITS_SEPARATOR } from '../cli/git/constants' | ||
|
||
export const ExperimentsScale = { | ||
...omit(ColumnType, 'TIMESTAMP'), | ||
|
@@ -169,13 +168,12 @@ export class Experiments extends BaseRepository<TableData> { | |
return this.data.managedUpdate() | ||
} | ||
|
||
public async setState(data: ExpShowOutput) { | ||
public async setState({ expShow, gitLog, rowOrder }: ExperimentsOutput) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [I] There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've got an item on the board to follow up and do this but will do it next. |
||
const hadCheckpoints = this.hasCheckpoints() | ||
const dvcLiveOnly = await this.checkSignalFile() | ||
const commitsOutput = await this.getCommitOutput(data) | ||
await Promise.all([ | ||
this.columns.transformAndSet(data), | ||
this.experiments.transformAndSet(data, dvcLiveOnly, commitsOutput) | ||
this.columns.transformAndSet(expShow), | ||
this.experiments.transformAndSet(expShow, gitLog, dvcLiveOnly, rowOrder) | ||
]) | ||
|
||
if (hadCheckpoints !== this.hasCheckpoints()) { | ||
|
@@ -538,25 +536,6 @@ export class Experiments extends BaseRepository<TableData> { | |
return this.webviewMessages.sendWebviewMessage() | ||
} | ||
|
||
private async getCommitOutput(data: ExpShowOutput | undefined) { | ||
if (!data || data.length === 0) { | ||
return | ||
} | ||
let output = '' | ||
for (const commit of data) { | ||
if (commit.rev === EXPERIMENT_WORKSPACE_ID) { | ||
continue | ||
} | ||
output += await this.internalCommands.executeCommand( | ||
AvailableCommands.GIT_GET_COMMIT_MESSAGES, | ||
this.dvcRoot, | ||
commit.rev | ||
) | ||
output += COMMITS_SEPARATOR | ||
} | ||
return output | ||
} | ||
|
||
private createWebviewMessageHandler() { | ||
const webviewMessages = new WebviewMessages( | ||
this.dvcRoot, | ||
|
@@ -596,7 +575,7 @@ export class Experiments extends BaseRepository<TableData> { | |
} | ||
|
||
return await pickExperiment( | ||
this.experiments.getUniqueList(), | ||
this.experiments.getCombinedList(), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [F] This name had to change as the old name was misleading (data is no longer duplicated) |
||
this.getFirstThreeColumnOrder(), | ||
Title.SELECT_BASE_EXPERIMENT | ||
) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,91 +1,64 @@ | ||
import { collectExperiments } from './collect' | ||
import { COMMITS_SEPARATOR } from '../../cli/git/constants' | ||
import { generateTestExpShowOutput } from '../../test/util/experiments' | ||
import { ExpShowOutput } from '../../cli/dvc/contract' | ||
|
||
const DEFAULT_DATA: [string, boolean] = ['', false] | ||
|
||
describe('collectExperiments', () => { | ||
it('should return an empty array if no commits are present', () => { | ||
const { commits } = collectExperiments( | ||
generateTestExpShowOutput({}), | ||
false, | ||
'' | ||
...DEFAULT_DATA | ||
) | ||
expect(commits).toStrictEqual([]) | ||
}) | ||
|
||
const expShowWithTwoCommits = generateTestExpShowOutput( | ||
{}, | ||
{ | ||
experiments: [{}, {}], | ||
name: 'branchA', | ||
rev: '61bed4ce8913eca7f73ca754d65bc5daad1520e2' | ||
}, | ||
{ | ||
name: 'branchB', | ||
rev: '351e42ace3cb6a3a853c65bef285e60748cc6341' | ||
} | ||
) | ||
const expShowWithTwoCommits: [ExpShowOutput, string, boolean] = [ | ||
generateTestExpShowOutput( | ||
{}, | ||
{ | ||
experiments: [{}, {}], | ||
name: 'branchA', | ||
rev: '61bed4ce8913eca7f73ca754d65bc5daad1520e2' | ||
}, | ||
{ | ||
name: 'branchB', | ||
rev: '351e42ace3cb6a3a853c65bef285e60748cc6341' | ||
} | ||
), | ||
...DEFAULT_DATA | ||
] | ||
|
||
it('should define a workspace', () => { | ||
const { workspace } = collectExperiments(expShowWithTwoCommits, false, '') | ||
const { workspace } = collectExperiments(...expShowWithTwoCommits) | ||
|
||
expect(workspace).toBeDefined() | ||
}) | ||
|
||
it('should find two branches from a repo with two branches', () => { | ||
const { commits } = collectExperiments(expShowWithTwoCommits, false, '') | ||
const { commits } = collectExperiments(...expShowWithTwoCommits) | ||
|
||
expect(commits.length).toStrictEqual(2) | ||
}) | ||
|
||
it('should list commits in the same order as they are collected', () => { | ||
const { commits } = collectExperiments(expShowWithTwoCommits, false, '') | ||
const { commits } = collectExperiments(...expShowWithTwoCommits) | ||
const [commitA, commitB] = commits | ||
|
||
expect(commitA.id).toStrictEqual('branchA') | ||
expect(commitB.id).toStrictEqual('branchB') | ||
}) | ||
|
||
it('should find two experiments on commitA', () => { | ||
const { experimentsByCommit } = collectExperiments( | ||
expShowWithTwoCommits, | ||
false, | ||
'' | ||
) | ||
const { experimentsByCommit } = collectExperiments(...expShowWithTwoCommits) | ||
expect(experimentsByCommit.get('branchA')?.length).toStrictEqual(2) | ||
}) | ||
|
||
it('should find no experiments on branchB', () => { | ||
const { experimentsByCommit } = collectExperiments( | ||
expShowWithTwoCommits, | ||
false, | ||
'' | ||
) | ||
const { experimentsByCommit } = collectExperiments(...expShowWithTwoCommits) | ||
expect(experimentsByCommit.get('branchB')).toBeUndefined() | ||
}) | ||
|
||
it('should add data from git to commits if git log output is provided', () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be a test to recreate but after a call to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. covered by the integration tests/ |
||
const { commits } = collectExperiments( | ||
expShowWithTwoCommits, | ||
false, | ||
`61bed4ce8913eca7f73ca754d65bc5daad1520e2\nJohn Smith\n3 days ago\nrefNames:tag: v.1.1\nmessage:add new feature${COMMITS_SEPARATOR}351e42ace3cb6a3a853c65bef285e60748cc6341\nrenovate[bot]\n5 weeks ago\nrefNames:\nmessage:update various dependencies\n* update dvc\n* update dvclive` | ||
) | ||
const [branch1, branch2] = commits | ||
expect(branch1.description).toStrictEqual('add new feature') | ||
expect(branch2.description).toStrictEqual('update various dependencies ...') | ||
expect(branch1.commit).toStrictEqual({ | ||
author: 'John Smith', | ||
date: '3 days ago', | ||
message: 'add new feature', | ||
tags: ['v.1.1'] | ||
}) | ||
expect(branch2.commit).toStrictEqual({ | ||
author: 'renovate[bot]', | ||
date: '5 weeks ago', | ||
message: 'update various dependencies\n* update dvc\n* update dvclive', | ||
tags: [] | ||
}) | ||
}) | ||
|
||
it('should not collect the same experiment twice', () => { | ||
const main = { | ||
experiments: [ | ||
|
@@ -114,8 +87,7 @@ describe('collectExperiments', () => { | |
|
||
const { experimentsByCommit, commits } = collectExperiments( | ||
expShowWithDuplicateCommits, | ||
false, | ||
'' | ||
...DEFAULT_DATA | ||
) | ||
|
||
expect(commits.length).toStrictEqual(3) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor: Should the
revisions
be anumber
instead of astring
then we change the type to string in thegetOptions
call below?