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

Bump min version of DVC to 2.57.0 (Live share to studio config option) #3976

Merged
merged 6 commits into from
May 28, 2023
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
refactor
  • Loading branch information
mattseddon committed May 26, 2023
commit 4d3d2e10d9ae5c47a2d5cd6cfb655076875e8d94
49 changes: 18 additions & 31 deletions extension/src/setup/index.ts
Original file line number Diff line number Diff line change
@@ -407,7 +407,7 @@ export class Setup
const webviewMessages = new WebviewMessages(
() => this.getWebview(),
() => this.initializeGit(),
(offline: boolean) => this.setStudioOffline(offline)
(offline: boolean) => this.updateStudioOffline(offline)
)
this.dispose.track(
this.onDidReceivedWebviewMessage(message =>
@@ -673,46 +673,24 @@ export class Setup
}

private async setStudioValues() {
if (!this.getCliCompatible()) {
const cwd = this.getCwd()

if (!cwd) {
this.studioAccessToken = undefined
this.shareLiveToStudio = undefined
return
}

if (this.dvcRoots.length !== 1) {
const cwd = getFirstWorkspaceFolder()
if (!cwd) {
this.studioAccessToken = undefined
this.shareLiveToStudio = undefined
return
}

;[this.studioAccessToken] = await Promise.all([
this.accessConfig(cwd, ConfigKey.STUDIO_TOKEN),
this.getStudioShareLive(cwd)
])
return
}

;[this.studioAccessToken] = await Promise.all([
this.accessConfig(this.dvcRoots[0], ConfigKey.STUDIO_TOKEN),
this.getStudioShareLive(this.dvcRoots[0])
])
}

private async getStudioShareLive(cwd: string) {
this.shareLiveToStudio =
;[this.studioAccessToken, this.shareLiveToStudio] = await Promise.all([
this.accessConfig(cwd, ConfigKey.STUDIO_TOKEN),
(await this.accessConfig(cwd, ConfigKey.STUDIO_OFFLINE)) !== 'true'
])
}

private async setStudioOffline(shareLive: boolean) {
private async updateStudioOffline(shareLive: boolean) {
const offline = !shareLive
if (!this.getCliCompatible()) {
return
}

const cwd =
this.dvcRoots.length === 1 ? this.dvcRoots[0] : getFirstWorkspaceFolder()
const cwd = this.getCwd()

if (!cwd) {
return
@@ -726,6 +704,15 @@ export class Setup
)
}

private getCwd() {
if (!this.getCliCompatible()) {
return
}
return this.dvcRoots.length === 1
? this.dvcRoots[0]
: getFirstWorkspaceFolder()
}

private accessConfig(cwd: string, ...args: Args) {
return this.accessDvc(AvailableCommands.CONFIG, cwd, ...args)
}
8 changes: 4 additions & 4 deletions extension/src/setup/webview/messages.ts
Original file line number Diff line number Diff line change
@@ -19,16 +19,16 @@ import { openUrl } from '../../vscode/external'
export class WebviewMessages {
private readonly getWebview: () => BaseWebview<TSetupData> | undefined
private readonly initializeGit: () => void
private readonly setStudioOffline: (offline: boolean) => Promise<void>
private readonly updateStudioOffline: (offline: boolean) => Promise<void>

constructor(
getWebview: () => BaseWebview<TSetupData> | undefined,
initializeGit: () => void,
setStudioOffline: (shareLive: boolean) => Promise<void>
updateStudioOffline: (shareLive: boolean) => Promise<void>
) {
this.getWebview = getWebview
this.initializeGit = initializeGit
this.setStudioOffline = setStudioOffline
this.updateStudioOffline = updateStudioOffline
}

public sendWebviewMessage({
@@ -102,7 +102,7 @@ export class WebviewMessages {
RegisteredCommands.REMOVE_STUDIO_ACCESS_TOKEN
)
case MessageFromWebviewType.SET_STUDIO_SHARE_EXPERIMENTS_LIVE:
return this.setStudioOffline(message.payload)
return this.updateStudioOffline(message.payload)
case MessageFromWebviewType.OPEN_EXPERIMENTS_WEBVIEW:
return commands.executeCommand(RegisteredCommands.EXPERIMENT_SHOW)
case MessageFromWebviewType.REMOTE_ADD: