Skip to content

Commit

Permalink
Create watcher specifically for temp queue directories (#4571)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattseddon committed Aug 25, 2023
1 parent fe6441f commit acd27dc
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 16 deletions.
2 changes: 1 addition & 1 deletion extension/src/cli/dvc/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const TEMP_PLOTS_DIR = join(DOT_DVC, 'tmp', 'plots')

export const FIELD_SEPARATOR = '::'

const TEMP_EXP_DIR = join(DOT_DVC, 'tmp', 'exps')
export const TEMP_EXP_DIR = join(DOT_DVC, 'tmp', 'exps')
export const DVCLIVE_ONLY_RUNNING_SIGNAL_FILE = join(
TEMP_EXP_DIR,
'run',
Expand Down
26 changes: 13 additions & 13 deletions extension/src/data/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,19 +82,7 @@ export abstract class BaseData<
)
}

private getWatchedFiles() {
return uniqueValues([...this.staticFiles, ...this.collectedFiles])
}

private watchFiles() {
return createFileSystemWatcher(
disposable => this.dispose.track(disposable),
getRelativePattern(this.dvcRoot, '**'),
path => this.listener(path)
)
}

private listener(path: string) {
protected listener(path: string) {
const relPath = relative(this.dvcRoot, path)
if (
this.getWatchedFiles().some(
Expand All @@ -108,5 +96,17 @@ export abstract class BaseData<
}
}

private getWatchedFiles() {
return uniqueValues([...this.staticFiles, ...this.collectedFiles])
}

private watchFiles() {
return createFileSystemWatcher(
disposable => this.dispose.track(disposable),
getRelativePattern(this.dvcRoot, '**'),
path => this.listener(path)
)
}

abstract managedUpdate(path?: string): Promise<void>
}
18 changes: 17 additions & 1 deletion extension/src/experiments/data/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { join } from 'path'
import { collectBranches, collectFiles } from './collect'
import {
EXPERIMENTS_GIT_LOGS_REFS,
Expand All @@ -13,7 +14,12 @@ import {
ExperimentsOutput,
isRemoteExperimentsOutput
} from '../../data'
import { Args, DOT_DVC, ExperimentFlag } from '../../cli/dvc/constants'
import {
Args,
DOT_DVC,
ExperimentFlag,
TEMP_EXP_DIR
} from '../../cli/dvc/constants'
import { COMMITS_SEPARATOR, gitPath } from '../../cli/git/constants'
import { getGitPath } from '../../fileSystem'
import { ExperimentsModel } from '../model'
Expand All @@ -38,6 +44,7 @@ export class ExperimentsData extends BaseData<ExperimentsOutput> {
this.experiments = experiments

void this.watchExpGitRefs()
void this.watchQueueDirectories()
void this.managedUpdate()
this.waitForInitialLocalData()
}
Expand Down Expand Up @@ -174,6 +181,15 @@ export class ExperimentsData extends BaseData<ExperimentsOutput> {
)
}

private watchQueueDirectories() {
const tempQueueDirectory = join(this.dvcRoot, TEMP_EXP_DIR)
return createFileSystemWatcher(
disposable => this.dispose.track(disposable),
getRelativePattern(tempQueueDirectory, '**'),
(path: string) => this.listener(path)
)
}

private async updateRemoteExpRefs() {
const [remoteExpRefs] = await Promise.all([
this.internalCommands.executeCommand(
Expand Down
2 changes: 1 addition & 1 deletion extension/src/test/suite/experiments/data/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ suite('Experiments Data Test Suite', () => {
await data.isReady()

expect(mockExpShow).to.be.calledOnce
expect(mockCreateFileSystemWatcher).to.be.calledOnce
expect(mockCreateFileSystemWatcher).to.be.calledTwice

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

0 comments on commit acd27dc

Please sign in to comment.