Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Group process execution and manager #3356

Merged
merged 1 commit into from
Feb 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions extension/src/cli/dvc/executor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import { Disposable, Disposer } from '@hediet/std/disposable'
import { Flag, GcPreserveFlag } from './constants'
import { DvcExecutor } from './executor'
import { CliResult, CliStarted } from '..'
import { createProcess } from '../../processExecution'
import { createProcess } from '../../process/execution'
import { getMockedProcess } from '../../test/util/jest'
import { getProcessEnv } from '../../env'
import { Config } from '../../config'
import { ContextKey, setContextValue } from '../../vscode/context'

jest.mock('vscode')
jest.mock('@hediet/std/disposable')
jest.mock('../../processExecution')
jest.mock('../../process/execution')
jest.mock('../../env')
jest.mock('../../vscode/context')

Expand Down
4 changes: 2 additions & 2 deletions extension/src/cli/dvc/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import { DvcCli } from '.'
import { Command } from './constants'
import { CliResult, CliStarted, typeCheckCommands } from '..'
import { getProcessEnv } from '../../env'
import { createProcess } from '../../processExecution'
import { createProcess } from '../../process/execution'
import { getFailingMockedProcess, getMockedProcess } from '../../test/util/jest'
import { Config } from '../../config'
import { joinEnvPath } from '../../util/env'

jest.mock('vscode')
jest.mock('@hediet/std/disposable')
jest.mock('../../env')
jest.mock('../../processExecution')
jest.mock('../../process/execution')

const mockedDisposable = jest.mocked(Disposable)

Expand Down
2 changes: 1 addition & 1 deletion extension/src/cli/dvc/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Args } from './constants'
import { getCaseSensitiveCwd } from './cwd'
import { getProcessEnv } from '../../env'
import { joinEnvPath } from '../../util/env'
import { ProcessOptions } from '../../processExecution'
import { ProcessOptions } from '../../process/execution'

type ExecutionOptions = ProcessOptions & {
env: NodeJS.ProcessEnv
Expand Down
4 changes: 2 additions & 2 deletions extension/src/cli/dvc/reader.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { EXPERIMENT_WORKSPACE_ID } from './contract'
import { DvcReader } from './reader'
import { CliResult, CliStarted } from '..'
import { MaybeConsoleError } from '../error'
import { createProcess } from '../../processExecution'
import { createProcess } from '../../process/execution'
import { getFailingMockedProcess, getMockedProcess } from '../../test/util/jest'
import { getProcessEnv } from '../../env'
import expShowFixture from '../../test/fixtures/expShow/base/output'
Expand All @@ -16,7 +16,7 @@ import { Config } from '../../config'
jest.mock('vscode')
jest.mock('@hediet/std/disposable')
jest.mock('fs')
jest.mock('../../processExecution')
jest.mock('../../process/execution')
jest.mock('../../env')
jest.mock('../../common/logger')

Expand Down
2 changes: 1 addition & 1 deletion extension/src/cli/dvc/runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { CliResult, CliStarted, ICli, typeCheckCommands } from '..'
import { getCommandString } from '../command'
import { Config } from '../../config'
import { PseudoTerminal } from '../../vscode/pseudoTerminal'
import { createProcess, Process } from '../../processExecution'
import { createProcess, Process } from '../../process/execution'
import { StopWatch } from '../../util/time'
import { sendErrorTelemetryEvent, sendTelemetryEvent } from '../../telemetry'
import { EventName } from '../../telemetry/constants'
Expand Down
2 changes: 1 addition & 1 deletion extension/src/cli/error.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ProcessOptions } from '../processExecution'
import { ProcessOptions } from '../process/execution'

export interface MaybeConsoleError extends Error {
stderr?: string
Expand Down
4 changes: 2 additions & 2 deletions extension/src/cli/git/executor.test.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { EventEmitter } from 'vscode'
import { Disposable, Disposer } from '@hediet/std/disposable'
import { GitExecutor } from './executor'
import { createProcess } from '../../processExecution'
import { createProcess } from '../../process/execution'
import { CliResult, CliStarted } from '..'
import { getMockedProcess } from '../../test/util/jest'
import { standardizePath } from '../../fileSystem/path'

jest.mock('vscode')
jest.mock('@hediet/std/disposable')
jest.mock('../../processExecution')
jest.mock('../../process/execution')

const mockedDisposable = jest.mocked(Disposable)

Expand Down
2 changes: 1 addition & 1 deletion extension/src/cli/git/options.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Args } from './constants'
import { ProcessOptions } from '../../processExecution'
import { ProcessOptions } from '../../process/execution'

export const getOptions = (cwd: string, ...args: Args): ProcessOptions => ({
args,
Expand Down
2 changes: 1 addition & 1 deletion extension/src/cli/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Event, EventEmitter } from 'vscode'
import { CliError, MaybeConsoleError } from './error'
import { getCommandString } from './command'
import { createProcess, Process, ProcessOptions } from '../processExecution'
import { createProcess, Process, ProcessOptions } from '../process/execution'
import { StopWatch } from '../util/time'
import { Disposable } from '../class/dispose'

Expand Down
2 changes: 1 addition & 1 deletion extension/src/data/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { relative } from 'path'
import { EventEmitter, Event } from 'vscode'
import { getRelativePattern } from '../fileSystem/relativePattern'
import { createFileSystemWatcher } from '../fileSystem/watcher'
import { ProcessManager } from '../processManager'
import { ProcessManager } from '../process/manager'
import { InternalCommands } from '../commands/internal'
import { ExperimentsOutput, PlotsOutputOrError } from '../cli/dvc/contract'
import { uniqueValues } from '../util/array'
Expand Down
2 changes: 1 addition & 1 deletion extension/src/experiments/processExecution/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { join } from 'path'
import { EXP_RWLOCK_FILE } from '../../cli/dvc/constants'
import { getPidFromFile } from '../../fileSystem'
import { Toast } from '../../vscode/toast'
import { processExists, stopProcesses } from '../../processExecution'
import { processExists, stopProcesses } from '../../process/execution'

export const stopWorkspaceExperiment = async (dvcRoot: string) => {
const pid = await getPidFromFile(join(dvcRoot, EXP_RWLOCK_FILE))
Expand Down
2 changes: 1 addition & 1 deletion extension/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ import { GitExecutor } from './cli/git/executor'
import { GitReader } from './cli/git/reader'
import { Setup } from './setup'
import { definedAndNonEmpty } from './util/array'
import { stopProcesses } from './processExecution'
import { stopProcesses } from './process/execution'
import { Flag } from './cli/dvc/constants'
import { LanguageClient } from './languageClient'
import { collectRunningExperimentPids } from './experiments/processExecution/collect'
Expand Down
4 changes: 2 additions & 2 deletions extension/src/extensions/python.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import {
getOnDidChangePythonExecutionDetails,
VscodePython
} from './python'
import { executeProcess } from '../processExecution'
import { executeProcess } from '../process/execution'

jest.mock('vscode')
jest.mock('../processExecution')
jest.mock('../process/execution')

const mockedExecuteProcess = jest.mocked(executeProcess)

Expand Down
2 changes: 1 addition & 1 deletion extension/src/fileSystem/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { definedAndNonEmpty } from '../util/array'
import { Logger } from '../common/logger'
import { gitPath } from '../cli/git/constants'
import { createValidInteger } from '../util/number'
import { processExists } from '../processExecution'
import { processExists } from '../process/execution'
import { getFirstWorkspaceFolder } from '../vscode/workspaceFolders'
import { DOT_DVC } from '../cli/dvc/constants'
import { delay } from '../util/time'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import process from 'process'
import { executeProcess, processExists } from './processExecution'
import { executeProcess, processExists } from './execution'

describe('executeProcess', () => {
it('should be able to run a process', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Disposable } from '@hediet/std/disposable'
import execa from 'execa'
import doesProcessExists from 'process-exists'
import kill from 'tree-kill'
import { getProcessPlatform } from './env'
import { getProcessPlatform } from '../env'

interface RunningProcess extends ChildProcess {
all?: Readable
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { EventEmitter } from 'vscode'
import { getCurrentEpoch } from './util/time'
import { Disposable } from './class/dispose'
import { getCurrentEpoch } from '../util/time'
import { Disposable } from '../class/dispose'

export const DEFAULT_DEBOUNCE_WINDOW_MS = 200

Expand Down
4 changes: 2 additions & 2 deletions extension/src/python/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { join } from 'path'
import { setupVenv } from '.'
import { Process, createProcess } from '../processExecution'
import { Process, createProcess } from '../process/execution'
import { getProcessPlatform } from '../env'

jest.mock('../env')
jest.mock('../processExecution')
jest.mock('../process/execution')

const mockedGetProcessPlatform = jest.mocked(getProcessPlatform)
const mockedCreateProcess = jest.mocked(createProcess)
Expand Down
2 changes: 1 addition & 1 deletion extension/src/python/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { getVenvBinPath } from './path'
import { getProcessPlatform } from '../env'
import { exists } from '../fileSystem'
import { Logger } from '../common/logger'
import { createProcess, executeProcess, Process } from '../processExecution'
import { createProcess, executeProcess, Process } from '../process/execution'

const sendOutput = (process: Process) => {
process.all?.on('data', chunk =>
Expand Down
2 changes: 1 addition & 1 deletion extension/src/repository/data/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Event, EventEmitter } from 'vscode'
import { AvailableCommands, InternalCommands } from '../../commands/internal'
import { ProcessManager } from '../../processManager'
import { ProcessManager } from '../../process/manager'
import { getRelativePattern } from '../../fileSystem/relativePattern'
import {
createFileSystemWatcher,
Expand Down
4 changes: 2 additions & 2 deletions extension/src/setup/runner.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { getFirstWorkspaceFolder } from '../vscode/workspaceFolders'
import { Toast } from '../vscode/toast'
import { Response } from '../vscode/response'
import { VscodePython } from '../extensions/python'
import { executeProcess } from '../processExecution'
import { executeProcess } from '../process/execution'
import {
LATEST_TESTED_CLI_VERSION,
MAX_CLI_VERSION,
Expand All @@ -34,7 +34,7 @@ jest.mock('../vscode/resourcePicker')
jest.mock('../vscode/quickPick')
jest.mock('../vscode/toast')
jest.mock('../vscode/workspaceFolders')
jest.mock('../processExecution')
jest.mock('../process/execution')

const mockedExtensions = jest.mocked(extensions)
const mockedCommands = jest.mocked(commands)
Expand Down
2 changes: 1 addition & 1 deletion extension/src/test/suite/cli/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { EventEmitter } from 'vscode'
import kill from 'tree-kill'
import { getOptions } from './util'
import { getTimeSafeDisposer } from '../util'
import { createProcess, processExists } from '../../../processExecution'
import { createProcess, processExists } from '../../../process/execution'
import { createValidInteger } from '../../../util/number'
import { Cli, CliEvent, CliResult } from '../../../cli'

Expand Down
2 changes: 1 addition & 1 deletion extension/src/test/suite/cli/util.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { join } from 'path'
import type { ProcessOptions } from '../../../processExecution'
import type { ProcessOptions } from '../../../process/execution'

export const getOptions = (file: 'child' | 'background'): ProcessOptions => ({
args: [join(__dirname, `${file}.js`)],
Expand Down
2 changes: 1 addition & 1 deletion extension/src/test/suite/experiments/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ import * as Time from '../../../util/time'
import { AvailableCommands } from '../../../commands/internal'
import { Setup } from '../../../setup'
import * as FileSystem from '../../../fileSystem'
import * as ProcessExecution from '../../../processExecution'
import * as ProcessExecution from '../../../process/execution'
import { DvcReader } from '../../../cli/dvc/reader'
import { Connect } from '../../../connect'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { afterEach, beforeEach, describe, it, suite } from 'mocha'
import { expect } from 'chai'
import { restore, stub } from 'sinon'
import { EventEmitter } from 'vscode'
import { Disposable } from '../../extension'
import { ProcessManager } from '../../processManager'
import { delay } from '../../util/time'
import { Disposable } from '../../../extension'
import { ProcessManager } from '../../../process/manager'
import { delay } from '../../../util/time'

suite('Process Manager Test Suite', () => {
const disposable = Disposable.fn()
Expand Down
2 changes: 1 addition & 1 deletion extension/src/test/suite/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import plotsDiffFixture from '../fixtures/plotsDiff/output'
import { BaseWebview } from '../../webview'
import { ExperimentsData } from '../../experiments/data'
import { ResourceLocator } from '../../resourceLocator'
import { DEFAULT_DEBOUNCE_WINDOW_MS } from '../../processManager'
import { DEFAULT_DEBOUNCE_WINDOW_MS } from '../../process/manager'
import { FileSystemData } from '../../fileSystem/data'
import * as FileSystem from '../../fileSystem'
import * as Watcher from '../../fileSystem/watcher'
Expand Down
2 changes: 1 addition & 1 deletion extension/src/test/util/jest/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { EventEmitter } from 'vscode'
import { Experiments } from '../../../experiments'
import { WorkspaceExperiments } from '../../../experiments/workspace'
import { Process } from '../../../processExecution'
import { Process } from '../../../process/execution'

export const getMockedProcess = (stdout: string): Process =>
({
Expand Down