-
Notifications
You must be signed in to change notification settings - Fork 29
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
Integrate remaining share experiment command with the extension (exp push) #3781
Merged
Merged
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
e18a7fd
integrate remaining share function with the extension (exp push)
mattseddon 7fa5da1
self review
mattseddon 7d66fe5
Merge branch 'main' into rename-share-command
mattseddon 104e653
rename share to push
mattseddon 4a5f1e0
remove custom error handling (use offer to show error in output channel)
mattseddon 82ea04a
Merge branch 'main' into rename-share-command
mattseddon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,37 +3,76 @@ import { AvailableCommands, InternalCommands } from '../../commands/internal' | |
import { Toast } from '../../vscode/toast' | ||
import { WorkspaceExperiments } from '../workspace' | ||
import { Setup } from '../../setup' | ||
import { Response } from '../../vscode/response' | ||
import { | ||
ConfigKey, | ||
getConfigValue, | ||
setUserConfigValue | ||
} from '../../vscode/config' | ||
import { STUDIO_URL } from '../../setup/webview/contract' | ||
import { RegisteredCommands } from '../../commands/external' | ||
|
||
export const getBranchExperimentCommand = | ||
(experiments: WorkspaceExperiments) => | ||
(cwd: string, name: string, input: string) => | ||
experiments.runCommand(AvailableCommands.EXP_BRANCH, cwd, name, input) | ||
|
||
export const getShareExperimentToStudioCommand = | ||
const promptToAddStudioToken = async () => { | ||
const response = await Toast.askShowOrCloseOrNever( | ||
`Experiments can be automatically shared to [Studio](${STUDIO_URL}) by setting the studio.token in your config.` | ||
) | ||
|
||
if (!response || response === Response.CLOSE) { | ||
return | ||
} | ||
if (response === Response.SHOW) { | ||
return commands.executeCommand(RegisteredCommands.SETUP_SHOW_STUDIO_CONNECT) | ||
} | ||
if (response === Response.NEVER) { | ||
return setUserConfigValue(ConfigKey.DO_NOT_RECOMMEND_ADD_STUDIO_TOKEN, true) | ||
} | ||
} | ||
|
||
const convertUrlTextToLink = (stdout: string) => { | ||
const experimentAtRegex = /\sat\s+(https:\/\/studio\.iterative\.ai\/.*$)/ | ||
const match = stdout.match(experimentAtRegex) | ||
if (!(match?.[0] && match?.[1])) { | ||
return stdout | ||
} | ||
return stdout.replace(match[0], ` in [Studio](${match[1]})`) | ||
} | ||
|
||
export const getPushExperimentCommand = | ||
(internalCommands: InternalCommands, setup: Setup) => | ||
({ dvcRoot, id }: { dvcRoot: string; id: string }) => { | ||
const studioAccessToken = setup.getStudioAccessToken() | ||
if (!studioAccessToken) { | ||
return commands.executeCommand(RegisteredCommands.SETUP_SHOW) | ||
if ( | ||
!( | ||
getConfigValue(ConfigKey.DO_NOT_RECOMMEND_ADD_STUDIO_TOKEN) || | ||
studioAccessToken | ||
) | ||
) { | ||
void promptToAddStudioToken() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [F] This is non-blocking. User can push as many experiments as they like without setting the token. |
||
} | ||
|
||
return Toast.showProgress('Sharing', async progress => { | ||
return Toast.showProgress('exp push', async progress => { | ||
progress.report({ increment: 0 }) | ||
|
||
progress.report({ increment: 25, message: 'Running exp push...' }) | ||
|
||
await Toast.runCommandAndIncrementProgress( | ||
() => | ||
internalCommands.executeCommand( | ||
AvailableCommands.EXP_PUSH, | ||
dvcRoot, | ||
id | ||
), | ||
progress, | ||
75 | ||
progress.report({ increment: 25, message: `Pushing ${id}...` }) | ||
|
||
const remainingProgress = 75 | ||
|
||
const stdout = await internalCommands.executeCommand( | ||
AvailableCommands.EXP_PUSH, | ||
dvcRoot, | ||
id | ||
) | ||
|
||
progress.report({ | ||
increment: remainingProgress, | ||
message: convertUrlTextToLink(stdout) | ||
}) | ||
|
||
return Toast.delayProgressClosing(15000) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
EXPERIMENT_VIEW_PUSH
was already set above 😕