Skip to content

Commit e8b9708

Browse files
authored
Bump min version of DVC to 2.57.0 (Live share to studio config option) (#3976)
* remove custom logic for live sharing experiments to studio (moved to dvc config) * give indicator that the checkbox reflects config option * test and refactor
1 parent 5701363 commit e8b9708

File tree

20 files changed

+113
-276
lines changed

20 files changed

+113
-276
lines changed

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,6 @@ These are the VS Code [settings] available for the Extension:
151151
| `dvc.dvcPath` | Path or shell command to the DVC binary. Required unless Microsoft's [Python extension] is installed and the `dvc` package found in its environment. |
152152
| `dvc.pythonPath` | Path to the desired Python interpreter to use with DVC. Should only be utilized when using a virtual environment without Microsoft's [Python extension]. |
153153
| `dvc.experimentsTableHeadMaxHeight` | Maximum height of experiment table head rows. |
154-
| `dvc.studio.shareExperimentsLive` | Automatically share all new experiment metrics and plots logged with DVCLive to Studio. This option will only take effect once Studio is connected. |
155154
| `dvc.focusedProjects` | A subset of paths to the workspace's available DVC projects. Using this option will override project auto-discovery. |
156155
| `dvc.doNotShowWalkthroughAfterInstall` | Do not prompt to show the Get Started page after installing. Useful for pre-configured development environments |
157156
| `dvc.doNotRecommendAddStudioToken` | Do not prompt to add a [studio.token] to the global DVC config, which enables automatic sharing of experiments to [Studio]. |

extension/package.json

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -643,11 +643,6 @@
643643
"description": "Path to the desired Python interpreter to use with DVC. Required when using a virtual environment. Overrides any other extension's settings for this extension's purposes.",
644644
"type": "string",
645645
"default": null
646-
},
647-
"dvc.studio.shareExperimentsLive": {
648-
"description": "Automatically share all new experiment metrics and plots logged with DVCLive to Studio. This option will only take effect once Studio is connected (studio.token is set).",
649-
"type": "boolean",
650-
"default": false
651646
}
652647
}
653648
},

extension/src/cli/dvc/constants.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@ export enum GcPreserveFlag {
103103
}
104104

105105
export enum ConfigKey {
106-
STUDIO_TOKEN = 'studio.token'
106+
STUDIO_TOKEN = 'studio.token',
107+
STUDIO_OFFLINE = 'studio.offline'
107108
}
108109

109110
type Target = string

extension/src/cli/dvc/contract.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Plot } from '../../plots/webview/contract'
22

3-
export const MIN_CLI_VERSION = '2.55.0'
3+
export const MIN_CLI_VERSION = '2.57.0'
44
export const LATEST_TESTED_CLI_VERSION = '2.58.1'
55
export const MAX_CLI_VERSION = '3'
66

extension/src/cli/dvc/executor.test.ts

Lines changed: 1 addition & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { Flag, GcPreserveFlag, UNEXPECTED_ERROR_CODE } from './constants'
55
import { DvcExecutor } from './executor'
66
import { CliResult, CliStarted } from '..'
77
import { createProcess } from '../../process/execution'
8-
import { flushPromises, getMockedProcess } from '../../test/util/jest'
8+
import { getMockedProcess } from '../../test/util/jest'
99
import { getProcessEnv } from '../../env'
1010
import { Config } from '../../config'
1111
import { ContextKey, setContextValue } from '../../vscode/context'
@@ -30,9 +30,6 @@ const mockedEnv = {
3030

3131
const mockedSetContextValue = jest.mocked(setContextValue)
3232

33-
const mockedGetStudioLiveShareToken = jest.fn()
34-
const mockedGetRepoUrl = jest.fn()
35-
3633
beforeEach(() => {
3734
jest.resetAllMocks()
3835
mockedGetProcessEnv.mockReturnValueOnce(mockedEnv)
@@ -53,8 +50,6 @@ describe('CliExecutor', () => {
5350
getCliPath: () => undefined,
5451
getPythonBinPath: () => undefined
5552
} as unknown as Config,
56-
mockedGetStudioLiveShareToken,
57-
mockedGetRepoUrl,
5853
{
5954
processCompleted: {
6055
event: jest.fn(),
@@ -620,39 +615,6 @@ describe('CliExecutor', () => {
620615
executable: 'dvc'
621616
})
622617
})
623-
624-
it("should call createProcess with the correct parameters to start the experiment's queue and send live updates to Studio", async () => {
625-
const cwd = __dirname
626-
const jobs = '91231324'
627-
const mockedToken = 'isat_notarealtoken'
628-
const mockedUrl = '[email protected]:iterative/vscode-dvc-demo.git'
629-
630-
mockedGetStudioLiveShareToken.mockReturnValueOnce(mockedToken)
631-
mockedGetRepoUrl.mockResolvedValueOnce(
632-
'[email protected]:iterative/vscode-dvc-demo.git'
633-
)
634-
635-
const stdout = `Started '${jobs}' new experiments task queue workers.`
636-
637-
mockedCreateProcess.mockReturnValueOnce(getMockedProcess(stdout))
638-
639-
void dvcExecutor.queueStart(cwd, jobs)
640-
await flushPromises()
641-
642-
expect(mockedGetRepoUrl).toHaveBeenCalledWith(cwd)
643-
644-
expect(mockedCreateProcess).toHaveBeenCalledWith({
645-
args: ['queue', 'start', '-j', jobs],
646-
cwd,
647-
detached: true,
648-
env: {
649-
...mockedEnv,
650-
STUDIO_REPO_URL: mockedUrl,
651-
STUDIO_TOKEN: mockedToken
652-
},
653-
executable: 'dvc'
654-
})
655-
})
656618
})
657619

658620
describe('queueStop', () => {

extension/src/cli/dvc/executor.ts

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { EventEmitter } from 'vscode'
21
import { DvcCli } from '.'
32
import {
43
Args,
@@ -9,10 +8,8 @@ import {
98
GcPreserveFlag,
109
QueueSubCommand
1110
} from './constants'
12-
import { addStudioAccessToken } from './options'
13-
import { CliResult, CliStarted, typeCheckCommands } from '..'
11+
import { typeCheckCommands } from '..'
1412
import { ContextKey, setContextValue } from '../../vscode/context'
15-
import { Config } from '../../config'
1613
import { DEFAULT_REMOTE } from '../git/constants'
1714

1815
export const autoRegisteredCommands = {
@@ -45,24 +42,8 @@ export class DvcExecutor extends DvcCli {
4542
this
4643
)
4744

48-
private readonly getStudioLiveShareToken: () => string | undefined
49-
private readonly getRepoUrl: (cwd: string) => Promise<string>
5045
private scmCommandRunning = false
5146

52-
constructor(
53-
config: Config,
54-
getStudioLiveShareToken: () => string | undefined,
55-
getRepoUrl: (cwd: string) => Promise<string>,
56-
emitters?: {
57-
processStarted: EventEmitter<CliStarted>
58-
processCompleted: EventEmitter<CliResult>
59-
}
60-
) {
61-
super(config, emitters)
62-
this.getStudioLiveShareToken = getStudioLiveShareToken
63-
this.getRepoUrl = getRepoUrl
64-
}
65-
6647
public add(cwd: string, target: string) {
6748
return this.blockAndExecuteProcess(cwd, Command.ADD, target)
6849
}
@@ -168,20 +149,16 @@ export class DvcExecutor extends DvcCli {
168149
)
169150
}
170151

171-
public async queueStart(cwd: string, jobs: string) {
152+
public queueStart(cwd: string, jobs: string) {
172153
const options = this.getOptions(
173154
cwd,
174155
Command.QUEUE,
175156
QueueSubCommand.START,
176157
Flag.JOBS,
177158
jobs
178159
)
179-
const studioAccessToken = this.getStudioLiveShareToken()
180-
const repoUrl = studioAccessToken ? await this.getRepoUrl(cwd) : undefined
181160

182-
return this.createBackgroundProcess(
183-
addStudioAccessToken(options, studioAccessToken, repoUrl)
184-
)
161+
return this.createBackgroundProcess(options)
185162
}
186163

187164
public queueStop(cwd: string, ...args: Args) {

extension/src/cli/dvc/options.ts

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -50,29 +50,3 @@ export const getOptions = (
5050
executable
5151
}
5252
}
53-
54-
export const addStudioAccessToken = (
55-
options: ExecutionOptions,
56-
studioAccessToken: string | undefined,
57-
repoUrl?: string
58-
): ExecutionOptions => {
59-
if (!studioAccessToken) {
60-
return options
61-
}
62-
63-
if (!repoUrl) {
64-
return {
65-
...options,
66-
env: { ...options.env, STUDIO_TOKEN: studioAccessToken }
67-
}
68-
}
69-
70-
return {
71-
...options,
72-
env: {
73-
...options.env,
74-
STUDIO_REPO_URL: repoUrl,
75-
STUDIO_TOKEN: studioAccessToken
76-
}
77-
}
78-
}

extension/src/cli/dvc/runner.ts

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
ExperimentFlag,
66
ExperimentSubCommand
77
} from './constants'
8-
import { addStudioAccessToken, getOptions } from './options'
8+
import { getOptions } from './options'
99
import { CliResult, CliStarted, ICli, typeCheckCommands } from '..'
1010
import { getCommandString } from '../command'
1111
import { Config } from '../../config'
@@ -46,15 +46,10 @@ export class DvcRunner extends Disposable implements ICli {
4646
private readonly pseudoTerminal: PseudoTerminal
4747
private currentProcess: Process | undefined
4848
private readonly config: Config
49-
private readonly getStudioLiveShareToken: () => string | undefined
5049

51-
constructor(
52-
config: Config,
53-
getStudioLiveShareToken: () => string | undefined
54-
) {
50+
constructor(config: Config) {
5551
super()
5652
this.config = config
57-
this.getStudioLiveShareToken = getStudioLiveShareToken
5853

5954
this.processCompleted = this.dispose.track(new EventEmitter<CliResult>())
6055
this.onDidCompleteProcess = this.processCompleted.event
@@ -146,7 +141,12 @@ export class DvcRunner extends Disposable implements ICli {
146141
}
147142

148143
private createProcess({ cwd, args }: { cwd: string; args: Args }): Process {
149-
const options = this.getOptions(cwd, args)
144+
const options = getOptions(
145+
this.config.getPythonBinPath(),
146+
this.config.getCliPath(),
147+
cwd,
148+
...args
149+
)
150150
const command = getCommandString(options)
151151
const stopWatch = new StopWatch()
152152
const process = this.dispose.track(createProcess(options))
@@ -174,18 +174,6 @@ export class DvcRunner extends Disposable implements ICli {
174174
return process
175175
}
176176

177-
private getOptions(cwd: string, args: Args) {
178-
const options = getOptions(
179-
this.config.getPythonBinPath(),
180-
this.config.getCliPath(),
181-
cwd,
182-
...args
183-
)
184-
185-
const studioAccessToken = this.getStudioLiveShareToken()
186-
return addStudioAccessToken(options, studioAccessToken)
187-
}
188-
189177
private startProcess(cwd: string, args: Args) {
190178
this.pseudoTerminal.setBlocked(true)
191179
this.processOutput.fire(`Running: dvc ${args.join(' ')}\r\n\n`)

extension/src/extension.ts

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -84,18 +84,10 @@ class Extension extends Disposable {
8484
this.gitExecutor = this.dispose.track(new GitExecutor())
8585
this.gitReader = this.dispose.track(new GitReader())
8686

87-
const getStudioLiveShareToken = () => this.setup.getStudioLiveShareToken()
88-
89-
this.dvcExecutor = this.dispose.track(
90-
new DvcExecutor(config, getStudioLiveShareToken, cwd =>
91-
this.gitReader.getRemoteUrl(cwd)
92-
)
93-
)
87+
this.dvcExecutor = this.dispose.track(new DvcExecutor(config))
9488

9589
this.dvcReader = this.dispose.track(new DvcReader(config))
96-
this.dvcRunner = this.dispose.track(
97-
new DvcRunner(config, getStudioLiveShareToken)
98-
)
90+
this.dvcRunner = this.dispose.track(new DvcRunner(config))
9991
this.dvcViewer = this.dispose.track(new DvcViewer(config))
10092

10193
const clis = [

0 commit comments

Comments
 (0)