Skip to content

Commit

Permalink
Merge branch 'main' into add-stylelint-to-precommit-hook
Browse files Browse the repository at this point in the history
  • Loading branch information
julieg18 authored May 2, 2023
2 parents 58d5241 + 4a89846 commit ed33fd9
Show file tree
Hide file tree
Showing 12 changed files with 188 additions and 96 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,19 @@

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

## [0.8.4] - 2023-05-02

### 🐛 Bug Fixes

- Fix missing tracked decorations [#3801](https://github.com/iterative/vscode-dvc/pull/3801) by [@mattseddon](https://github.com/mattseddon)
- Hide push option when an experiment is running [#3808](https://github.com/iterative/vscode-dvc/pull/3808) by [@mattseddon](https://github.com/mattseddon)

### 🔨 Maintenance

- Update demo project and latest tested CLI version (2.56.0) [#3805](https://github.com/iterative/vscode-dvc/pull/3805) by [@sroy3](https://github.com/sroy3)
- WorkspaceExperiments housekeeping [#3797](https://github.com/iterative/vscode-dvc/pull/3797) by [@mattseddon](https://github.com/mattseddon)
- Wait for config to be ready before accessing values [#3799](https://github.com/iterative/vscode-dvc/pull/3799) by [@mattseddon](https://github.com/mattseddon)

## [0.8.3] - 2023-05-01

### 🚀 New Features and Enhancements
Expand Down
2 changes: 1 addition & 1 deletion demo
Submodule demo updated 1 files
+2 −2 requirements.txt
2 changes: 1 addition & 1 deletion extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"extensionDependencies": [
"vscode.git"
],
"version": "0.8.3",
"version": "0.8.4",
"license": "Apache-2.0",
"readme": "./README.md",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion extension/src/cli/dvc/contract.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Plot } from '../../plots/webview/contract'

export const MIN_CLI_VERSION = '2.55.0'
export const LATEST_TESTED_CLI_VERSION = '2.55.0'
export const LATEST_TESTED_CLI_VERSION = '2.56.0'
export const MAX_CLI_VERSION = '3'

type ErrorContents = { type: string; msg: string }
Expand Down
7 changes: 4 additions & 3 deletions extension/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,14 @@ export class Config extends DeferredDisposable {
}

public async setPythonBinPath() {
this.pythonBinPath = await this.getConfigOrExtensionPythonBinPath()
return this.deferred.resolve()
const pythonBinPath = await this.getConfigOrExtensionPythonBinPath()
this.pythonBinPath = pythonBinPath
this.deferred.resolve()
}

public async setPythonAndNotifyIfChanged() {
const oldPath = this.pythonBinPath
this.pythonBinPath = await this.getConfigOrExtensionPythonBinPath()
await this.setPythonBinPath()
this.notifyIfChanged(oldPath, this.pythonBinPath)
}

Expand Down
139 changes: 64 additions & 75 deletions extension/src/experiments/workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,83 +95,43 @@ export class WorkspaceExperiments extends BaseWorkspaceWebviews<
)
}

public async addFilter(overrideRoot?: string) {
const dvcRoot = await this.getDvcRoot(overrideRoot)
if (!dvcRoot) {
return
}
return this.getRepository(dvcRoot).addFilter()
public addFilter(overrideRoot?: string) {
return this.getRepositoryThenUpdate('addFilter', overrideRoot)
}

public async addStarredFilter(overrideRoot?: string) {
const dvcRoot = await this.getDvcRoot(overrideRoot)
if (!dvcRoot) {
return
}
return this.getRepository(dvcRoot).addStarredFilter()
public addStarredFilter(overrideRoot?: string) {
return this.getRepositoryThenUpdate('addStarredFilter', overrideRoot)
}

public async removeFilters() {
const dvcRoot = await this.getFocusedOrOnlyOrPickProject()
if (!dvcRoot) {
return
}
return this.getRepository(dvcRoot).removeFilters()
public removeFilters() {
return this.getRepositoryThenUpdate('removeFilters')
}

public async addSort(overrideRoot?: string) {
const dvcRoot = await this.getDvcRoot(overrideRoot)
if (!dvcRoot) {
return
}
return this.getRepository(dvcRoot).addSort()
public addSort(overrideRoot?: string) {
return this.getRepositoryThenUpdate('addSort', overrideRoot)
}

public async addStarredSort(overrideRoot?: string) {
const dvcRoot = await this.getDvcRoot(overrideRoot)
if (!dvcRoot) {
return
}
return this.getRepository(dvcRoot).addStarredSort()
public addStarredSort(overrideRoot?: string) {
return this.getRepositoryThenUpdate('addStarredSort', overrideRoot)
}

public async removeSorts() {
const dvcRoot = await this.getFocusedOrOnlyOrPickProject()
if (!dvcRoot) {
return
}

return this.getRepository(dvcRoot).removeSorts()
public removeSorts() {
return this.getRepositoryThenUpdate('removeSorts')
}

public async selectExperimentsToPlot(overrideRoot?: string) {
const dvcRoot = await this.getDvcRoot(overrideRoot)
if (!dvcRoot) {
return
}
return this.getRepository(dvcRoot).selectExperimentsToPlot()
public selectExperimentsToPlot(overrideRoot?: string) {
return this.getRepositoryThenUpdate('selectExperimentsToPlot', overrideRoot)
}

public async selectColumns(overrideRoot?: string) {
const dvcRoot = await this.getDvcRoot(overrideRoot)
if (!dvcRoot) {
return
}
return this.getRepository(dvcRoot).selectColumns()
public selectColumns(overrideRoot?: string) {
return this.getRepositoryThenUpdate('selectColumns', overrideRoot)
}

public async selectQueueTasksToKill() {
const cwd = await this.getFocusedOrOnlyOrPickProject()
if (!cwd) {
return
}

const taskIds = await this.getRepository(cwd).pickQueueTasksToKill()

if (!taskIds || isEmpty(taskIds)) {
return
}
return this.runCommand(AvailableCommands.QUEUE_KILL, cwd, ...taskIds)
public selectQueueTasksToKill() {
return this.pickIdsThenRun(
'pickQueueTasksToKill',
AvailableCommands.QUEUE_KILL
)
}

public async selectExperimentsToPush(setup: Setup) {
Expand All @@ -190,20 +150,11 @@ export class WorkspaceExperiments extends BaseWorkspaceWebviews<
return pushCommand({ dvcRoot, ids })
}

public async selectExperimentsToRemove() {
const cwd = await this.getFocusedOrOnlyOrPickProject()
if (!cwd) {
return
}

const experimentIds = await this.getRepository(
cwd
).pickExperimentsToRemove()
if (!experimentIds || isEmpty(experimentIds)) {
return
}

return this.runCommand(AvailableCommands.EXP_REMOVE, cwd, ...experimentIds)
public selectExperimentsToRemove() {
return this.pickIdsThenRun(
'pickExperimentsToRemove',
AvailableCommands.EXP_REMOVE
)
}

public async modifyExperimentParamsAndRun(
Expand Down Expand Up @@ -453,6 +404,25 @@ export class WorkspaceExperiments extends BaseWorkspaceWebviews<
)
}

private async getRepositoryThenUpdate(
method:
| 'addFilter'
| 'addStarredFilter'
| 'removeFilters'
| 'addSort'
| 'addStarredSort'
| 'removeSorts'
| 'selectExperimentsToPlot'
| 'selectColumns',
overrideRoot?: string
) {
const dvcRoot = await this.getDvcRoot(overrideRoot)
if (!dvcRoot) {
return
}
return this.getRepository(dvcRoot)[method]()
}

private async shouldRun() {
const cwd = await this.getFocusedOrOnlyOrPickProject()
if (!cwd) {
Expand Down Expand Up @@ -555,6 +525,25 @@ export class WorkspaceExperiments extends BaseWorkspaceWebviews<
return { command, enteredManually, trainingScript }
}

private async pickIdsThenRun(
pickMethod: 'pickQueueTasksToKill' | 'pickExperimentsToRemove',
commandId:
| typeof AvailableCommands.QUEUE_KILL
| typeof AvailableCommands.EXP_REMOVE
) {
const cwd = await this.getFocusedOrOnlyOrPickProject()
if (!cwd) {
return
}

const ids = await this.getRepository(cwd)[pickMethod]()

if (!ids || isEmpty(ids)) {
return
}
return this.runCommand(commandId, cwd, ...ids)
}

private async pickExpThenRun(
commandId: CommandId,
pickFunc: (cwd: string) => Thenable<string | undefined> | undefined
Expand Down
49 changes: 49 additions & 0 deletions extension/src/repository/model/collect.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,55 @@ describe('collectDataStatus', () => {
makeAbsPathSet(dvcDemoPath, rawDataDir)
)
})

it('should fill in the gaps for tracked decorations', () => {
const data = {
not_in_remote: [
join('static', 'uploads', 'images', '2019-12-14', 'devsprints.png')
],
unchanged: [
join('static', 'uploads', 'images', '2019-09-26', 'dvc-org.png')
],
uncommitted: {
added: [
join(
'static',
'uploads',
'images',
'2017-05-15',
'20190925_181739.jpg'
)
],
modified: [join('static', 'uploads') + sep]
}
}
const collected = collectDataStatus(dvcDemoPath, data)

expect(
collected.trackedDecorations.has(
join(
dvcDemoPath,
'static',
'uploads',
'images',
'2019-09-26',
'dvc-org.png'
)
)
).toBe(true)

expect(
collected.trackedDecorations.has(
join(dvcDemoPath, 'static', 'uploads', 'images')
)
).toBe(true)

expect(
collected.trackedDecorations.has(
join(dvcDemoPath, 'static', 'uploads', 'images', '2019-09-26')
)
).toBe(true)
})
})

const makeUri = (...paths: string[]): Uri =>
Expand Down
34 changes: 33 additions & 1 deletion extension/src/repository/model/collect.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { join, relative, resolve } from 'path'
import { join, relative, resolve, sep } from 'path'
import { Uri } from 'vscode'
import { Resource } from '../commands'
import { addToMapSet } from '../../util/map'
Expand Down Expand Up @@ -195,6 +195,33 @@ const uncommitNotInCache = (
return ('un' + status) as ExtendedStatus
}

const collectMissingTracked = (
trackedDecorations: Set<String>,
path: string,
add: boolean
) => {
if (add) {
trackedDecorations.add(path)
}
}

const fillGapsInTrackedDecorations = (
rootDepth: number,
trackedDecorations: Set<string>
) => {
for (const path of trackedDecorations) {
const pathArray = getPathArray(path)
let add = false
for (let idx = rootDepth; idx < pathArray.length; idx++) {
const currPath = getPath(pathArray, idx)
if (trackedDecorations.has(currPath)) {
add = true
}
collectMissingTracked(trackedDecorations, currPath, add)
}
}
}

const collectGroupWithMissingAncestors = (
acc: DataStatusAccumulator,
dvcRoot: string,
Expand All @@ -214,6 +241,11 @@ const collectGroupWithMissingAncestors = (

addToTracked(acc.trackedDecorations, absPath, originalStatus)
}

fillGapsInTrackedDecorations(
dvcRoot.split(sep).length + 1,
acc.trackedDecorations
)
}

export const collectDataStatus = (
Expand Down
20 changes: 8 additions & 12 deletions extension/src/setup/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,8 @@ export class Setup
return this.sendDataToWebview()
}

public getDvcCliDetails(): DvcCliDetails {
private async getDvcCliDetails(): Promise<DvcCliDetails> {
await this.config.isReady()
const dvcPath = this.config.getCliPath()
const pythonBinPath = this.config.getPythonBinPath()
const cwd = getFirstWorkspaceFolder()
Expand All @@ -389,18 +390,14 @@ export class Setup
}
}

private isDVCBeingUsedGlobally() {
const dvcPath = this.config.getCliPath()
const pythonBinPath = this.config.getPythonBinPath()

return dvcPath || !pythonBinPath
}

private async sendDataToWebview() {
const projectInitialized = this.hasRoots()
const hasData = this.getHasData()

const isPythonExtensionUsed = await this.isPythonExtensionUsed()
const [isPythonExtensionUsed, dvcCliDetails] = await Promise.all([
this.isPythonExtensionUsed(),
this.getDvcCliDetails()
])

const needsGitInitialized =
!projectInitialized && !!(await this.needsGitInit())
Expand All @@ -415,10 +412,9 @@ export class Setup
this.webviewMessages.sendWebviewMessage({
canGitInitialize,
cliCompatible: this.getCliCompatible(),
dvcCliDetails: this.getDvcCliDetails(),
dvcCliDetails,
hasData,
isPythonExtensionUsed:
!this.isDVCBeingUsedGlobally() && isPythonExtensionUsed,
isPythonExtensionUsed,
isStudioConnected: this.studioIsConnected,
needsGitCommit,
needsGitInitialized,
Expand Down
Loading

0 comments on commit ed33fd9

Please sign in to comment.