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 dvc config to store and access studio.token #3768

Merged
merged 4 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
16 changes: 15 additions & 1 deletion extension/src/cli/dvc/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export enum Command {
ADD = 'add',
CHECKOUT = 'checkout',
COMMIT = 'commit',
CONFIG = 'config',
DATA = 'data',
EXPERIMENT = 'exp',
INITIALIZE = 'init',
Expand All @@ -46,7 +47,9 @@ export enum Flag {
ALL_COMMITS = '-A',
FOLLOW = '-f',
FORCE = '-f',
GLOBAL = '--global',
GRANULAR = '--granular',
LOCAL = '--local',
JOBS = '-j',
JSON = '--json',
KILL = '--kill',
Expand All @@ -56,6 +59,7 @@ export enum Flag {
SET_PARAM = '-S',
SPLIT = '--split',
UNCHANGED = '--unchanged',
UNSET = '--unset',
VERSION = '--version'
}

Expand Down Expand Up @@ -90,8 +94,18 @@ export enum GcPreserveFlag {
WORKSPACE = '--workspace'
}

export enum ConfigKey {
STUDIO_TOKEN = 'studio.token'
}

type Target = string

type Flags = Flag | ExperimentFlag | GcPreserveFlag

export type Args = (Command | Target | ExperimentSubCommand | Flags)[]
export type Args = (
| Command
| Target
| ExperimentSubCommand
| Flags
| ConfigKey
)[]
5 changes: 5 additions & 0 deletions extension/src/cli/dvc/executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export const autoRegisteredCommands = {
ADD: 'add',
CHECKOUT: 'checkout',
COMMIT: 'commit',
CONFIG: 'config',
EXPERIMENT_APPLY: 'experimentApply',
EXPERIMENT_BRANCH: 'experimentBranch',
EXPERIMENT_GARBAGE_COLLECT: 'experimentGarbageCollect',
Expand Down Expand Up @@ -71,6 +72,10 @@ export class DvcExecutor extends DvcCli {
return this.blockAndExecuteProcess(cwd, Command.COMMIT, ...args, Flag.FORCE)
}

public config(cwd: string, ...args: Args) {
Copy link
Member Author

Choose a reason for hiding this comment

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

[F] Config doesn't really fit with the reader/executor model as it can both read and write the config. For now, I've put it into executor.

return this.executeDvcProcess(cwd, Command.CONFIG, ...args)
}

public experimentApply(cwd: string, experimentName: string) {
return this.executeExperimentProcess(
cwd,
Expand Down
8 changes: 4 additions & 4 deletions extension/src/cli/dvc/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { Config } from '../../config'
export class DvcCli extends Cli {
public autoRegisteredCommands: string[] = []

protected readonly config: Config
protected readonly extensionConfig: Config

constructor(
config: Config,
Expand All @@ -18,7 +18,7 @@ export class DvcCli extends Cli {
) {
super(emitters)

this.config = config
this.extensionConfig = config
}

protected executeDvcProcess(cwd: string, ...args: Args): Promise<string> {
Expand All @@ -36,8 +36,8 @@ export class DvcCli extends Cli {

protected getOptions(cwd: string, ...args: Args) {
return getOptions(
this.config.getPythonBinPath(),
this.config.getCliPath(),
this.extensionConfig.getPythonBinPath(),
this.extensionConfig.getCliPath(),
cwd,
...args
)
Expand Down
2 changes: 1 addition & 1 deletion extension/src/cli/dvc/reader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ export class DvcReader extends DvcCli {
public globalVersion(cwd: string): Promise<string> {
const options = getOptions(
undefined,
this.config.getCliPath(),
this.extensionConfig.getCliPath(),
cwd,
Flag.VERSION
)
Expand Down
1 change: 0 additions & 1 deletion extension/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,6 @@ export class Extension extends Disposable {

this.setup = this.dispose.track(
new Setup(
context,
config,
this.internalCommands,
this.experiments,
Expand Down
Loading