1- import { getBranchExperimentCommand , getPushExperimentCommand } from '.'
1+ import {
2+ getBranchExperimentCommand ,
3+ getPushExperimentCommand ,
4+ getRenameExperimentCommand
5+ } from '.'
26import { WorkspaceExperiments } from '../workspace'
37import { AvailableCommands , InternalCommands } from '../../commands/internal'
48import {
@@ -9,6 +13,10 @@ import { Title } from '../../vscode/title'
913import { Context , getDvcRootFromContext } from '../../vscode/context'
1014import { Setup } from '../../setup'
1115import { showSetupOrExecuteCommand } from '../../commands/util'
16+ import { CliCompatible , isVersionCompatible } from '../../cli/dvc/version'
17+ import { Toast } from '../../vscode/toast'
18+ import { Response } from '../../vscode/response'
19+ import { SetupSection } from '../../setup/webview/contract'
1220
1321type ExperimentDetails = { dvcRoot : string ; id : string }
1422
@@ -121,13 +129,46 @@ const registerExperimentNameCommands = (
121129
122130const registerExperimentInputCommands = (
123131 experiments : WorkspaceExperiments ,
124- internalCommands : InternalCommands
132+ internalCommands : InternalCommands ,
133+ setup : Setup
125134) : void => {
126135 internalCommands . registerExternalCliCommand (
127136 RegisteredCliCommands . EXPERIMENT_BRANCH ,
128137 ( ) => experiments . createExperimentBranch ( )
129138 )
130139
140+ internalCommands . registerExternalCliCommand (
141+ RegisteredCliCommands . EXPERIMENT_VIEW_RENAME ,
142+ async ( { dvcRoot, id } : ExperimentDetails ) => {
143+ const cliVersion = await setup . getCliVersion ( dvcRoot )
144+ const REQUIRED_CLI_VERSION = '3.22.0'
145+
146+ if (
147+ ! (
148+ isVersionCompatible ( cliVersion , REQUIRED_CLI_VERSION ) ===
149+ CliCompatible . YES
150+ )
151+ ) {
152+ const response = await Toast . warnWithOptions (
153+ 'To rename experiments, you need DVC version 3.22.0 or greater. Please update your DVC installation.' ,
154+ Response . SHOW_SETUP
155+ )
156+ if ( response === Response . SHOW_SETUP ) {
157+ return setup . showSetup ( SetupSection . DVC )
158+ }
159+ return
160+ }
161+
162+ return experiments . getInputAndRun (
163+ getRenameExperimentCommand ( experiments ) ,
164+ Title . ENTER_NEW_EXPERIMENT_NAME ,
165+ id ,
166+ dvcRoot ,
167+ id
168+ )
169+ }
170+ )
171+
131172 internalCommands . registerExternalCliCommand (
132173 RegisteredCliCommands . EXPERIMENT_VIEW_BRANCH ,
133174 ( { dvcRoot, id } : ExperimentDetails ) =>
@@ -265,7 +306,7 @@ export const registerExperimentCommands = (
265306) => {
266307 registerExperimentCwdCommands ( experiments , internalCommands )
267308 registerExperimentNameCommands ( experiments , internalCommands )
268- registerExperimentInputCommands ( experiments , internalCommands )
309+ registerExperimentInputCommands ( experiments , internalCommands , setup )
269310 registerExperimentQuickPickCommands ( experiments , internalCommands , setup )
270311 registerExperimentRunCommands ( experiments , internalCommands , setup )
271312
0 commit comments