Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,12 @@
"category": "DVC",
"icon": "$(repo-push)"
},
{
"title": "%command.shareExperimentAsCommit%",
"command": "dvc.shareExperimentAsCommit",
"category": "DVC",
"icon": "$(repo-push)"
},
{
"title": "%command.showCommands",
"command": "dvc.showCommands",
Expand Down Expand Up @@ -757,6 +763,10 @@
"command": "dvc.shareExperimentAsBranch",
"when": "dvc.commands.available && dvc.project.available && !dvc.experiment.running"
},
{
"command": "dvc.shareExperimentAsCommit",
"when": "dvc.commands.available && dvc.project.available && !dvc.experiment.running"
},
{
"command": "dvc.showExperiments",
"when": "dvc.commands.available && dvc.project.available"
Expand Down
1 change: 1 addition & 0 deletions extension/package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
"command.selectForCompare": "Select for Compare",
"command.setupWorkspace": "Setup The Workspace",
"command.shareExperimentAsBranch": "Share Experiment as Branch",
"command.shareExperimentAsCommit": "Commit and Share Experiment",
"command.showCommands": "Show Commands",
"command.showExperiments": "Show Experiments",
"command.showOutput": "Show DVC Output",
Expand Down
1 change: 1 addition & 0 deletions extension/src/commands/external.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export enum RegisteredCliCommands {
EXPERIMENT_RUN_QUEUED = 'dvc.startExperimentsQueue',
EXPERIMENT_RESET_AND_RUN = 'dvc.resetAndRunCheckpointExperiment',
EXPERIMENT_SHARE_AS_BRANCH = 'dvc.shareExperimentAsBranch',
EXPERIMENT_SHARE_AS_COMMIT = 'dvc.shareExperimentAsCommit',
QUEUE_EXPERIMENT = 'dvc.queueExperiment',

EXPERIMENT_VIEW_APPLY = 'dvc.views.experiments.applyExperiment',
Expand Down
9 changes: 9 additions & 0 deletions extension/src/experiments/commands/register.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,15 @@ const registerExperimentInputCommands = (
)
)

internalCommands.registerExternalCliCommand(
RegisteredCliCommands.EXPERIMENT_SHARE_AS_COMMIT,
() =>
experiments.getCwdExpNameAndInputThenRun(
getShareExperimentAsCommitCommand(internalCommands),
Title.ENTER_COMMIT_MESSAGE
)
)

internalCommands.registerExternalCliCommand(
RegisteredCliCommands.EXPERIMENT_VIEW_SHARE_AS_COMMIT,
({ dvcRoot, id }: ExperimentDetails) =>
Expand Down
1 change: 1 addition & 0 deletions extension/src/telemetry/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ export interface IEventNamePropertyMapping {
[EventName.EXPERIMENT_RESET_AND_RUN]: undefined
[EventName.EXPERIMENT_SELECT]: undefined
[EventName.EXPERIMENT_SHARE_AS_BRANCH]: undefined
[EventName.EXPERIMENT_SHARE_AS_COMMIT]: undefined
[EventName.EXPERIMENT_SHOW]: undefined
[EventName.EXPERIMENT_SORT_ADD]: undefined
[EventName.EXPERIMENT_SORT_ADD_STARRED]: undefined
Expand Down
55 changes: 55 additions & 0 deletions extension/src/test/suite/experiments/workspace.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,61 @@ suite('Workspace Experiments Test Suite', () => {
})
})

describe('dvc.shareExperimentAsCommit', () => {
it('should be able to share an experiment as a commit', async () => {
const { experiments } = buildExperiments(disposable)
await experiments.isReady()

const testExperiment = 'exp-83425'
const mockCommit = 'this is the best experiment ever!'
const inputEvent = getInputBoxEvent(mockCommit)

stub(window, 'showQuickPick').resolves({
value: { id: testExperiment, name: testExperiment }
} as QuickPickItemWithValue<{ id: string; name: string }>)

const mockExperimentApply = stub(
DvcExecutor.prototype,
'experimentApply'
).resolves(
`Changes for experiment '${testExperiment}' have been applied to your current workspace.`
)
const mockPush = stub(DvcExecutor.prototype, 'push').resolves(
'191232423 files updated.'
)
const mockStageAndCommit = stub(
GitExecutor.prototype,
'stageAndCommit'
).resolves('')
const mockGitPush = stub(GitExecutor.prototype, 'pushBranch')
const branchPushedToRemote = new Promise(resolve =>
mockGitPush.callsFake(() => {
resolve(undefined)
return Promise.resolve(`${mockCommit} pushed to remote`)
})
)

stubWorkspaceExperimentsGetters(dvcDemoPath, experiments)

await commands.executeCommand(
RegisteredCliCommands.EXPERIMENT_SHARE_AS_COMMIT
)

await inputEvent
await branchPushedToRemote
expect(mockExperimentApply).to.be.calledWithExactly(
dvcDemoPath,
testExperiment
)
expect(mockStageAndCommit).to.be.calledWithExactly(
dvcDemoPath,
mockCommit
)
expect(mockPush).to.be.calledWithExactly(dvcDemoPath)
expect(mockGitPush).to.be.calledWithExactly(dvcDemoPath)
})
})

describe('dvc.removeExperiment', () => {
it('should ask the user to pick an experiment and then remove that experiment from the workspace', async () => {
const mockExperiment = 'exp-to-remove'
Expand Down