Skip to content
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
5 changes: 5 additions & 0 deletions build/ci/templates/steps/compile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ steps:
compile: 'false'
installVSCEorNPX: 'false'

- task: Gulp@0
displayName: 'Validate package.json'
inputs:
targets: 'validate-packagejson'

- task: Gulp@0
displayName: 'Compile and check for errors'
inputs:
Expand Down
12 changes: 12 additions & 0 deletions experiments.json
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,18 @@
"min": 0,
"max": 100
},
{
"name": "NativeNotebook - experiment",
"salt": "NativeNotebook",
Comment thread
DonJayamanne marked this conversation as resolved.
"max": 0,
"min": 0
},
{
"name": "NativeNotebook - control",
"salt": "NativeNotebook",
"min": 0,
"max": 100
},
{
"name": "CollectLSRequestTiming - experiment",
"salt": "CollectLSRequestTiming",
Expand Down
15 changes: 15 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,23 @@ gulp.task('checkNativeDependencies', (done) => {

gulp.task('check-datascience-dependencies', () => checkDatascienceDependencies());

gulp.task('validate-packagejson', () => validatePackageJson());

const webpackEnv = { NODE_OPTIONS: '--max_old_space_size=9096' };

async function validatePackageJson(){
const json = require('./package.json');
if (json.enableProposedApi){
throw new Error('package.json has enableProposedApi setting enabled');
}
if (json.contributes.notebookOutputRenderer){
throw new Error('Package.json contains entry for contributes.notebookOutputRenderer');
}
if (json.contributes.notebookProvider){
throw new Error('Package.json contains entry for contributes.notebookProvider');
}
}

async function buildIPyWidgets() {
await spawnAsync('npm', ['run', 'build-ipywidgets'], webpackEnv);
}
Expand Down
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@
"onCommand:python.datascience.selectjupytercommandline",
"onCommand:python.enableSourceMapSupport",
"onCustomEditor:NativeEditorProvider.ipynb",
"onNotebookEditor:jupyter-notebook",
"workspaceContains:**/mspythonconfig.json"
],
"main": "./out/client/extension",
Expand Down Expand Up @@ -1600,6 +1601,7 @@
"AA_testing - experiment",
"WebHostNotebook - experiment",
"LocalZMQKernel - experiment",
"NativeNotebook - experiment",
"UseTerminalToGetActivatedEnvVars - experiment",
"CollectLSRequestTiming - experiment",
"CollectNodeLSRequestTiming - experiment",
Expand All @@ -1625,6 +1627,7 @@
"AA_testing - experiment",
"WebHostNotebook - experiment",
"LocalZMQKernel - experiment",
"NativeNotebook - experiment",
"UseTerminalToGetActivatedEnvVars - experiment",
"CollectLSRequestTiming - experiment",
"CollectNodeLSRequestTiming - experiment",
Expand Down
4 changes: 3 additions & 1 deletion src/client/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ export const PYTHON_WARNINGS = 'PYTHONWARNINGS';
export const PYTHON = [
{ scheme: 'file', language: PYTHON_LANGUAGE },
{ scheme: 'untitled', language: PYTHON_LANGUAGE },
{ scheme: 'vscode-notebook', language: PYTHON_LANGUAGE }
{ scheme: 'vscode-notebook', language: PYTHON_LANGUAGE },
Comment thread
DonJayamanne marked this conversation as resolved.
{ scheme: 'vscode-notebook-cell', language: PYTHON_LANGUAGE }
];
export const PYTHON_ALLFILES = [{ language: PYTHON_LANGUAGE }];

Expand Down Expand Up @@ -107,5 +108,6 @@ export function isUnitTestExecution(): boolean {

// Temporary constant, used to indicate whether we're using custom editor api or not.
export const UseCustomEditorApi = Symbol('USE_CUSTOM_EDITOR');
export const UseProposedApi = Symbol('USE_VSC_PROPOSED_API');

export * from '../constants';
6 changes: 6 additions & 0 deletions src/client/common/experimentGroups.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ export enum LocalZMQKernel {
experiment = 'LocalZMQKernel - experiment'
}

// Experiment to use VSC Notebook Implementation
export enum NativeNotebook {
control = 'NativeNotebook - control',
experiment = 'NativeNotebook - experiment'
}

// Experiment for supporting run by line in data science notebooks
export enum RunByLine {
control = 'RunByLine - control',
Expand Down
56 changes: 56 additions & 0 deletions src/client/datascience/notebook/contentProvider.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

'use strict';

import { inject, injectable } from 'inversify';
import {
CancellationToken,
EventEmitter,
NotebookContentProvider as VSCodeNotebookContentProvider,
NotebookData,
NotebookDocument,
NotebookDocumentEditEvent,
Uri
} from 'vscode';
import { INotebookStorageProvider } from '../interactive-ipynb/notebookStorageProvider';
import { notebookModelToVSCNotebookData } from './helpers';

/**
* This class is responsible for reading a notebook file (ipynb or other files) and returning VS Code with the NotebookData.
* Its upto extension authors to read the files and return it in a format that VSCode understands.
* Same with the cells and cell output.
*
* Also responsbile for saving of notebooks.
* When saving, VSC will provide their model and we need to take that and merge it with an existing ipynb json (if any, to preserve metadata).
*/
@injectable()
Comment thread
DonJayamanne marked this conversation as resolved.
export class NotebookContentProvider implements VSCodeNotebookContentProvider {
private notebookChanged = new EventEmitter<NotebookDocumentEditEvent>();
public get onDidChangeNotebook() {
return this.notebookChanged.event;
}
constructor(@inject(INotebookStorageProvider) private readonly notebookStorage: INotebookStorageProvider) {}
public async openNotebook(uri: Uri): Promise<NotebookData> {
const model = await this.notebookStorage.load(uri);
return notebookModelToVSCNotebookData(model);
}
public async saveNotebook(document: NotebookDocument, cancellation: CancellationToken) {
const model = await this.notebookStorage.load(document.uri);
if (model.isUntitled) {
return;
}
await this.notebookStorage.save(model, cancellation);
}

public async saveNotebookAs(
targetResource: Uri,
document: NotebookDocument,
cancellation: CancellationToken
): Promise<void> {
const model = await this.notebookStorage.load(document.uri);
if (!cancellation.isCancellationRequested) {
await this.notebookStorage.saveAs(model, targetResource);
}
}
}
Loading