Skip to content

Commit

Permalink
Merge branch 'main' into fix-row-selection
Browse files Browse the repository at this point in the history
  • Loading branch information
mattseddon authored May 19, 2023
2 parents e8c676a + 53b2346 commit aa7bd4e
Show file tree
Hide file tree
Showing 42 changed files with 395 additions and 158 deletions.
4 changes: 3 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module.exports = {
env: {
'jest/globals': true
},

extends: [
'prettier-standard/prettier-file',
'plugin:@typescript-eslint/eslint-recommended',
Expand All @@ -22,7 +23,8 @@ module.exports = {
'**/*.js',
'*.d.ts',
'tsconfig.json',
'webpack.config.ts'
'webpack.config.ts',
'scripts/virtualenv-install.ts'
],
overrides: [
{
Expand Down
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@

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

## [0.8.17] - 2023-05-19

### 🐛 Bug Fixes

- Fix extension initialization on Windows (esm imports broken) [#3937](https://github.com/iterative/vscode-dvc/pull/3937) by [@mattseddon](https://github.com/mattseddon)

### 🔨 Maintenance

- Fix test console errors (add tbody) [#3927](https://github.com/iterative/vscode-dvc/pull/3927) by [@mattseddon](https://github.com/mattseddon)
- Increase timeout of flaky test [#3923](https://github.com/iterative/vscode-dvc/pull/3923) by [@mattseddon](https://github.com/mattseddon)

## [0.8.16] - 2023-05-18

### 🚀 New Features and Enhancements
Expand Down
2 changes: 1 addition & 1 deletion demo
Submodule demo updated 1 files
+1 −1 requirements.txt
17 changes: 13 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": "0.8.16",
"version": "0.8.17",
"license": "Apache-2.0",
"readme": "./README.md",
"repository": {
Expand Down Expand Up @@ -100,6 +100,12 @@
"category": "DVC",
"icon": "$(add)"
},
{
"title": "Add Remote",
"command": "dvc.addRemote",
"category": "DVC",
"icon": "$(add)"
},
{
"title": "Filter Experiments Table to Starred",
"command": "dvc.addStarredExperimentsTableFilter",
Expand Down Expand Up @@ -654,6 +660,10 @@
"command": "dvc.addExperimentsTableSort",
"when": "dvc.commands.available && dvc.project.available"
},
{
"command": "dvc.addRemote",
"when": "dvc.commands.available && dvc.project.available && !dvc.experiment.running.workspace"
},
{
"command": "dvc.addStarredExperimentsTableFilter",
"when": "dvc.commands.available && dvc.project.available"
Expand Down Expand Up @@ -1628,15 +1638,14 @@
"test-vscode": "node ./dist/test/runTest.js",
"test-e2e": "wdio run ./src/test/e2e/wdio.conf.ts",
"test": "jest --collect-coverage",
"setup-venv": "node ./scripts/virtualenv-install.js",
"cover-vscode-run": "node ./scripts/coverIntegrationTests.js",
"vscode:prepublish": ""
},
"dependencies": {
"@hediet/std": "0.6.0",
"@vscode/extension-telemetry": "0.7.7",
"appdirs": "1.1.0",
"execa": "7.1.1",
"execa": "5.1.1",
"fs-extra": "11.1.1",
"js-yaml": "4.1.0",
"json5": "2.2.3",
Expand All @@ -1646,7 +1655,7 @@
"lodash.isequal": "4.5.0",
"lodash.merge": "4.6.2",
"lodash.omit": "4.5.0",
"process-exists": "5.0.0",
"process-exists": "4.1.0",
"tree-kill": "1.2.2",
"uuid": "9.0.0",
"vega-util": "1.17.2",
Expand Down
12 changes: 5 additions & 7 deletions extension/scripts/coverIntegrationTests.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
const { resolve, join } = require('path')
const { writeFileSync } = require('fs-extra')

const getExeca = async () => {
const { execa } = await import('execa')
return execa
}
const execa = require('execa')

let activationEvents = []
let failed
Expand All @@ -22,7 +18,7 @@ activationEvents = packageJson.activationEvents
packageJson.activationEvents = ['onStartupFinished']
writeFileSync(packageJsonPath, JSON.stringify(packageJson))

getExeca().then(async execa => {
const runCover = async () => {
const tests = execa('node', [join(cwd, 'dist', 'test', 'runTest.js')], {
cwd
})
Expand All @@ -43,4 +39,6 @@ getExeca().then(async execa => {
if (failed) {
process.exit(1)
}
})
}

runCover()
13 changes: 0 additions & 13 deletions extension/scripts/virtualenv-install.js

This file was deleted.

5 changes: 4 additions & 1 deletion extension/src/cli/dvc/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export enum Command {
}

export enum SubCommand {
ADD = 'add',
DIFF = 'diff',
LIST = 'list',
STATUS = 'status',
Expand All @@ -47,13 +48,15 @@ export enum SubCommand {
export enum Flag {
ALL_COMMITS = '-A',
FOLLOW = '-f',
DEFAULT = '-d',
FORCE = '-f',
GLOBAL = '--global',
GRANULAR = '--granular',
LOCAL = '--local',
JOBS = '-j',
JSON = '--json',
KILL = '--kill',
LOCAL = '--local',
PROJECT = '--project',
NUM_COMMIT = '-n',
OUTPUT_PATH = '-o',
SUBDIRECTORY = '--subdir',
Expand Down
7 changes: 3 additions & 4 deletions extension/src/cli/dvc/executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ import {
ExperimentSubCommand,
Flag,
GcPreserveFlag,
QueueSubCommand,
SubCommand
QueueSubCommand
} from './constants'
import { addStudioAccessToken } from './options'
import { CliResult, CliStarted, typeCheckCommands } from '..'
Expand Down Expand Up @@ -198,8 +197,8 @@ export class DvcExecutor extends DvcCli {
return this.blockAndExecuteProcess(cwd, Command.REMOVE, ...args)
}

public remote(cwd: string, arg: typeof SubCommand.LIST) {
return this.executeDvcProcess(cwd, Command.REMOTE, arg)
public remote(cwd: string, ...args: Args) {
return this.executeDvcProcess(cwd, Command.REMOTE, ...args)
}

private executeExperimentProcess(cwd: string, ...args: Args) {
Expand Down
2 changes: 2 additions & 0 deletions extension/src/commands/external.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ export enum RegisteredCliCommands {
REMOVE_TARGET = 'dvc.removeTarget',
RENAME_TARGET = 'dvc.renameTarget',

REMOTE_ADD = 'dvc.addRemote',

GIT_STAGE_ALL = 'dvc.gitStageAll',
GIT_UNSTAGE_ALL = 'dvc.gitUnstageAll'
}
Expand Down
6 changes: 2 additions & 4 deletions extension/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,9 @@ import { Flag } from './cli/dvc/constants'
import { LanguageClient } from './languageClient'
import { collectRunningExperimentPids } from './experiments/processExecution/collect'
import { DvcViewer } from './cli/dvc/viewer'
import { registerSetupCommands } from './setup/register'
import { registerSetupCommands } from './setup/commands/register'
import { Status } from './status'
import { registerPersistenceCommands } from './persistence/register'
import { esmPackagesImported } from './util/esm'

class Extension extends Disposable {
protected readonly internalCommands: InternalCommands
Expand Down Expand Up @@ -304,8 +303,7 @@ class Extension extends Disposable {

let extension: undefined | Extension

export async function activate(context: ExtensionContext): Promise<void> {
await esmPackagesImported
export function activate(context: ExtensionContext): void {
extension = new Extension(context)
context.subscriptions.push(extension)
}
Expand Down
32 changes: 32 additions & 0 deletions extension/src/process/execution.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import process from 'process'
import { executeProcess, processExists } from './execution'

describe('executeProcess', () => {
it('should be able to run a process', async () => {
const output = await executeProcess({
args: ['some', 'text'],
cwd: __dirname,
executable: 'echo'
})
expect(output).toMatch(/some.*text/)
})

it('should return the stderr if the process throws with stderr', async () => {
await expect(
executeProcess({
args: ['me', 'outside'],
cwd: __dirname,
executable: 'find'
})
).rejects.toBeTruthy()
})
})

describe('processExists', () => {
it('should return true if the process exists', async () => {
expect(await processExists(process.pid)).toBe(true)
})
it('should return false if it does not', async () => {
expect(await processExists(-123.321)).toBe(false)
})
})
3 changes: 2 additions & 1 deletion extension/src/process/execution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ import { ChildProcess } from 'child_process'
import { Readable } from 'stream'
import { Event, EventEmitter } from 'vscode'
import { Disposable } from '@hediet/std/disposable'
import execa from 'execa'
import doesProcessExist from 'process-exists'
import kill from 'tree-kill'
import { getProcessPlatform } from '../env'
import { doesProcessExist, execa } from '../util/esm'

interface RunningProcess extends ChildProcess {
all?: Readable
Expand Down
1 change: 0 additions & 1 deletion extension/src/python/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { getProcessPlatform } from '../env'

jest.mock('../env')
jest.mock('../process/execution')
jest.mock('../util/esm')

const mockedGetProcessPlatform = jest.mocked(getProcessPlatform)
const mockedCreateProcess = jest.mocked(createProcess)
Expand Down
2 changes: 0 additions & 2 deletions extension/src/python/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { getProcessPlatform } from '../env'
import { exists } from '../fileSystem'
import { Logger } from '../common/logger'
import { createProcess, executeProcess, Process } from '../process/execution'
import { esmPackagesImported } from '../util/esm'

const sendOutput = (process: Process) => {
process.all?.on('data', chunk =>
Expand Down Expand Up @@ -35,7 +34,6 @@ export const setupTestVenv = async (
envDir: string,
...installArgs: string[]
) => {
await esmPackagesImported
if (!exists(join(cwd, envDir))) {
const initVenv = createProcess({
args: ['-m', 'venv', envDir],
Expand Down
86 changes: 86 additions & 0 deletions extension/src/setup/commands/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
import { Setup } from '..'
import { Flag, SubCommand } from '../../cli/dvc/constants'
import { AvailableCommands, InternalCommands } from '../../commands/internal'
import { definedAndNonEmpty } from '../../util/array'
import { getInput } from '../../vscode/inputBox'
import { quickPickYesOrNo } from '../../vscode/quickPick'
import { Title } from '../../vscode/title'
import { Toast } from '../../vscode/toast'
import { getOnlyOrPickProject } from '../../workspace/util'

const noExistingOrUserConfirms = async (
internalCommands: InternalCommands,
dvcRoot: string
): Promise<boolean | undefined> => {
const remoteList = await internalCommands.executeCommand(
AvailableCommands.REMOTE,
dvcRoot,
SubCommand.LIST
)

if (!remoteList) {
return true
}

return await quickPickYesOrNo(
'make this new remote the default',
'keep the current default',
{
placeHolder: 'Would you like to set this new remote as the default?',
title: Title.SET_REMOTE_AS_DEFAULT
}
)
}

const addRemoteToProject = async (
internalCommands: InternalCommands,
dvcRoot: string
): Promise<void> => {
const name = await getInput(Title.ENTER_REMOTE_NAME)
if (!name) {
return
}

const url = await getInput(Title.ENTER_REMOTE_URL)
if (!url) {
return
}

const args = [Flag.PROJECT, name, url]

const shouldSetAsDefault = await noExistingOrUserConfirms(
internalCommands,
dvcRoot
)
if (shouldSetAsDefault === undefined) {
return
}

if (shouldSetAsDefault) {
args.unshift(Flag.DEFAULT)
}

return await Toast.showOutput(
internalCommands.executeCommand(
AvailableCommands.REMOTE,
dvcRoot,
SubCommand.ADD,
...args
)
)
}

export const getAddRemoteCommand =
(setup: Setup, internalCommands: InternalCommands) =>
async (): Promise<void> => {
const dvcRoots = setup.getRoots()
if (!definedAndNonEmpty(dvcRoots)) {
return Toast.showError('Cannot add a remote without a DVC project')
}
const dvcRoot = await getOnlyOrPickProject(dvcRoots)

if (!dvcRoot) {
return
}
return addRemoteToProject(internalCommands, dvcRoot)
}
Loading

0 comments on commit aa7bd4e

Please sign in to comment.