Skip to content

Commit acd27dc

Browse files
authored
Create watcher specifically for temp queue directories (#4571)
1 parent fe6441f commit acd27dc

File tree

4 files changed

+32
-16
lines changed

4 files changed

+32
-16
lines changed

extension/src/cli/dvc/constants.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export const TEMP_PLOTS_DIR = join(DOT_DVC, 'tmp', 'plots')
99

1010
export const FIELD_SEPARATOR = '::'
1111

12-
const TEMP_EXP_DIR = join(DOT_DVC, 'tmp', 'exps')
12+
export const TEMP_EXP_DIR = join(DOT_DVC, 'tmp', 'exps')
1313
export const DVCLIVE_ONLY_RUNNING_SIGNAL_FILE = join(
1414
TEMP_EXP_DIR,
1515
'run',

extension/src/data/index.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -82,19 +82,7 @@ export abstract class BaseData<
8282
)
8383
}
8484

85-
private getWatchedFiles() {
86-
return uniqueValues([...this.staticFiles, ...this.collectedFiles])
87-
}
88-
89-
private watchFiles() {
90-
return createFileSystemWatcher(
91-
disposable => this.dispose.track(disposable),
92-
getRelativePattern(this.dvcRoot, '**'),
93-
path => this.listener(path)
94-
)
95-
}
96-
97-
private listener(path: string) {
85+
protected listener(path: string) {
9886
const relPath = relative(this.dvcRoot, path)
9987
if (
10088
this.getWatchedFiles().some(
@@ -108,5 +96,17 @@ export abstract class BaseData<
10896
}
10997
}
11098

99+
private getWatchedFiles() {
100+
return uniqueValues([...this.staticFiles, ...this.collectedFiles])
101+
}
102+
103+
private watchFiles() {
104+
return createFileSystemWatcher(
105+
disposable => this.dispose.track(disposable),
106+
getRelativePattern(this.dvcRoot, '**'),
107+
path => this.listener(path)
108+
)
109+
}
110+
111111
abstract managedUpdate(path?: string): Promise<void>
112112
}

extension/src/experiments/data/index.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { join } from 'path'
12
import { collectBranches, collectFiles } from './collect'
23
import {
34
EXPERIMENTS_GIT_LOGS_REFS,
@@ -13,7 +14,12 @@ import {
1314
ExperimentsOutput,
1415
isRemoteExperimentsOutput
1516
} from '../../data'
16-
import { Args, DOT_DVC, ExperimentFlag } from '../../cli/dvc/constants'
17+
import {
18+
Args,
19+
DOT_DVC,
20+
ExperimentFlag,
21+
TEMP_EXP_DIR
22+
} from '../../cli/dvc/constants'
1723
import { COMMITS_SEPARATOR, gitPath } from '../../cli/git/constants'
1824
import { getGitPath } from '../../fileSystem'
1925
import { ExperimentsModel } from '../model'
@@ -38,6 +44,7 @@ export class ExperimentsData extends BaseData<ExperimentsOutput> {
3844
this.experiments = experiments
3945

4046
void this.watchExpGitRefs()
47+
void this.watchQueueDirectories()
4148
void this.managedUpdate()
4249
this.waitForInitialLocalData()
4350
}
@@ -174,6 +181,15 @@ export class ExperimentsData extends BaseData<ExperimentsOutput> {
174181
)
175182
}
176183

184+
private watchQueueDirectories() {
185+
const tempQueueDirectory = join(this.dvcRoot, TEMP_EXP_DIR)
186+
return createFileSystemWatcher(
187+
disposable => this.dispose.track(disposable),
188+
getRelativePattern(tempQueueDirectory, '**'),
189+
(path: string) => this.listener(path)
190+
)
191+
}
192+
177193
private async updateRemoteExpRefs() {
178194
const [remoteExpRefs] = await Promise.all([
179195
this.internalCommands.executeCommand(

extension/src/test/suite/experiments/data/index.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ suite('Experiments Data Test Suite', () => {
8383
await data.isReady()
8484

8585
expect(mockExpShow).to.be.calledOnce
86-
expect(mockCreateFileSystemWatcher).to.be.calledOnce
86+
expect(mockCreateFileSystemWatcher).to.be.calledTwice
8787

8888
expect(getArgOfCall(mockCreateFileSystemWatcher, 0, 2)).to.deep.equal(
8989
new RelativePattern(getTestWorkspaceFolder(), '**')

0 commit comments

Comments
 (0)