Skip to content
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

Use exp push to share experiments to Studio #3701

Merged
merged 2 commits into from
Apr 28, 2023
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
1 change: 1 addition & 0 deletions extension/src/cli/dvc/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export enum ExperimentSubCommand {
APPLY = 'apply',
BRANCH = 'branch',
GARBAGE_COLLECT = 'gc',
PUSH = 'push',
REMOVE = 'remove',
RUN = 'run'
}
Expand Down
18 changes: 18 additions & 0 deletions extension/src/cli/dvc/executor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,24 @@ describe('CliExecutor', () => {
})
})

describe('experimentPush', () => {
it('should call createProcess with the correct parameters to push an existing experiment to the remote', async () => {
const cwd = __dirname
const stdout = ''
mockedCreateProcess.mockReturnValueOnce(getMockedProcess(stdout))

const output = await dvcExecutor.experimentPush(cwd, 'toric-sail')
expect(output).toStrictEqual(stdout)

expect(mockedCreateProcess).toHaveBeenCalledWith({
args: ['exp', 'push', 'origin', 'toric-sail'],
cwd,
env: mockedEnv,
executable: 'dvc'
})
})
})

describe('experimentRemove', () => {
it('should call createProcess with the correct parameters to remove an existing experiment from the workspace', async () => {
const cwd = __dirname
Expand Down
11 changes: 11 additions & 0 deletions extension/src/cli/dvc/executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { addStudioAccessToken } from './options'
import { CliResult, CliStarted, typeCheckCommands } from '..'
import { ContextKey, setContextValue } from '../../vscode/context'
import { Config } from '../../config'
import { DEFAULT_REMOTE } from '../git/constants'

export const autoRegisteredCommands = {
ADD: 'add',
Expand All @@ -22,6 +23,7 @@ export const autoRegisteredCommands = {
EXPERIMENT_APPLY: 'experimentApply',
EXPERIMENT_BRANCH: 'experimentBranch',
EXPERIMENT_GARBAGE_COLLECT: 'experimentGarbageCollect',
EXPERIMENT_PUSH: 'experimentPush',
EXPERIMENT_QUEUE: 'experimentRunQueue',
EXPERIMENT_REMOVE: 'experimentRemove',
EXPERIMENT_REMOVE_QUEUE: 'experimentRemoveQueue',
Expand Down Expand Up @@ -109,6 +111,15 @@ export class DvcExecutor extends DvcCli {
)
}

public experimentPush(cwd: string, id: string) {
return this.executeExperimentProcess(
cwd,
ExperimentSubCommand.PUSH,
DEFAULT_REMOTE,
id
)
}

public experimentRemove(cwd: string, ...experimentNames: string[]) {
return this.executeExperimentProcess(
cwd,
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 @@ -16,6 +16,7 @@ export enum RegisteredCliCommands {

EXPERIMENT_VIEW_APPLY = 'dvc.views.experiments.applyExperiment',
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',
Expand Down
4 changes: 2 additions & 2 deletions extension/src/commands/internal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { Disposable } from '../class/dispose'
type Command = (...args: Args) => unknown | Promise<unknown>

export const AvailableCommands = Object.assign(
{ EXP_PUSH: 'expPush' } as const,
{},
DvcExecutorCommands,
DvcReaderCommands,
DvcRunnerCommands,
Expand All @@ -30,7 +30,7 @@ export const AvailableCommands = Object.assign(
typeof DvcRunnerCommands &
typeof DvcViewerCommands &
typeof GitExecutorCommands &
typeof GitReaderCommands & { EXP_PUSH: 'expPush' }
typeof GitReaderCommands
export type CommandId =
(typeof AvailableCommands)[keyof typeof AvailableCommands]

Expand Down
24 changes: 18 additions & 6 deletions extension/src/experiments/commands/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,22 @@ export const getShareExperimentToStudioCommand =
return commands.executeCommand(RegisteredCommands.SETUP_SHOW)
}

return internalCommands.executeCommand(
AvailableCommands.EXP_PUSH,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[I] Make sure to remove this from internal commands too (it is in the types).

studioAccessToken,
dvcRoot,
id
)
return Toast.showProgress('Sharing', async progress => {
progress.report({ increment: 0 })

progress.report({ increment: 25, message: 'Running exp push...' })

await Toast.runCommandAndIncrementProgress(
() =>
internalCommands.executeCommand(
AvailableCommands.EXPERIMENT_PUSH,
dvcRoot,
id
),
progress,
75
)

return Toast.delayProgressClosing(15000)
})
}
2 changes: 0 additions & 2 deletions extension/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ import { stopProcesses } from './process/execution'
import { Flag } from './cli/dvc/constants'
import { LanguageClient } from './languageClient'
import { collectRunningExperimentPids } from './experiments/processExecution/collect'
import { registerPatchCommand } from './patch'
import { DvcViewer } from './cli/dvc/viewer'
import { registerSetupCommands } from './setup/register'
import { Status } from './status'
Expand Down Expand Up @@ -200,7 +199,6 @@ export class Extension extends Disposable {
)
)

registerPatchCommand(this.internalCommands)
registerExperimentCommands(
this.experiments,
this.internalCommands,
Expand Down
209 changes: 0 additions & 209 deletions extension/src/patch.ts

This file was deleted.

1 change: 1 addition & 0 deletions extension/src/telemetry/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ export interface IEventNamePropertyMapping {
[EventName.EXPERIMENT_TOGGLE]: undefined
[EventName.EXPERIMENT_VIEW_APPLY]: undefined
[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
Expand Down
Loading