Skip to content

Commit

Permalink
use dvc config to store and access studio.token
Browse files Browse the repository at this point in the history
  • Loading branch information
mattseddon committed Apr 27, 2023
1 parent 626328a commit 408a94c
Show file tree
Hide file tree
Showing 12 changed files with 286 additions and 150 deletions.
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) {
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
}

public 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

0 comments on commit 408a94c

Please sign in to comment.