diff --git a/extension/package.json b/extension/package.json index 102cde70e4..fbaa91e797 100644 --- a/extension/package.json +++ b/extension/package.json @@ -382,18 +382,6 @@ "command": "dvc.setupWorkspace", "category": "DVC" }, - { - "title": "Share Experiment as Branch", - "command": "dvc.shareExperimentAsBranch", - "category": "DVC", - "icon": "$(repo-push)" - }, - { - "title": "Commit and Share Experiment", - "command": "dvc.shareExperimentAsCommit", - "category": "DVC", - "icon": "$(repo-push)" - }, { "title": "Show Commands", "command": "dvc.showCommands", @@ -517,18 +505,6 @@ "category": "DVC", "icon": "$(play)" }, - { - "title": "Share as Branch", - "command": "dvc.views.experiments.shareExperimentAsBranch", - "category": "DVC", - "icon": "$(repo-push)" - }, - { - "title": "Commit and Share", - "command": "dvc.views.experiments.shareExperimentAsCommit", - "category": "DVC", - "icon": "$(repo-push)" - }, { "title": "Share to Studio", "command": "dvc.views.experiments.shareExperimentToStudio", @@ -846,14 +822,6 @@ "command": "dvc.showCommands", "when": "false" }, - { - "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" @@ -914,14 +882,6 @@ "command": "dvc.views.experiments.resetAndRunCheckpointExperiment", "when": "false" }, - { - "command": "dvc.views.experiments.shareExperimentAsBranch", - "when": "false" - }, - { - "command": "dvc.views.experiments.shareExperimentAsCommit", - "when": "false" - }, { "command": "dvc.views.experiments.shareExperimentToStudio", "when": "false" @@ -1191,16 +1151,6 @@ "group": "1_share@0", "when": "view == dvc.views.experimentsTree && dvc.commands.available && viewItem == experiment && !dvc.experiment.running" }, - { - "command": "dvc.views.experiments.shareExperimentAsCommit", - "group": "1_share@1", - "when": "view == dvc.views.experimentsTree && dvc.commands.available && viewItem == experiment && !dvc.experiment.running" - }, - { - "command": "dvc.views.experiments.shareExperimentAsBranch", - "group": "1_share@2", - "when": "view == dvc.views.experimentsTree && dvc.commands.available && viewItem == experiment && !dvc.experiment.running" - }, { "command": "dvc.views.experiments.runExperiment", "group": "2_modify@1", diff --git a/extension/src/cli/git/constants.ts b/extension/src/cli/git/constants.ts index b630fc0c51..4acea7e092 100644 --- a/extension/src/cli/git/constants.ts +++ b/extension/src/cli/git/constants.ts @@ -13,13 +13,11 @@ export enum Command { ADD = 'add', BRANCH = 'branch', CLEAN = 'clean', - COMMIT = 'commit', DIFF = 'diff', INITIALIZE = 'init', LOG = 'log', LS_FILES = 'ls-files', LS_REMOTE = 'ls-remote', - PUSH = 'push', RESET = 'reset', REV_PARSE = 'rev-parse', REV_LIST = 'rev-list' @@ -35,7 +33,6 @@ export enum Flag { FULL_HISTORY = '--full-history', GET_URL = '--get-url', HARD = '--hard', - MESSAGE = '-m', NAME_ONLY = '--name-only', NO_EMPTY_DIRECTORY = '--no-empty-directory', NO_MERGE = '--no-merge', @@ -45,7 +42,6 @@ export enum Flag { QUIET = '-q', RAW_WITH_NUL = '-z', SEPARATE_WITH_NULL = '-z', - SET_UPSTREAM = '--set-upstream', SHOW_TOPLEVEL = '--show-toplevel' } diff --git a/extension/src/cli/git/executor.test.ts b/extension/src/cli/git/executor.test.ts deleted file mode 100644 index 703188f431..0000000000 --- a/extension/src/cli/git/executor.test.ts +++ /dev/null @@ -1,99 +0,0 @@ -import { EventEmitter } from 'vscode' -import { Disposable, Disposer } from '@hediet/std/disposable' -import { GitExecutor } from './executor' -import { createProcess } from '../../process/execution' -import { CliResult, CliStarted } from '..' -import { getMockedProcess } from '../../test/util/jest' -import { standardizePath } from '../../fileSystem/path' - -jest.mock('vscode') -jest.mock('@hediet/std/disposable') -jest.mock('../../process/execution') - -const mockedDisposable = jest.mocked(Disposable) - -const mockedCreateProcess = jest.mocked(createProcess) - -beforeEach(() => { - jest.resetAllMocks() -}) - -describe('GitExecutor', () => { - mockedDisposable.fn.mockReturnValueOnce({ - track: function (disposable: T): T { - return disposable - }, - untrack: function (disposable: T): T { - return disposable - } - } as unknown as (() => void) & Disposer) - - const gitExecutor = new GitExecutor({ - processCompleted: { - event: jest.fn(), - fire: jest.fn() - } as unknown as EventEmitter, - processStarted: { - event: jest.fn(), - fire: jest.fn() - } as unknown as EventEmitter - }) - - const cwd = standardizePath(__dirname) - - describe('pushBranch', () => { - it('should call createProcess with the correct parameters to push a branch', async () => { - const branchName = 'my-branch' - mockedCreateProcess.mockReturnValueOnce( - getMockedProcess( - `branch '${branchName}' set up to track 'origin/${branchName}'.` - ) - ) - - await gitExecutor.pushBranch(cwd, branchName) - expect(mockedCreateProcess).toHaveBeenCalledWith({ - args: ['push', '--set-upstream', 'origin', branchName], - cwd, - executable: 'git' - }) - }) - - it('should call createProcess with the correct parameters to push the current branch', async () => { - mockedCreateProcess.mockReturnValueOnce( - getMockedProcess('Everything up-to-date') - ) - - await gitExecutor.pushBranch(cwd) - expect(mockedCreateProcess).toHaveBeenCalledWith({ - args: ['push', '--set-upstream', 'origin', 'HEAD'], - cwd, - executable: 'git' - }) - }) - }) - - describe('stageAndCommit', () => { - it('should call createProcess with the correct parameters to stage all files and then commit', async () => { - const message = 'best experiment' - mockedCreateProcess.mockReturnValueOnce(getMockedProcess(cwd)) - mockedCreateProcess - .mockReturnValueOnce(getMockedProcess('')) - .mockReturnValueOnce( - getMockedProcess(`[current-branch 67effdbc] ${message}`) - ) - - await gitExecutor.stageAndCommit(cwd, message) - expect(mockedCreateProcess).toHaveBeenCalledTimes(3) - expect(mockedCreateProcess).toHaveBeenCalledWith({ - args: ['add', '.'], - cwd, - executable: 'git' - }) - expect(mockedCreateProcess).toHaveBeenCalledWith({ - args: ['commit', '-m', message], - cwd, - executable: 'git' - }) - }) - }) -}) diff --git a/extension/src/cli/git/executor.ts b/extension/src/cli/git/executor.ts index 008e4b3ea4..536635f073 100644 --- a/extension/src/cli/git/executor.ts +++ b/extension/src/cli/git/executor.ts @@ -1,14 +1,12 @@ import { GitCli } from '.' -import { Args, Command, Commit, DEFAULT_REMOTE, Flag } from './constants' +import { Command, Commit, Flag } from './constants' import { getOptions } from './options' import { typeCheckCommands } from '..' export const autoRegisteredCommands = { GIT_INIT: 'gitInit', - GIT_PUSH_BRANCH: 'pushBranch', GIT_RESET_WORKSPACE: 'resetWorkspace', GIT_STAGE_ALL: 'stageAll', - GIT_STAGE_AND_COMMIT: 'stageAndCommit', GIT_UNSTAGE_ALL: 'reset' } as const @@ -24,16 +22,6 @@ export class GitExecutor extends GitCli { return this.executeProcess(options) } - public pushBranch(cwd: string, branchName?: string) { - const args: Args = [Command.PUSH, Flag.SET_UPSTREAM, DEFAULT_REMOTE] - - args.push((branchName || Commit.HEAD) as Commit) - - const options = getOptions(cwd, ...args) - - return this.executeProcess(options) - } - public reset(cwd: string, ...args: (Flag | Commit)[]) { const options = getOptions(cwd, Command.RESET, ...args) @@ -60,13 +48,4 @@ export class GitExecutor extends GitCli { return this.executeProcess(options) } - - public async stageAndCommit(cwd: string, message: string) { - await this.stageAll(cwd) - - const args = [Command.COMMIT, Flag.MESSAGE, message] as Args - const options = getOptions(cwd, ...args) - - return this.executeProcess(options) - } } diff --git a/extension/src/commands/external.ts b/extension/src/commands/external.ts index 9ab290075f..78ed077eec 100644 --- a/extension/src/commands/external.ts +++ b/extension/src/commands/external.ts @@ -7,8 +7,6 @@ export enum RegisteredCliCommands { EXPERIMENT_RESET_AND_RUN = 'dvc.resetAndRunCheckpointExperiment', EXPERIMENT_RESUME = 'dvc.resumeCheckpointExperiment', EXPERIMENT_RUN = 'dvc.runExperiment', - EXPERIMENT_SHARE_AS_BRANCH = 'dvc.shareExperimentAsBranch', - EXPERIMENT_SHARE_AS_COMMIT = 'dvc.shareExperimentAsCommit', QUEUE_EXPERIMENT = 'dvc.queueExperiment', QUEUE_KILL = 'dvc.stopQueuedExperiments', QUEUE_START = 'dvc.startExperimentsQueue', @@ -18,8 +16,6 @@ export enum RegisteredCliCommands { EXPERIMENT_VIEW_BRANCH = 'dvc.views.experiments.branchExperiment', EXPERIMENT_VIEW_PUSH = 'dvc.views.experiments.pushExperiment', EXPERIMENT_VIEW_REMOVE = 'dvc.views.experiments.removeExperiment', - EXPERIMENT_VIEW_SHARE_AS_BRANCH = 'dvc.views.experiments.shareExperimentAsBranch', - EXPERIMENT_VIEW_SHARE_AS_COMMIT = 'dvc.views.experiments.shareExperimentAsCommit', EXPERIMENT_VIEW_SHOW_LOGS = 'dvc.views.experiments.showLogs', EXPERIMENT_VIEW_STOP = 'dvc.views.experiments.stopQueueExperiment', diff --git a/extension/src/experiments/commands/index.ts b/extension/src/experiments/commands/index.ts index 12c559664a..2df5b3cd2c 100644 --- a/extension/src/experiments/commands/index.ts +++ b/extension/src/experiments/commands/index.ts @@ -1,4 +1,4 @@ -import { Progress, commands } from 'vscode' +import { commands } from 'vscode' import { AvailableCommands, InternalCommands } from '../../commands/internal' import { Toast } from '../../vscode/toast' import { WorkspaceExperiments } from '../workspace' @@ -15,98 +15,6 @@ export const getBranchExperimentCommand = input ) -const applyAndPush = async ( - internalCommands: InternalCommands, - progress: Progress<{ increment: number; message: string }>, - cwd: string, - name: string -): Promise => { - await Toast.runCommandAndIncrementProgress( - () => - internalCommands.executeCommand( - AvailableCommands.EXPERIMENT_APPLY, - cwd, - name - ), - progress, - 25 - ) - - return Toast.runCommandAndIncrementProgress( - () => internalCommands.executeCommand(AvailableCommands.PUSH, cwd), - progress, - 25 - ) -} - -export const getShareExperimentAsBranchCommand = - (internalCommands: InternalCommands) => - async (cwd: string, name: string, input: string) => { - await Toast.showProgress('Sharing Branch', async progress => { - progress.report({ increment: 0 }) - - await Toast.runCommandAndIncrementProgress( - () => - internalCommands.executeCommand( - AvailableCommands.EXPERIMENT_BRANCH, - cwd, - name, - input - ), - progress, - 25 - ) - - await applyAndPush(internalCommands, progress, cwd, name) - - await Toast.runCommandAndIncrementProgress( - () => - internalCommands.executeCommand( - AvailableCommands.GIT_PUSH_BRANCH, - cwd, - input - ), - progress, - 25 - ) - - return Toast.delayProgressClosing() - }) - } - -export const getShareExperimentAsCommitCommand = - (internalCommands: InternalCommands) => - async (cwd: string, name: string, input: string) => { - await Toast.showProgress('Sharing Commit', async progress => { - progress.report({ increment: 0 }) - - await applyAndPush(internalCommands, progress, cwd, name) - - await Toast.runCommandAndIncrementProgress( - () => - internalCommands.executeCommand( - AvailableCommands.GIT_STAGE_AND_COMMIT, - cwd, - input - ), - progress, - 25 - ) - - await Toast.runCommandAndIncrementProgress( - () => - internalCommands.executeCommand( - AvailableCommands.GIT_PUSH_BRANCH, - cwd - ), - progress, - 25 - ) - - return Toast.delayProgressClosing() - }) - } - export const getShareExperimentToStudioCommand = (internalCommands: InternalCommands, setup: Setup) => ({ dvcRoot, id }: { dvcRoot: string; id: string }) => { diff --git a/extension/src/experiments/commands/register.ts b/extension/src/experiments/commands/register.ts index dc32fc11ff..183a25bdb8 100644 --- a/extension/src/experiments/commands/register.ts +++ b/extension/src/experiments/commands/register.ts @@ -1,7 +1,5 @@ import { getBranchExperimentCommand, - getShareExperimentAsBranchCommand, - getShareExperimentAsCommitCommand, getShareExperimentToStudioCommand } from '.' import { pickGarbageCollectionFlags } from '../quickPick' @@ -167,46 +165,6 @@ const registerExperimentInputCommands = ( id ) ) - - internalCommands.registerExternalCliCommand( - RegisteredCliCommands.EXPERIMENT_SHARE_AS_BRANCH, - () => - experiments.getCwdExpNameAndInputThenRun( - getShareExperimentAsBranchCommand(internalCommands), - Title.ENTER_BRANCH_NAME - ) - ) - - internalCommands.registerExternalCliCommand( - RegisteredCliCommands.EXPERIMENT_VIEW_SHARE_AS_BRANCH, - ({ dvcRoot, id }: ExperimentDetails) => - experiments.getInputAndRun( - getShareExperimentAsBranchCommand(internalCommands), - Title.ENTER_BRANCH_NAME, - dvcRoot, - id - ) - ) - - 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) => - experiments.getInputAndRun( - getShareExperimentAsCommitCommand(internalCommands), - Title.ENTER_COMMIT_MESSAGE, - dvcRoot, - id - ) - ) } const registerExperimentQuickPickCommands = ( diff --git a/extension/src/experiments/webview/messages.ts b/extension/src/experiments/webview/messages.ts index e6dbd9a4f2..7ed3447e97 100644 --- a/extension/src/experiments/webview/messages.ts +++ b/extension/src/experiments/webview/messages.ts @@ -174,17 +174,6 @@ export class WebviewMessages { case MessageFromWebviewType.OPEN_PLOTS_WEBVIEW: return this.showPlotsToSide() - case MessageFromWebviewType.SHARE_EXPERIMENT_AS_BRANCH: - return commands.executeCommand( - RegisteredCliCommands.EXPERIMENT_VIEW_SHARE_AS_BRANCH, - { dvcRoot: this.dvcRoot, id: message.payload } - ) - case MessageFromWebviewType.SHARE_EXPERIMENT_AS_COMMIT: - return commands.executeCommand( - RegisteredCliCommands.EXPERIMENT_VIEW_SHARE_AS_COMMIT, - { dvcRoot: this.dvcRoot, id: message.payload } - ) - case MessageFromWebviewType.SET_EXPERIMENTS_FOR_PLOTS: return this.setSelectedExperiments(message.payload) diff --git a/extension/src/telemetry/constants.ts b/extension/src/telemetry/constants.ts index 02dddc9ea9..f55c7f1a2c 100644 --- a/extension/src/telemetry/constants.ts +++ b/extension/src/telemetry/constants.ts @@ -133,8 +133,6 @@ export interface IEventNamePropertyMapping { [EventName.EXPERIMENT_RUN]: undefined [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_STARRED]: undefined [EventName.EXPERIMENT_SORT_ADD]: undefined @@ -146,8 +144,6 @@ export interface IEventNamePropertyMapping { [EventName.EXPERIMENT_VIEW_BRANCH]: undefined [EventName.EXPERIMENT_VIEW_PUSH]: undefined [EventName.EXPERIMENT_VIEW_REMOVE]: undefined - [EventName.EXPERIMENT_VIEW_SHARE_AS_BRANCH]: undefined - [EventName.EXPERIMENT_VIEW_SHARE_AS_COMMIT]: undefined [EventName.EXPERIMENT_VIEW_SHARE_TO_STUDIO]: undefined [EventName.EXPERIMENT_VIEW_SHOW_LOGS]: undefined [EventName.EXPERIMENT_VIEW_STOP]: undefined diff --git a/extension/src/test/suite/experiments/index.test.ts b/extension/src/test/suite/experiments/index.test.ts index 955ed2355b..d779bed334 100644 --- a/extension/src/test/suite/experiments/index.test.ts +++ b/extension/src/test/suite/experiments/index.test.ts @@ -64,7 +64,6 @@ import * as VscodeContext from '../../../vscode/context' import { Title } from '../../../vscode/title' import { EXP_RWLOCK_FILE, ExperimentFlag } from '../../../cli/dvc/constants' import { DvcExecutor } from '../../../cli/dvc/executor' -import { GitExecutor } from '../../../cli/git/executor' import { WorkspacePlots } from '../../../plots/workspace' import { RegisteredCliCommands, @@ -696,119 +695,6 @@ suite('Experiments Test Suite', () => { expect(mockExperimentPush).to.be.calledWithExactly(dvcDemoPath, mockExpId) }).timeout(WEBVIEW_TEST_TIMEOUT) - it('should handle a message to share an experiment as a new branch', async () => { - const { experiments } = buildExperiments(disposable) - await experiments.isReady() - - const mockExperimentId = 'exp-e7a67' - const mockBranch = 'it-is-a-branch-shared-to-the-remote' - const inputEvent = getInputBoxEvent(mockBranch) - - const mockExperimentBranch = stub( - DvcExecutor.prototype, - 'experimentBranch' - ).resolves( - `Git branch '${mockBranch}' has been created from experiment '${mockExperimentId}'. - To switch to the new branch run: - git checkout ${mockBranch}` - ) - const mockExperimentApply = stub( - DvcExecutor.prototype, - 'experimentApply' - ).resolves( - `Changes for experiment '${mockExperimentId}' have been applied to your current workspace.` - ) - const mockPush = stub(DvcExecutor.prototype, 'push').resolves( - '10 files updated.' - ) - const mockGitPush = stub(GitExecutor.prototype, 'pushBranch') - const branchPushedToRemote = new Promise(resolve => - mockGitPush.callsFake(() => { - resolve(undefined) - return Promise.resolve(`${mockBranch} pushed to remote`) - }) - ) - - stubWorkspaceExperimentsGetters(dvcDemoPath, experiments) - - const webview = await experiments.showWebview() - const mockMessageReceived = getMessageReceivedEmitter(webview) - - mockMessageReceived.fire({ - payload: mockExperimentId, - type: MessageFromWebviewType.SHARE_EXPERIMENT_AS_BRANCH - }) - - await inputEvent - await branchPushedToRemote - expect(mockExperimentBranch).to.be.calledWithExactly( - dvcDemoPath, - mockExperimentId, - mockBranch - ) - expect(mockExperimentApply).to.be.calledWithExactly( - dvcDemoPath, - mockExperimentId - ) - expect(mockPush).to.be.calledWithExactly(dvcDemoPath) - expect(mockGitPush).to.be.calledWithExactly(dvcDemoPath, mockBranch) - }).timeout(WEBVIEW_TEST_TIMEOUT) - - it('should handle a message to share an experiment as a commit', async () => { - const { experiments } = buildExperiments(disposable) - await experiments.isReady() - - const mockExperimentId = 'exp-e7a67' - const mockCommitMessage = - 'this is the very best version that I could come up with' - const inputEvent = getInputBoxEvent(mockCommitMessage) - - const mockExperimentApply = stub( - DvcExecutor.prototype, - 'experimentApply' - ).resolves( - `Changes for experiment '${mockExperimentId}' have been applied to your current workspace.` - ) - const mockStageAndCommit = stub( - GitExecutor.prototype, - 'stageAndCommit' - ).resolves(`[current-branch 67effdbc] ${mockCommitMessage}`) - - const mockPush = stub(DvcExecutor.prototype, 'push').resolves( - '100000 files updated.' - ) - const mockGitPush = stub(GitExecutor.prototype, 'pushBranch') - const branchPushedToRemote = new Promise(resolve => - mockGitPush.callsFake(() => { - resolve(undefined) - return Promise.resolve('current-branch pushed to remote') - }) - ) - - stubWorkspaceExperimentsGetters(dvcDemoPath, experiments) - - const webview = await experiments.showWebview() - const mockMessageReceived = getMessageReceivedEmitter(webview) - - mockMessageReceived.fire({ - payload: mockExperimentId, - type: MessageFromWebviewType.SHARE_EXPERIMENT_AS_COMMIT - }) - - await inputEvent - await branchPushedToRemote - expect(mockStageAndCommit).to.be.calledWithExactly( - dvcDemoPath, - mockCommitMessage - ) - expect(mockExperimentApply).to.be.calledWithExactly( - dvcDemoPath, - mockExperimentId - ) - expect(mockPush).to.be.calledWithExactly(dvcDemoPath) - expect(mockGitPush).to.be.calledWithExactly(dvcDemoPath) - }).timeout(WEBVIEW_TEST_TIMEOUT) - it("should be able to handle a message to modify an experiment's params and queue an experiment", async () => { stub(DvcReader.prototype, 'listStages').resolves('train') const { experiments, dvcExecutor } = buildExperiments(disposable) diff --git a/extension/src/test/suite/experiments/workspace.test.ts b/extension/src/test/suite/experiments/workspace.test.ts index be5acdf6b9..669063b93c 100644 --- a/extension/src/test/suite/experiments/workspace.test.ts +++ b/extension/src/test/suite/experiments/workspace.test.ts @@ -13,7 +13,6 @@ import { Experiments } from '../../../experiments' import * as QuickPick from '../../../vscode/quickPick' import { DvcExecutor } from '../../../cli/dvc/executor' import { - bypassProgressCloseDelay, closeAllEditors, getInputBoxEvent, getTimeSafeDisposer, @@ -35,7 +34,6 @@ import { WEBVIEW_TEST_TIMEOUT } from '../timeouts' import { Title } from '../../../vscode/title' import { join } from '../../util/path' import { AvailableCommands } from '../../../commands/internal' -import { GitExecutor } from '../../../cli/git/executor' import { EXPERIMENT_WORKSPACE_ID } from '../../../cli/dvc/contract' import { formatDate } from '../../../util/date' import { DvcReader } from '../../../cli/dvc/reader' @@ -660,127 +658,6 @@ suite('Workspace Experiments Test Suite', () => { }) }) - describe('dvc.shareExperimentAsBranch', () => { - it('should be able to share an experiment as a branch', async () => { - bypassProgressCloseDelay() - stub(DvcReader.prototype, 'listStages').resolves('train') - - const { experiments } = buildExperiments(disposable) - await experiments.isReady() - - const testExperiment = 'exp-83425' - const mockBranch = 'more-brunch' - const inputEvent = getInputBoxEvent(mockBranch) - - stub(window, 'showQuickPick').resolves({ - value: testExperiment - } as QuickPickItemWithValue) - - const mockExperimentBranch = stub( - DvcExecutor.prototype, - 'experimentBranch' - ).resolves( - `Git branch '${mockBranch}' has been created from experiment '${testExperiment}'. - To switch to the new branch run: - git checkout ${mockBranch}` - ) - 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( - '10 files updated.' - ) - const mockGitPush = stub(GitExecutor.prototype, 'pushBranch') - const branchPushedToRemote = new Promise(resolve => - mockGitPush.callsFake(() => { - resolve(undefined) - return Promise.resolve(`${mockBranch} pushed to remote`) - }) - ) - - stubWorkspaceExperimentsGetters(dvcDemoPath, experiments) - - await commands.executeCommand( - RegisteredCliCommands.EXPERIMENT_SHARE_AS_BRANCH - ) - - await inputEvent - await branchPushedToRemote - expect(mockExperimentBranch).to.be.calledWithExactly( - dvcDemoPath, - testExperiment, - mockBranch - ) - expect(mockExperimentApply).to.be.calledWithExactly( - dvcDemoPath, - testExperiment - ) - expect(mockPush).to.be.calledWithExactly(dvcDemoPath) - expect(mockGitPush).to.be.calledWithExactly(dvcDemoPath, mockBranch) - }) - }) - - describe('dvc.shareExperimentAsCommit', () => { - it('should be able to share an experiment as a commit', async () => { - bypassProgressCloseDelay() - stub(DvcReader.prototype, 'listStages').resolves('train') - - 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: testExperiment - } as QuickPickItemWithValue) - - 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.removeExperiments', () => { it('should ask the user to pick experiment(s) and then remove selected ones from the workspace', async () => { const mockExperimentId = 'exp-e7a67' diff --git a/extension/src/webview/contract.ts b/extension/src/webview/contract.ts index c7947fd7e7..bc5eae0756 100644 --- a/extension/src/webview/contract.ts +++ b/extension/src/webview/contract.ts @@ -50,8 +50,6 @@ export enum MessageFromWebviewType { SET_EXPERIMENTS_FOR_PLOTS = 'set-experiments-for-plots', SET_EXPERIMENTS_AND_OPEN_PLOTS = 'set-experiments-and-open-plots', SET_STUDIO_SHARE_EXPERIMENTS_LIVE = 'set-studio-share-experiments-live', - SHARE_EXPERIMENT_AS_BRANCH = 'share-experiment-as-branch', - SHARE_EXPERIMENT_AS_COMMIT = 'share-experiment-as-commit', TOGGLE_PLOTS_SECTION = 'toggle-plots-section', REMOVE_CUSTOM_PLOTS = 'remove-custom-plots', REMOVE_STUDIO_TOKEN = 'remove-studio-token', @@ -212,14 +210,6 @@ export type MessageFromWebview = type: MessageFromWebviewType.SET_STUDIO_SHARE_EXPERIMENTS_LIVE payload: boolean } - | { - type: MessageFromWebviewType.SHARE_EXPERIMENT_AS_BRANCH - payload: string - } - | { - type: MessageFromWebviewType.SHARE_EXPERIMENT_AS_COMMIT - payload: string - } | { type: MessageFromWebviewType.SET_EXPERIMENTS_HEADER_HEIGHT } | { type: MessageFromWebviewType.CHECK_CLI_COMPATIBLE } | { type: MessageFromWebviewType.INITIALIZE_DVC } diff --git a/webview/src/experiments/components/App.test.tsx b/webview/src/experiments/components/App.test.tsx index 5c99b02c24..2c9925e18b 100644 --- a/webview/src/experiments/components/App.test.tsx +++ b/webview/src/experiments/components/App.test.tsx @@ -863,8 +863,6 @@ describe('App', () => { 'Apply to Workspace', 'Create new Branch', 'Share to Studio', - 'Commit and Share', - 'Share as Branch', 'Modify and Run', 'Modify and Resume', 'Modify and Queue', @@ -884,7 +882,7 @@ describe('App', () => { fireEvent.contextMenu(row, { bubbles: true }) advanceTimersByTime(100) - expect(screen.getAllByRole('menuitem')).toHaveLength(12) + expect(screen.getAllByRole('menuitem')).toHaveLength(10) fireEvent.click(window, { bubbles: true }) advanceTimersByTime(100) @@ -898,7 +896,7 @@ describe('App', () => { fireEvent.contextMenu(row, { bubbles: true }) advanceTimersByTime(100) - expect(screen.getAllByRole('menuitem')).toHaveLength(12) + expect(screen.getAllByRole('menuitem')).toHaveLength(10) const commit = getRow('main') fireEvent.click(commit, { bubbles: true }) @@ -913,13 +911,13 @@ describe('App', () => { fireEvent.contextMenu(row, { bubbles: true }) advanceTimersByTime(100) - expect(screen.queryAllByRole('menuitem')).toHaveLength(12) + expect(screen.queryAllByRole('menuitem')).toHaveLength(10) fireEvent.contextMenu(within(row).getByText('[exp-e7a67]'), { bubbles: true }) advanceTimersByTime(200) - expect(screen.queryAllByRole('menuitem')).toHaveLength(12) + expect(screen.queryAllByRole('menuitem')).toHaveLength(10) }) it('should present the Remove experiment option for the checkpoint tips', () => { diff --git a/webview/src/experiments/components/table/body/RowContextMenu.tsx b/webview/src/experiments/components/table/body/RowContextMenu.tsx index bac3166559..3778b525c1 100644 --- a/webview/src/experiments/components/table/body/RowContextMenu.tsx +++ b/webview/src/experiments/components/table/body/RowContextMenu.tsx @@ -205,14 +205,6 @@ const getSingleSelectMenuOptions = ( MessageFromWebviewType.SHARE_EXPERIMENT_TO_STUDIO, true ), - hideIfRunningOrNotExperiment( - 'Commit and Share', - MessageFromWebviewType.SHARE_EXPERIMENT_AS_COMMIT - ), - hideIfRunningOrNotExperiment( - 'Share as Branch', - MessageFromWebviewType.SHARE_EXPERIMENT_AS_BRANCH - ), ...getRunResumeOptions( hideIfRunning, projectHasCheckpoints,