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

Enlist in native notebook experiment if sync'd settings is forcing it anyway #4925

Merged
merged 2 commits into from
Feb 23, 2021
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
([#4779](https://github.com/Microsoft/vscode-jupyter/issues/4779))
1. Allow kernels to not be handled by the jupyter extension.
([#4423](https://github.com/Microsoft/vscode-jupyter/issues/4423)
1. Enable native notebook if sync'd settings is forcing it.
([#4845](https://github.com/Microsoft/vscode-jupyter/issues/4845)

## 2021.2.0 (17 February 2021)

Expand Down
15 changes: 13 additions & 2 deletions src/client/common/experiments/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { Memento } from 'vscode';
import { getExperimentationService, IExperimentationService, TargetPopulation } from 'vscode-tas-client';
import { sendTelemetryEvent } from '../../telemetry';
import { EventName } from '../../telemetry/constants';
import { IApplicationEnvironment } from '../application/types';
import { IApplicationEnvironment, IWorkspaceService } from '../application/types';
import { JVSC_EXTENSION_ID, STANDARD_OUTPUT_CHANNEL } from '../constants';
import {
GLOBAL_MEMENTO,
Expand Down Expand Up @@ -47,7 +47,8 @@ export class ExperimentService implements IExperimentService {
@inject(IApplicationEnvironment) private readonly appEnvironment: IApplicationEnvironment,
@inject(IMemento) @named(GLOBAL_MEMENTO) private readonly globalState: Memento,
@inject(IOutputChannel) @named(STANDARD_OUTPUT_CHANNEL) private readonly output: IOutputChannel,
@inject(IExtensions) private readonly extensions: IExtensions
@inject(IExtensions) private readonly extensions: IExtensions,
@inject(IWorkspaceService) workspaceService: IWorkspaceService
) {
this.settings = configurationService.getSettings(undefined);

Expand All @@ -57,6 +58,16 @@ export class ExperimentService implements IExperimentService {
this._optInto = optInto.filter((exp) => !exp.endsWith('control'));
this._optOutFrom = optOutFrom.filter((exp) => !exp.endsWith('control'));

// Custom settings just for native notebook support.
const settings = workspaceService.getConfiguration('workbench', undefined);
const editorAssociations = settings.get('editorAssociations') as {
viewType: string;
filenamePattern: string;
}[];
if (editorAssociations.find((a) => a.viewType && a.viewType.includes('jupyter-notebook'))) {
this._optInto.push(`__${ExperimentGroups.NativeNotebook}__`);
}

// Don't initialize the experiment service if the extension's experiments setting is disabled.
const enabled = this.settings.experiments.enabled;
if (!enabled) {
Expand Down
56 changes: 40 additions & 16 deletions src/test/common/experiments/service.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import { anything, instance, mock, when } from 'ts-mockito';
import * as tasClient from 'vscode-tas-client';
import { ApplicationEnvironment } from '../../../client/common/application/applicationEnvironment';
import { Extensions } from '../../../client/common/application/extensions';
import { Channel, IApplicationEnvironment } from '../../../client/common/application/types';
import { Channel, IApplicationEnvironment, IWorkspaceService } from '../../../client/common/application/types';
import { WorkspaceService } from '../../../client/common/application/workspace';
import { ConfigurationService } from '../../../client/common/configuration/service';
import { ExperimentService } from '../../../client/common/experiments/service';
import { IConfigurationService, IExtensions } from '../../../client/common/types';
Expand All @@ -28,13 +29,21 @@ suite('Experimentation service', () => {
let globalMemento: MockMemento;
let outputChannel: MockOutputChannel;
let extensionService: IExtensions;
let workspace: IWorkspaceService;

setup(() => {
configurationService = mock(ConfigurationService);
appEnvironment = mock(ApplicationEnvironment);
globalMemento = new MockMemento();
outputChannel = new MockOutputChannel('');
extensionService = instance(mock(Extensions));
workspace = mock(WorkspaceService);
when(workspace.getConfiguration(anything(), anything())).thenReturn({
get: () => [],
has: () => false,
inspect: () => undefined,
update: () => Promise.resolve()
});
});

teardown(() => {
Expand Down Expand Up @@ -72,7 +81,8 @@ suite('Experimentation service', () => {
instance(appEnvironment),
globalMemento,
outputChannel,
extensionService
extensionService,
instance(workspace)
);

sinon.assert.calledWithExactly(
Expand All @@ -97,7 +107,8 @@ suite('Experimentation service', () => {
instance(appEnvironment),
globalMemento,
outputChannel,
extensionService
extensionService,
instance(workspace)
);

sinon.assert.calledWithExactly(
Expand All @@ -121,7 +132,8 @@ suite('Experimentation service', () => {
instance(appEnvironment),
globalMemento,
outputChannel,
extensionService
extensionService,
instance(workspace)
);

assert.deepEqual(experimentService._optInto, ['Foo - experiment']);
Expand All @@ -137,7 +149,8 @@ suite('Experimentation service', () => {
instance(appEnvironment),
globalMemento,
outputChannel,
extensionService
extensionService,
instance(workspace)
);

assert.deepEqual(experimentService._optOutFrom, ['Foo - experiment']);
Expand All @@ -157,7 +170,8 @@ suite('Experimentation service', () => {
instance(appEnvironment),
instance(globalMemento),
outputChannel,
extensionService
extensionService,
instance(workspace)
);
const output = `${Experiments.inGroup().format('pythonExperiment')}\n`;

Expand Down Expand Up @@ -201,7 +215,8 @@ suite('Experimentation service', () => {
instance(appEnvironment),
globalMemento,
outputChannel,
extensionService
extensionService,
instance(workspace)
);
const result = await experimentService.inExperiment(experiment);

Expand All @@ -218,7 +233,8 @@ suite('Experimentation service', () => {
instance(appEnvironment),
globalMemento,
outputChannel,
extensionService
extensionService,
instance(workspace)
);
const result = await experimentService.inExperiment(experiment);

Expand All @@ -235,7 +251,8 @@ suite('Experimentation service', () => {
instance(appEnvironment),
globalMemento,
outputChannel,
extensionService
extensionService,
instance(workspace)
);
const result = await experimentService.inExperiment(experiment);

Expand All @@ -256,7 +273,8 @@ suite('Experimentation service', () => {
instance(appEnvironment),
globalMemento,
outputChannel,
extensionService
extensionService,
instance(workspace)
);
const result = await experimentService.inExperiment(experiment);

Expand All @@ -277,7 +295,8 @@ suite('Experimentation service', () => {
instance(appEnvironment),
globalMemento,
outputChannel,
extensionService
extensionService,
instance(workspace)
);
const result = await experimentService.inExperiment(experiment);

Expand All @@ -298,7 +317,8 @@ suite('Experimentation service', () => {
instance(appEnvironment),
globalMemento,
outputChannel,
extensionService
extensionService,
instance(workspace)
);
const result = await experimentService.inExperiment(experiment);

Expand Down Expand Up @@ -334,7 +354,8 @@ suite('Experimentation service', () => {
instance(appEnvironment),
globalMemento,
outputChannel,
extensionService
extensionService,
instance(workspace)
);
const result = await experimentService.getExperimentValue(experiment);

Expand All @@ -350,7 +371,8 @@ suite('Experimentation service', () => {
instance(appEnvironment),
globalMemento,
outputChannel,
extensionService
extensionService,
instance(workspace)
);
const result = await experimentService.getExperimentValue(experiment);

Expand All @@ -366,7 +388,8 @@ suite('Experimentation service', () => {
instance(appEnvironment),
globalMemento,
outputChannel,
extensionService
extensionService,
instance(workspace)
);
const result = await experimentService.getExperimentValue(experiment);

Expand All @@ -382,7 +405,8 @@ suite('Experimentation service', () => {
instance(appEnvironment),
globalMemento,
outputChannel,
extensionService
extensionService,
instance(workspace)
);
const result = await experimentService.getExperimentValue(experiment);

Expand Down