-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
303 additions
and
97 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { Disposable } from './class/dispose' | ||
import { CliRunner } from './cli/runner' | ||
import { WorkspaceExperiments } from './experiments/workspace' | ||
import { setContextValue } from './vscode/context' | ||
|
||
export class Context extends Disposable { | ||
private readonly experiments: WorkspaceExperiments | ||
private readonly cliRunner: CliRunner | ||
|
||
constructor(experiments: WorkspaceExperiments, cliRunner: CliRunner) { | ||
super() | ||
|
||
this.experiments = experiments | ||
this.cliRunner = cliRunner | ||
|
||
this.dispose.track( | ||
this.cliRunner.onDidStartProcess(() => { | ||
this.setIsExperimentRunning() | ||
}) | ||
) | ||
|
||
this.dispose.track( | ||
this.cliRunner.onDidCompleteProcess(({ cwd }) => | ||
this.experiments.getRepository(cwd).update() | ||
) | ||
) | ||
|
||
this.dispose.track( | ||
this.experiments.onDidChangeExperiments(() => { | ||
this.setIsExperimentRunning() | ||
}) | ||
) | ||
} | ||
|
||
private setIsExperimentRunning() { | ||
if (this.cliRunner.isExperimentRunning()) { | ||
setContextValue('dvc.experiment.running', true) | ||
return | ||
} | ||
|
||
let hasRunning = false | ||
for (const dvcRoot of this.experiments.getDvcRoots()) { | ||
if (this.experiments.getRepository(dvcRoot).hasRunningExperiment()) { | ||
hasRunning = true | ||
} | ||
} | ||
setContextValue('dvc.experiment.running', hasRunning) | ||
} | ||
} |
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
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.