Skip to content

Commit

Permalink
Remove the pip trigger to create environment
Browse files Browse the repository at this point in the history
  • Loading branch information
karthiknadig committed Jul 1, 2024
1 parent c81ef8c commit 59dd823
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 42 deletions.
6 changes: 0 additions & 6 deletions src/client/common/experiments/groups.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,3 @@ export enum EnableTestAdapterRewrite {
export enum RecommendTensobardExtension {
experiment = 'pythonRecommendTensorboardExt',
}

// Experiment to enable triggering venv creation when users install with `pip`
// in a global environment
export enum CreateEnvOnPipInstallTrigger {
experiment = 'pythonCreateEnvOnPipInstall',
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { Disposable, TerminalShellExecutionStartEvent } from 'vscode';
import { CreateEnvOnPipInstallTrigger } from '../../common/experiments/groups';
import { inExperiment } from '../common/externalDependencies';
import {
disableCreateEnvironmentTrigger,
isGlobalPythonSelected,
Expand All @@ -27,7 +25,7 @@ function checkCommand(command: string): boolean {
}

export function registerTriggerForPipInTerminal(disposables: Disposable[]): void {
if (!shouldPromptToCreateEnv() || !inExperiment(CreateEnvOnPipInstallTrigger.experiment)) {
if (!shouldPromptToCreateEnv()) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,12 @@ import * as triggerUtils from '../../../client/pythonEnvironments/creation/commo
import * as windowApis from '../../../client/common/vscodeApis/windowApis';
import * as workspaceApis from '../../../client/common/vscodeApis/workspaceApis';
import * as commandApis from '../../../client/common/vscodeApis/commandApis';
import * as extDepApi from '../../../client/pythonEnvironments/common/externalDependencies';
import { registerTriggerForPipInTerminal } from '../../../client/pythonEnvironments/creation/globalPipInTerminalTrigger';
import { EXTENSION_ROOT_DIR_FOR_TESTS } from '../../constants';
import { Common, CreateEnv } from '../../../client/common/utils/localize';

suite('Global Pip in Terminal Trigger', () => {
let shouldPromptToCreateEnvStub: sinon.SinonStub;
let inExperimentStub: sinon.SinonStub;
let getWorkspaceFoldersStub: sinon.SinonStub;
let getWorkspaceFolderStub: sinon.SinonStub;
let isGlobalPythonSelectedStub: sinon.SinonStub;
Expand All @@ -48,7 +46,6 @@ suite('Global Pip in Terminal Trigger', () => {

setup(() => {
shouldPromptToCreateEnvStub = sinon.stub(triggerUtils, 'shouldPromptToCreateEnv');
inExperimentStub = sinon.stub(extDepApi, 'inExperiment');

getWorkspaceFoldersStub = sinon.stub(workspaceApis, 'getWorkspaceFolders');
getWorkspaceFoldersStub.returns([workspace1]);
Expand Down Expand Up @@ -88,7 +85,6 @@ suite('Global Pip in Terminal Trigger', () => {

test('Should not prompt to create environment if setting is off', async () => {
shouldPromptToCreateEnvStub.returns(false);
inExperimentStub.returns(true);

const disposables: Disposable[] = [];
registerTriggerForPipInTerminal(disposables);
Expand All @@ -97,35 +93,20 @@ suite('Global Pip in Terminal Trigger', () => {
sinon.assert.calledOnce(shouldPromptToCreateEnvStub);
});

test('Should not prompt to create environment if experiment is off', async () => {
shouldPromptToCreateEnvStub.returns(true);
inExperimentStub.returns(false);

const disposables: Disposable[] = [];
registerTriggerForPipInTerminal(disposables);

assert.strictEqual(disposables.length, 0);
sinon.assert.calledOnce(shouldPromptToCreateEnvStub);
sinon.assert.calledOnce(inExperimentStub);
});

test('Should not prompt to create environment if no workspace folders', async () => {
shouldPromptToCreateEnvStub.returns(true);
inExperimentStub.returns(true);
getWorkspaceFoldersStub.returns([]);

const disposables: Disposable[] = [];
registerTriggerForPipInTerminal(disposables);

assert.strictEqual(disposables.length, 0);
sinon.assert.calledOnce(shouldPromptToCreateEnvStub);
sinon.assert.calledOnce(inExperimentStub);
sinon.assert.calledOnce(getWorkspaceFoldersStub);
});

test('Should not prompt to create environment if workspace folder is not found', async () => {
shouldPromptToCreateEnvStub.returns(true);
inExperimentStub.returns(true);
getWorkspaceFolderStub.returns(undefined);

const disposables: Disposable[] = [];
Expand All @@ -136,16 +117,13 @@ suite('Global Pip in Terminal Trigger', () => {

assert.strictEqual(disposables.length, 1);
sinon.assert.calledOnce(shouldPromptToCreateEnvStub);
sinon.assert.calledOnce(inExperimentStub);
sinon.assert.calledOnce(getWorkspaceFolderStub);

sinon.assert.notCalled(isGlobalPythonSelectedStub);
sinon.assert.notCalled(showWarningMessageStub);
});

test('Should not prompt to create environment if global python is not selected', async () => {
shouldPromptToCreateEnvStub.returns(true);
inExperimentStub.returns(true);
isGlobalPythonSelectedStub.returns(false);

const disposables: Disposable[] = [];
Expand All @@ -155,7 +133,6 @@ suite('Global Pip in Terminal Trigger', () => {

assert.strictEqual(disposables.length, 1);
sinon.assert.calledOnce(shouldPromptToCreateEnvStub);
sinon.assert.calledOnce(inExperimentStub);
sinon.assert.calledOnce(getWorkspaceFolderStub);
sinon.assert.calledOnce(isGlobalPythonSelectedStub);

Expand All @@ -164,7 +141,6 @@ suite('Global Pip in Terminal Trigger', () => {

test('Should not prompt to create environment if command is not trusted', async () => {
shouldPromptToCreateEnvStub.returns(true);
inExperimentStub.returns(true);
isGlobalPythonSelectedStub.returns(true);

const disposables: Disposable[] = [];
Expand All @@ -189,7 +165,6 @@ suite('Global Pip in Terminal Trigger', () => {

assert.strictEqual(disposables.length, 1);
sinon.assert.calledOnce(shouldPromptToCreateEnvStub);
sinon.assert.calledOnce(inExperimentStub);
sinon.assert.calledOnce(getWorkspaceFolderStub);
sinon.assert.calledOnce(isGlobalPythonSelectedStub);

Expand All @@ -198,7 +173,6 @@ suite('Global Pip in Terminal Trigger', () => {

test('Should not prompt to create environment if command does not start with pip install', async () => {
shouldPromptToCreateEnvStub.returns(true);
inExperimentStub.returns(true);
isGlobalPythonSelectedStub.returns(true);

const disposables: Disposable[] = [];
Expand All @@ -223,7 +197,6 @@ suite('Global Pip in Terminal Trigger', () => {

assert.strictEqual(disposables.length, 1);
sinon.assert.calledOnce(shouldPromptToCreateEnvStub);
sinon.assert.calledOnce(inExperimentStub);
sinon.assert.calledOnce(getWorkspaceFolderStub);
sinon.assert.calledOnce(isGlobalPythonSelectedStub);

Expand All @@ -233,7 +206,6 @@ suite('Global Pip in Terminal Trigger', () => {
['pip install', 'pip3 install', 'python -m pip install', 'python3 -m pip install'].forEach((command) => {
test(`Should prompt to create environment if all conditions are met: ${command}`, async () => {
shouldPromptToCreateEnvStub.returns(true);
inExperimentStub.returns(true);
isGlobalPythonSelectedStub.returns(true);
showWarningMessageStub.resolves(CreateEnv.Trigger.createEnvironment);

Expand All @@ -259,11 +231,9 @@ suite('Global Pip in Terminal Trigger', () => {

assert.strictEqual(disposables.length, 1);
sinon.assert.calledOnce(shouldPromptToCreateEnvStub);
sinon.assert.calledOnce(inExperimentStub);
sinon.assert.calledOnce(getWorkspaceFolderStub);
sinon.assert.calledOnce(isGlobalPythonSelectedStub);
sinon.assert.calledOnce(showWarningMessageStub);

sinon.assert.calledOnce(executeCommandStub);
sinon.assert.notCalled(disableCreateEnvironmentTriggerStub);

Expand All @@ -273,7 +243,7 @@ suite('Global Pip in Terminal Trigger', () => {

test("Should disable create environment trigger if user selects don't show again", async () => {
shouldPromptToCreateEnvStub.returns(true);
inExperimentStub.returns(true);

isGlobalPythonSelectedStub.returns(true);
showWarningMessageStub.resolves(Common.doNotShowAgain);

Expand All @@ -299,11 +269,9 @@ suite('Global Pip in Terminal Trigger', () => {

assert.strictEqual(disposables.length, 1);
sinon.assert.calledOnce(shouldPromptToCreateEnvStub);
sinon.assert.calledOnce(inExperimentStub);
sinon.assert.calledOnce(getWorkspaceFolderStub);
sinon.assert.calledOnce(isGlobalPythonSelectedStub);
sinon.assert.calledOnce(showWarningMessageStub);

sinon.assert.notCalled(executeCommandStub);
sinon.assert.calledOnce(disableCreateEnvironmentTriggerStub);
});
Expand Down

0 comments on commit 59dd823

Please sign in to comment.