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… #4927

Merged
merged 1 commit 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
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# Changelog

## 2021.2.1 (28 February 2021)

### Fixes

1. Popup a tip when opening a notebook for the first time.
([#4775](https://github.com/Microsoft/vscode-jupyter/issues/4775))
1. Ensure we save the contents when closing a (webview based) notebook.
([#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)

### Enhancements
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'))) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ewww, all of these hacks make me go 🤮
But i don't see any other way around it, not complaining about your code, just the hacks we have for native notebooks & experiments (opting in & out...) too complicated

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. I hate the experiments stuff too.

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
59 changes: 42 additions & 17 deletions src/test/common/experiments/service.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ import * as sinon from 'sinon';
import { anything, instance, mock, when } from 'ts-mockito';
import * as tasClient from 'vscode-tas-client';
import { ApplicationEnvironment } from '../../../client/common/application/applicationEnvironment';
import { Channel, IApplicationEnvironment } from '../../../client/common/application/types';
import { Extensions } from '../../../client/common/application/extensions';
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 +30,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 = new MockExtensions();
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 +82,8 @@ suite('Experimentation service', () => {
instance(appEnvironment),
globalMemento,
outputChannel,
extensionService
extensionService,
instance(workspace)
);

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

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

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

assert.deepEqual(experimentService._optOutFrom, ['Foo - experiment']);
Expand All @@ -157,7 +171,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 +216,8 @@ suite('Experimentation service', () => {
instance(appEnvironment),
globalMemento,
outputChannel,
extensionService
extensionService,
instance(workspace)
);
const result = await experimentService.inExperiment(experiment);

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

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

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

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

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

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

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

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

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

Expand Down