Skip to content

Commit bc24806

Browse files
authored
Single experiment group for nb editors (#12301)
1 parent daa467d commit bc24806

10 files changed

Lines changed: 37 additions & 45 deletions

File tree

experiments.json

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -113,18 +113,6 @@
113113
"min": 0,
114114
"max": 100
115115
},
116-
{
117-
"name": "NativeNotebook - experiment",
118-
"salt": "NativeNotebook",
119-
"max": 0,
120-
"min": 0
121-
},
122-
{
123-
"name": "NativeNotebook - control",
124-
"salt": "NativeNotebook",
125-
"min": 0,
126-
"max": 100
127-
},
128116
{
129117
"name": "CollectLSRequestTiming - experiment",
130118
"salt": "CollectLSRequestTiming",
@@ -196,6 +184,11 @@
196184
"salt": "CustomEditorSupport",
197185
"max": 0,
198186
"min": 0
187+
},
188+
{
189+
"name": "NativeNotebook - experiment",
190+
"salt": "CustomEditorSupport",
191+
"max": 0,
192+
"min": 0
199193
}
200-
201194
]

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1674,6 +1674,7 @@
16741674
"AA_testing - experiment",
16751675
"LocalZMQKernel - experiment",
16761676
"NativeNotebook - experiment",
1677+
"CustomEditorSupport - experiment",
16771678
"UseTerminalToGetActivatedEnvVars - experiment",
16781679
"CollectLSRequestTiming - experiment",
16791680
"CollectNodeLSRequestTiming - experiment",
@@ -1699,6 +1700,7 @@
16991700
"AA_testing - experiment",
17001701
"LocalZMQKernel - experiment",
17011702
"NativeNotebook - experiment",
1703+
"CustomEditorSupport - experiment",
17021704
"UseTerminalToGetActivatedEnvVars - experiment",
17031705
"CollectLSRequestTiming - experiment",
17041706
"CollectNodeLSRequestTiming - experiment",

src/client/common/application/notebook.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import type {
1414
NotebookOutputSelector
1515
} from 'vscode-proposed';
1616
import { UseProposedApi } from '../constants';
17-
import { NativeNotebook } from '../experiments/groups';
17+
import { NotebookEditorSupport } from '../experiments/groups';
1818
import { IDisposableRegistry, IExperimentsManager } from '../types';
1919
import {
2020
IVSCodeNotebook,
@@ -66,7 +66,7 @@ export class VSCodeNotebook implements IVSCodeNotebook {
6666
@inject(IDisposableRegistry) private readonly disposables: IDisposableRegistry,
6767
@inject(IExperimentsManager) readonly experimentManager: IExperimentsManager
6868
) {
69-
if (this.useProposedApi && experimentManager.inExperiment(NativeNotebook.experiment)) {
69+
if (this.useProposedApi && experimentManager.inExperiment(NotebookEditorSupport.nativeNotebookExperiment)) {
7070
this.addEventHandlers();
7171
}
7272
}

src/client/common/experiments/groups.ts

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,6 @@ export enum LocalZMQKernel {
3737
experiment = 'LocalZMQKernel - experiment'
3838
}
3939

40-
// Experiment to use VSC Notebook Implementation
41-
export enum NativeNotebook {
42-
control = 'NativeNotebook - control',
43-
experiment = 'NativeNotebook - experiment'
44-
}
45-
4640
// Experiment for supporting run by line in data science notebooks
4741
export enum RunByLine {
4842
control = 'RunByLine - control',
@@ -93,9 +87,10 @@ export enum DeprecatePythonPath {
9387
}
9488

9589
/*
96-
* Experiment to turn on custom editor API support.
90+
* Experiment to turn on custom editor or VS Code Native Notebook API support.
9791
*/
98-
export enum CustomEditorSupport {
92+
export enum NotebookEditorSupport {
9993
control = 'CustomEditorSupport - control',
100-
experiment = 'CustomEditorSupport - experiment'
94+
customEditorExperiment = 'CustomEditorSupport - experiment',
95+
nativeNotebookExperiment = 'NativeNotebook - experiment'
10196
}

src/client/common/experiments/manager.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import {
2828
import { sleep } from '../utils/async';
2929
import { swallowExceptions } from '../utils/decorators';
3030
import { Experiments } from '../utils/localize';
31-
import { NativeNotebook } from './groups';
31+
import { NotebookEditorSupport } from './groups';
3232

3333
const EXPIRY_DURATION_MS = 30 * 60 * 1000;
3434
export const isDownloadedStorageValidKey = 'IS_EXPERIMENTS_STORAGE_VALID_KEY';
@@ -158,7 +158,7 @@ export class ExperimentsManager implements IExperimentsManager {
158158
for (const experiment of this.experimentStorage.value) {
159159
// User cannot belong to NotebookExperiment if they are not using Insiders.
160160
if (
161-
(experiment.name === NativeNotebook.experiment || experiment.name === NativeNotebook.control) &&
161+
experiment.name === NotebookEditorSupport.nativeNotebookExperiment &&
162162
this.appEnvironment.channel === 'stable'
163163
) {
164164
continue;

src/client/datascience/context/activeEditorContext.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { IExtensionSingleActivationService } from '../../activation/types';
99
import { ICommandManager, IDocumentManager, IVSCodeNotebook } from '../../common/application/types';
1010
import { PYTHON_LANGUAGE } from '../../common/constants';
1111
import { ContextKey } from '../../common/contextKey';
12-
import { NativeNotebook } from '../../common/experiments/groups';
12+
import { NotebookEditorSupport } from '../../common/experiments/groups';
1313
import { IDisposable, IDisposableRegistry, IExperimentsManager } from '../../common/types';
1414
import { EditorContexts } from '../constants';
1515
import { IInteractiveWindow, IInteractiveWindowProvider, INotebookEditor, INotebookEditorProvider } from '../types';
@@ -72,7 +72,7 @@ export class ActiveEditorContextService implements IExtensionSingleActivationSer
7272
if (this.docManager.activeTextEditor?.document.languageId === PYTHON_LANGUAGE) {
7373
this.onDidChangeActiveTextEditor(this.docManager.activeTextEditor);
7474
}
75-
if (this.experiments.inExperiment(NativeNotebook.experiment)) {
75+
if (this.experiments.inExperiment(NotebookEditorSupport.nativeNotebookExperiment)) {
7676
this.vscodeNotebook.onDidChangeNotebookDocument(this.onDidChangeVSCodeNotebook, this, this.disposables);
7777
this.vscodeNotebook.onDidCloseNotebookDocument(this.onDidChangeVSCodeNotebook, this, this.disposables);
7878
this.vscodeNotebook.onDidOpenNotebookDocument(this.onDidChangeVSCodeNotebook, this, this.disposables);
@@ -81,7 +81,7 @@ export class ActiveEditorContextService implements IExtensionSingleActivationSer
8181
}
8282

8383
private udpateNativeNotebookCellContext() {
84-
if (!this.experiments.inExperiment(NativeNotebook.experiment)) {
84+
if (!this.experiments.inExperiment(NotebookEditorSupport.nativeNotebookExperiment)) {
8585
return;
8686
}
8787
this.hasNativeNotebookCells

src/client/datascience/notebook/cellEditSyncService.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import type { NotebookCell, NotebookDocument } from '../../../../typings/vscode-
77
import { splitMultilineString } from '../../../datascience-ui/common';
88
import { IExtensionSingleActivationService } from '../../activation/types';
99
import { IDocumentManager, IVSCodeNotebook } from '../../common/application/types';
10-
import { NativeNotebook } from '../../common/experiments/groups';
10+
import { NotebookEditorSupport } from '../../common/experiments/groups';
1111
import { IDisposable, IDisposableRegistry, IExperimentsManager } from '../../common/types';
1212
import { isNotebookCell } from '../../common/utils/misc';
1313
import { traceError } from '../../logging';
@@ -33,7 +33,7 @@ export class CellEditSyncService implements IExtensionSingleActivationService, I
3333
}
3434
}
3535
public async activate(): Promise<void> {
36-
if (!this.experiment.inExperiment(NativeNotebook.experiment)) {
36+
if (!this.experiment.inExperiment(NotebookEditorSupport.nativeNotebookExperiment)) {
3737
return;
3838
}
3939
this.documentManager.onDidChangeTextDocument(this.onDidChangeTextDocument, this, this.disposables);

src/client/datascience/notebook/integration.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { inject, injectable } from 'inversify';
55
import * as path from 'path';
66
import { IExtensionSingleActivationService } from '../../activation/types';
77
import { ICommandManager, IVSCodeNotebook } from '../../common/application/types';
8-
import { NativeNotebook } from '../../common/experiments/groups';
8+
import { NotebookEditorSupport } from '../../common/experiments/groups';
99
import { IFileSystem } from '../../common/platform/types';
1010
import { IDisposableRegistry, IExperimentsManager, IExtensionContext } from '../../common/types';
1111
import { noop } from '../../common/utils/misc';
@@ -35,7 +35,7 @@ export class NotebookIntegration implements IExtensionSingleActivationService {
3535
// This condition is temporary.
3636
// If user belongs to the experiment, then make the necessary changes to package.json.
3737
// Once the API is final, we won't need to modify the package.json.
38-
if (!this.experiment.inExperiment(NativeNotebook.experiment)) {
38+
if (!this.experiment.inExperiment(NotebookEditorSupport.nativeNotebookExperiment)) {
3939
return;
4040
}
4141

src/client/datascience/serviceRegistry.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
'use strict';
44
import { IExtensionSingleActivationService } from '../activation/types';
55
import { UseCustomEditorApi } from '../common/constants';
6-
import { CustomEditorSupport, NativeNotebook } from '../common/experiments/groups';
6+
import { NotebookEditorSupport } from '../common/experiments/groups';
77
import { StartPage } from '../common/startPage/startPage';
88
import { IStartPage } from '../common/startPage/types';
99
import { IExperimentsManager } from '../common/types';
@@ -160,8 +160,8 @@ import {
160160
// tslint:disable-next-line: max-func-body-length
161161
export function registerTypes(serviceManager: IServiceManager) {
162162
const experiments = serviceManager.get<IExperimentsManager>(IExperimentsManager);
163-
const useVSCodeNotebookAPI = experiments.inExperiment(NativeNotebook.experiment);
164-
const inCustomEditorApiExperiment = experiments.inExperiment(CustomEditorSupport.experiment);
163+
const useVSCodeNotebookAPI = experiments.inExperiment(NotebookEditorSupport.nativeNotebookExperiment);
164+
const inCustomEditorApiExperiment = experiments.inExperiment(NotebookEditorSupport.customEditorExperiment);
165165
const usingCustomEditor = inCustomEditorApiExperiment;
166166
serviceManager.addSingletonInstance<boolean>(UseCustomEditorApi, usingCustomEditor);
167167

src/test/common/experiments/manager.unit.test.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { IApplicationEnvironment } from '../../../client/common/application/type
1414
import { PythonSettings } from '../../../client/common/configSettings';
1515
import { ConfigurationService } from '../../../client/common/configuration/service';
1616
import { CryptoUtils } from '../../../client/common/crypto';
17-
import { NativeNotebook } from '../../../client/common/experiments/groups';
17+
import { NotebookEditorSupport } from '../../../client/common/experiments/groups';
1818
import {
1919
configUri,
2020
downloadedExperimentStorageKey,
@@ -895,8 +895,9 @@ suite('A/B experiments', () => {
895895
});
896896
test('NativeNotebook Experiment are not loaded in VSC Insiders', async () => {
897897
const storageValue = [
898-
{ name: NativeNotebook.control, salt: 'salt', min: 79, max: 94 },
899-
{ name: NativeNotebook.experiment, salt: 'salt', min: 19, max: 30 }
898+
{ name: NotebookEditorSupport.control, salt: 'salt', min: 0, max: 0 },
899+
{ name: NotebookEditorSupport.customEditorExperiment, salt: 'salt', min: 0, max: 0 },
900+
{ name: NotebookEditorSupport.nativeNotebookExperiment, salt: 'salt', min: 0, max: 100 }
900901
];
901902
experimentStorage.setup((n) => n.value).returns(() => storageValue);
902903
when(appEnvironment.machineId).thenReturn('101');
@@ -905,10 +906,11 @@ suite('A/B experiments', () => {
905906
expManager.populateUserExperiments();
906907
assert.deepEqual(expManager.userExperiments, []);
907908
});
908-
test('NativeNotebook Experiment are loaded in VSC Insiders', async () => {
909+
test('NativeNotebook Experiment is loaded in VSC Insiders', async () => {
909910
const storageValue = [
910-
{ name: NativeNotebook.control, salt: 'salt', min: 79, max: 94 },
911-
{ name: NativeNotebook.experiment, salt: 'salt', min: 19, max: 30 }
911+
{ name: NotebookEditorSupport.control, salt: 'salt', min: 0, max: 0 },
912+
{ name: NotebookEditorSupport.customEditorExperiment, salt: 'salt', min: 0, max: 0 },
913+
{ name: NotebookEditorSupport.nativeNotebookExperiment, salt: 'salt', min: 0, max: 100 }
912914
];
913915
experimentStorage.setup((n) => n.value).returns(() => storageValue);
914916
when(appEnvironment.machineId).thenReturn('101');
@@ -917,9 +919,9 @@ suite('A/B experiments', () => {
917919
expManager.populateUserExperiments();
918920
assert.deepEqual(expManager.userExperiments, [
919921
{
920-
max: 94,
921-
min: 79,
922-
name: 'NativeNotebook - control',
922+
min: 0,
923+
max: 100,
924+
name: 'NativeNotebook - experiment',
923925
salt: 'salt'
924926
}
925927
]);

0 commit comments

Comments
 (0)