Skip to content

Commit

Permalink
Merge branch 'main' into add-tsv-export-option
Browse files Browse the repository at this point in the history
  • Loading branch information
julieg18 committed Jul 18, 2023
2 parents 831ccc7 + 9b49eb6 commit 51ba3ce
Show file tree
Hide file tree
Showing 56 changed files with 598 additions and 338 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@

All notable changes to this project will be documented in this file.

## [1.0.20] - 2023-07-17

### 🐛 Bug Fixes

- Exclude sub-project files from file and editor watchers [#4283](https://github.com/iterative/vscode-dvc/pull/4283) by [@mattseddon](https://github.com/mattseddon)

### 🔨 Maintenance

- Remove moduleResolution from tsconfig [#4282](https://github.com/iterative/vscode-dvc/pull/4282) by [@mattseddon](https://github.com/mattseddon)

## [1.0.19] - 2023-07-17

### 🚀 New Features and Enhancements
Expand Down
4 changes: 4 additions & 0 deletions extension/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ module.exports = {
'jest/valid-expect': 'off',
'no-unused-expressions': 'off'
}
},
{
files: ['src/test/e2e/**/*'],
rules: { '@typescript-eslint/no-unsafe-declaration-merging': 'off' }
}
]
}
8 changes: 4 additions & 4 deletions extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"extensionDependencies": [
"vscode.git"
],
"version": "1.0.19",
"version": "1.0.20",
"license": "Apache-2.0",
"readme": "./README.md",
"repository": {
Expand Down Expand Up @@ -1696,7 +1696,7 @@
"@types/chai-as-promised": "7.1.5",
"@types/copy-webpack-plugin": "10.1.0",
"@types/fs-extra": "11.0.1",
"@types/jest": "29.5.2",
"@types/jest": "29.5.3",
"@types/js-yaml": "4.0.5",
"@types/lodash.clonedeep": "4.5.7",
"@types/lodash.get": "4.4.7",
Expand All @@ -1714,10 +1714,10 @@
"@types/vscode": "1.64.0",
"@vscode/test-electron": "2.3.3",
"@vscode/vsce": "2.19.0",
"@wdio/cli": "8.12.1",
"@wdio/cli": "8.12.2",
"@wdio/local-runner": "8.12.1",
"@wdio/mocha-framework": "8.12.1",
"@wdio/spec-reporter": "8.12.1",
"@wdio/spec-reporter": "8.12.2",
"chai": "4.3.7",
"chai-as-promised": "7.1.1",
"clean-webpack-plugin": "4.0.0",
Expand Down
2 changes: 1 addition & 1 deletion extension/src/cli/dvc/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export enum SubCommand {

export enum Flag {
ALL_COMMITS = '-A',
FOLLOW = '-f',
FOLLOW = '--follow',
DEFAULT = '-d',
FORCE = '-f',
GLOBAL = '--global',
Expand Down
3 changes: 1 addition & 2 deletions extension/src/cli/git/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ export enum Flag {
OTHERS = '--others',
QUIET = '-q',
RAW_WITH_NUL = '-z',
SEPARATE_WITH_NULL = '-z',
SHOW_TOPLEVEL = '--show-toplevel'
}

Expand All @@ -53,4 +52,4 @@ export const DEFAULT_REMOTE = 'origin'

export const COMMITS_SEPARATOR = '\u0000'

export type Args = (Command | Flag | Commit | typeof DEFAULT_REMOTE | string)[]
export type Args = (Command | Flag | Commit | string)[]
2 changes: 1 addition & 1 deletion extension/src/cli/git/reader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export class GitReader extends GitCli {
Command.LOG,
revision,
Flag.PRETTY_FORMAT_COMMIT_MESSAGE,
Flag.SEPARATE_WITH_NULL,
Flag.RAW_WITH_NUL,
Flag.NUMBER,
revisions
],
Expand Down
2 changes: 1 addition & 1 deletion extension/src/commands/internal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { Toast } from '../vscode/toast'
import { Response } from '../vscode/response'
import { Disposable } from '../class/dispose'

type Command = (...args: Args) => unknown | Promise<unknown>
type Command = (...args: Args) => unknown

export const AvailableCommands = Object.assign(
{},
Expand Down
34 changes: 21 additions & 13 deletions extension/src/data/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { InternalCommands } from '../commands/internal'
import { ExpShowOutput, PlotsOutputOrError } from '../cli/dvc/contract'
import { uniqueValues } from '../util/array'
import { DeferredDisposable } from '../class/deferred'
import { isSameOrChild } from '../fileSystem'
import { isPathInSubProject, isSameOrChild } from '../fileSystem'

export type ExperimentsOutput = {
availableNbCommits: { [branch: string]: number }
Expand All @@ -29,6 +29,7 @@ export abstract class BaseData<
protected readonly internalCommands: InternalCommands
protected collectedFiles: string[] = []

private readonly relSubProjects: string[]
private readonly staticFiles: string[]

private readonly updated: EventEmitter<T> = this.dispose.track(
Expand All @@ -39,6 +40,7 @@ export abstract class BaseData<
dvcRoot: string,
internalCommands: InternalCommands,
updateProcesses: { name: string; process: () => Promise<unknown> }[],
subProjects: string[],
staticFiles: string[] = []
) {
super()
Expand All @@ -49,6 +51,9 @@ export abstract class BaseData<
)
this.internalCommands = internalCommands
this.onDidUpdate = this.updated.event
this.relSubProjects = subProjects.map(subProject =>
relative(this.dvcRoot, subProject)
)
this.staticFiles = staticFiles

this.watchFiles()
Expand Down Expand Up @@ -78,20 +83,23 @@ export abstract class BaseData<
return createFileSystemWatcher(
disposable => this.dispose.track(disposable),
getRelativePattern(this.dvcRoot, '**'),
path => {
const relPath = relative(this.dvcRoot, path)
if (
this.getWatchedFiles().some(
watchedRelPath =>
path.endsWith(watchedRelPath) ||
isSameOrChild(relPath, watchedRelPath)
)
) {
void this.managedUpdate(path)
}
}
path => this.listener(path)
)
}

private listener(path: string) {
const relPath = relative(this.dvcRoot, path)
if (
this.getWatchedFiles().some(
watchedRelPath =>
path.endsWith(watchedRelPath) ||
isSameOrChild(relPath, watchedRelPath)
) &&
!isPathInSubProject(relPath, this.relSubProjects)
) {
void this.managedUpdate(path)
}
}

abstract managedUpdate(path?: string): Promise<void>
}
23 changes: 16 additions & 7 deletions extension/src/experiments/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ import { Event, EventEmitter, window } from 'vscode'
import { Disposable, Disposer } from '@hediet/std/disposable'
import { ContextKey, setContextValue } from '../vscode/context'
import { standardizePossiblePath } from '../fileSystem/path'
import { isPathInProject, isPathInSubProject } from '../fileSystem'

const setContextOnDidChangeParamsFiles = (
setActiveEditorContext: (paramsFileActive: boolean) => void,
onDidChangeColumns: Event<void>,
getParamsFiles: () => Set<string>
getParamsFiles: () => Set<string>,
subProjects: string[]
): Disposable =>
onDidChangeColumns(() => {
const path = standardizePossiblePath(
Expand All @@ -16,7 +18,10 @@ const setContextOnDidChangeParamsFiles = (
return
}

if (!getParamsFiles().has(path) && !path.endsWith('dvc.yaml')) {
if (
(!getParamsFiles().has(path) && !path.endsWith('dvc.yaml')) ||
isPathInSubProject(path, subProjects)
) {
return
}
setActiveEditorContext(true)
Expand All @@ -25,7 +30,8 @@ const setContextOnDidChangeParamsFiles = (
const setContextOnDidChangeActiveEditor = (
setActiveEditorContext: (paramsFileActive: boolean) => void,
dvcRoot: string,
getParamsFiles: () => Set<string>
getParamsFiles: () => Set<string>,
subProjects: string[]
): Disposable =>
window.onDidChangeActiveTextEditor(event => {
const path = standardizePossiblePath(event?.document.fileName)
Expand All @@ -34,7 +40,7 @@ const setContextOnDidChangeActiveEditor = (
return
}

if (!path.includes(dvcRoot)) {
if (!isPathInProject(path, dvcRoot, subProjects)) {
return
}

Expand All @@ -49,7 +55,8 @@ export const setContextForEditorTitleIcons = (
disposer: (() => void) & Disposer,
getParamsFiles: () => Set<string>,
experimentsFileFocused: EventEmitter<string | undefined>,
onDidChangeColumns: Event<void>
onDidChangeColumns: Event<void>,
subProjects: string[]
): void => {
const setActiveEditorContext = (experimentsFileActive: boolean) => {
void setContextValue(
Expand All @@ -64,15 +71,17 @@ export const setContextForEditorTitleIcons = (
setContextOnDidChangeParamsFiles(
setActiveEditorContext,
onDidChangeColumns,
getParamsFiles
getParamsFiles,
subProjects
)
)

disposer.track(
setContextOnDidChangeActiveEditor(
setActiveEditorContext,
dvcRoot,
getParamsFiles
getParamsFiles,
subProjects
)
)
}
4 changes: 3 additions & 1 deletion extension/src/experiments/data/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@ export class ExperimentsData extends BaseData<ExperimentsOutput> {
constructor(
dvcRoot: string,
internalCommands: InternalCommands,
experiments: ExperimentsModel
experiments: ExperimentsModel,
subProjects: string[]
) {
super(
dvcRoot,
internalCommands,
[{ name: 'update', process: () => this.update() }],
subProjects,
['dvc.lock', 'dvc.yaml', 'params.yaml', DOT_DVC]
)

Expand Down
16 changes: 12 additions & 4 deletions extension/src/experiments/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ export class Experiments extends BaseRepository<TableData> {
selectBranches: (
branchesSelected: string[]
) => Promise<string[] | undefined>,
subProjects: string[],
data?: ExperimentsData
) {
super(dvcRoot, resourceLocator.beaker)
Expand Down Expand Up @@ -143,7 +144,13 @@ export class Experiments extends BaseRepository<TableData> {
)

this.data = this.dispose.track(
data || new ExperimentsData(dvcRoot, internalCommands, this.experiments)
data ||
new ExperimentsData(
dvcRoot,
internalCommands,
this.experiments,
subProjects
)
)

this.dispose.track(this.data.onDidUpdate(data => this.setState(data)))
Expand All @@ -158,7 +165,7 @@ export class Experiments extends BaseRepository<TableData> {

this.webviewMessages = this.createWebviewMessageHandler()
this.setupInitialData()
this.watchActiveEditor()
this.watchActiveEditor(subProjects)
}

public update() {
Expand Down Expand Up @@ -600,13 +607,14 @@ export class Experiments extends BaseRepository<TableData> {
)
}

private watchActiveEditor() {
private watchActiveEditor(subProjects: string[]) {
setContextForEditorTitleIcons(
this.dvcRoot,
this.dispose,
() => this.columns.getParamsFiles(),
this.experimentsFileFocused,
this.onDidChangeColumns
this.onDidChangeColumns,
subProjects
)
}

Expand Down
2 changes: 1 addition & 1 deletion extension/src/experiments/model/collect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ export const collectRunningInWorkspace = (
if (!ids.has(id)) {
continue
}
if (executor === EXPERIMENT_WORKSPACE_ID) {
if (executor === (EXPERIMENT_WORKSPACE_ID as Executor)) {
return id
}
}
Expand Down
5 changes: 4 additions & 1 deletion extension/src/experiments/model/filterBy/quickPick.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,10 @@ describe('pickFilterToAdd', () => {
expect(mockedQuickPickValue).toHaveBeenCalledWith(
OPERATORS.filter(
({ types }) =>
!(types.length === 1 && types[0] === ColumnType.TIMESTAMP)
!(
types.length === 1 &&
(types[0] as ColumnType) === ColumnType.TIMESTAMP
)
),
{
title: Title.SELECT_OPERATOR
Expand Down
4 changes: 3 additions & 1 deletion extension/src/experiments/workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ export class WorkspaceExperiments extends BaseWorkspaceWebviews<

public createRepository(
dvcRoot: string,
subProjects: string[],
pipeline: WorkspacePipeline,
resourceLocator: ResourceLocator
) {
Expand All @@ -283,7 +284,8 @@ export class WorkspaceExperiments extends BaseWorkspaceWebviews<
pipeline.getRepository(dvcRoot),
resourceLocator,
this.workspaceState,
(branchesSelected: string[]) => this.selectBranches(branchesSelected)
(branchesSelected: string[]) => this.selectBranches(branchesSelected),
subProjects
)
)

Expand Down
23 changes: 18 additions & 5 deletions extension/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -277,17 +277,26 @@ class Extension extends Disposable {
public async initialize() {
this.resetMembers()

const dvcRoots = this.getRoots()
const subProjects = this.getSubProjects()

await Promise.all([
this.repositories.create(this.getRoots()),
this.repositoriesTree.initialize(this.getRoots()),
this.pipelines.create(this.getRoots())
this.repositories.create(dvcRoots, subProjects),
this.repositoriesTree.initialize(dvcRoots),
this.pipelines.create(dvcRoots, subProjects)
])
this.experiments.create(
this.getRoots(),
dvcRoots,
subProjects,
this.pipelines,
this.resourceLocator
)
this.plots.create(this.getRoots(), this.resourceLocator, this.experiments)
this.plots.create(
dvcRoots,
subProjects,
this.resourceLocator,
this.experiments
)

return Promise.all([
this.experiments.isReady(),
Expand All @@ -308,6 +317,10 @@ class Extension extends Disposable {
private getRoots() {
return this.setup.getRoots()
}

private getSubProjects() {
return this.setup.getSubProjects()
}
}

let extension: undefined | Extension
Expand Down
Loading

0 comments on commit 51ba3ce

Please sign in to comment.