profile
viewpoint
Don Jayamanne DonJayamanne Software engineer with a soft spot for .NET and Node.js. Loves tinkering with Arduino and Raspberry Pi. Lives in a cave.

beeware/vscode-beeware 27

A Visual Studio Code extension with support for BeeWare development

DonJayamanne/awesome-python 1

A curated list of awesome Python frameworks, libraries, software and resources

DonJayamanne/azure-pipelines-template 1

template for your azure pipelines

DonJayamanne/conda 1

OS-agnostic, system-level binary package manager and ecosystem

DonJayamanne/apollo-tooling 0

:pencil2: Tooling for development and production Apollo workflows

DonJayamanne/autoDocstring 0

vscode extension that generates docstrings for python files

DonJayamanne/awesome-jupyter 0

A curated list of awesome Jupyter projects, libraries and resources

DonJayamanne/azure-powershell 0

Microsoft Azure PowerShell

DonJayamanne/BlazorTest 0

A place to test Blazor features

Pull request review commentmicrosoft/vscode-python

Fix raw kernel running other languages

 export class KernelProcess implements IKernelProcess {      // Instead of having to use a connection file update our local copy of the kernelspec to launch     // directly with command line arguments-    private updateConnectionArgs() {+    private async updateConnectionArgs() {         // First check to see if we have a kernelspec that expects a connection file,         // Error if we don't have one. We expect '-f', '{connectionfile}' in our launch args         const indexOfConnectionFile = findIndexOfConnectionFile(this._kernelSpec);+        if (indexOfConnectionFile === -1) {+            throw new Error(`Connection file not found in kernelspec json args, ${this._kernelSpec.argv.join(' ')}`);+        }         if (-            indexOfConnectionFile === -1 ||-            indexOfConnectionFile === 0 ||+            this.isPythonKernel &&+            indexOfConnectionFile === 0 &&             this._kernelSpec.argv[indexOfConnectionFile - 1] !== '-f'         ) {             throw new Error(`Connection file not found in kernelspec json args, ${this._kernelSpec.argv.join(' ')}`);         } -        // Slice out -f and the connection file from the args-        this._kernelSpec.argv.splice(indexOfConnectionFile - 1, 2);+        // Python kernels are special. Handle the extra arguments.+        if (this.isPythonKernel) {+            // Slice out -f and the connection file from the args+            this._kernelSpec.argv.splice(indexOfConnectionFile - 1, 2); -        // Add in our connection command line args-        this._kernelSpec.argv.push(...this.addConnectionArgs());+            // Add in our connection command line args+            this._kernelSpec.argv.push(...this.addPythonConnectionArgs());+        } else {+            // For other kernels, just write to the connection file.+            // Note: We have to dispose the temp file and recreate it because otherwise the file+            // system will hold onto the file with an open handle. THis doesn't work so well when+            // a different process tries to open it.+            const tempFile = await this.file.createTemporaryFile('.json');+            this.connectionFile = tempFile.filePath;+            await tempFile.dispose();

We should create a better API that returns a random file name instead of creating one.

rchiodo

comment created time in 13 minutes

Pull request review commentmicrosoft/vscode-python

Fix raw kernel running other languages

 export class KernelProcess implements IKernelProcess {      // Instead of having to use a connection file update our local copy of the kernelspec to launch     // directly with command line arguments-    private updateConnectionArgs() {+    private async updateConnectionArgs() {         // First check to see if we have a kernelspec that expects a connection file,         // Error if we don't have one. We expect '-f', '{connectionfile}' in our launch args         const indexOfConnectionFile = findIndexOfConnectionFile(this._kernelSpec);+        if (indexOfConnectionFile === -1) {+            throw new Error(`Connection file not found in kernelspec json args, ${this._kernelSpec.argv.join(' ')}`);+        }         if (-            indexOfConnectionFile === -1 ||-            indexOfConnectionFile === 0 ||+            this.isPythonKernel &&+            indexOfConnectionFile === 0 &&             this._kernelSpec.argv[indexOfConnectionFile - 1] !== '-f'         ) {             throw new Error(`Connection file not found in kernelspec json args, ${this._kernelSpec.argv.join(' ')}`);         } -        // Slice out -f and the connection file from the args-        this._kernelSpec.argv.splice(indexOfConnectionFile - 1, 2);+        // Python kernels are special. Handle the extra arguments.+        if (this.isPythonKernel) {+            // Slice out -f and the connection file from the args+            this._kernelSpec.argv.splice(indexOfConnectionFile - 1, 2); -        // Add in our connection command line args-        this._kernelSpec.argv.push(...this.addConnectionArgs());+            // Add in our connection command line args+            this._kernelSpec.argv.push(...this.addPythonConnectionArgs());+        } else {+            // For other kernels, just write to the connection file.+            // Note: We have to dispose the temp file and recreate it because otherwise the file+            // system will hold onto the file with an open handle. THis doesn't work so well when+            // a different process tries to open it.+            const tempFile = await this.file.createTemporaryFile('.json');+            this.connectionFile = tempFile.filePath;+            await tempFile.dispose();

Oops

rchiodo

comment created time in 13 minutes

issue openedmicrosoft/vscode

Add support for multiple cancellations

<!-- ⚠️⚠️ Do Not Delete This! feature_request_template ⚠️⚠️ --> <!-- Please read our Rules of Conduct: https://opensource.microsoft.com/codeofconduct/ --> <!-- Please search existing issues to avoid creating duplicates. -->

<!-- Describe the feature you'd like. --> When user runs a notebook/cell, the cancel button can be clicked once. This cancels the CancellationToken passed into the NotebookKernel.executeCell.

In Jupyter, clicking interrupt (stop button) doesn't necessarily work the first time the button is clicked. hence one can click the interrupt button multiple times.

We'd like the same behavior.

I.e. clicking the cancel button should trigger a cancellation (either the cancellation token or a cancellation callback).

It is my understanding that cancellation tokens will not trigger the onCancellationRequested event more than once. Hence the suggestion for a callback or we create a new construct that supports such a notification.

Note: Today we Python extension have a dedicated interrupt button on the toolbar that can be used to interrupt/stop the kernel at any point. We were planning on using the VS Code stop icon, however it doesn't trigger callbacks when clicked more than once.

@rebornix /cc

created time in 41 minutes

PR closed microsoft/vscode-python

WIP

For #

<!-- If an item below does not apply to you, then go ahead and check it off as "done" and strikethrough the text, e.g.: - [x] ~Has unit tests & system/integration tests~ -->

  • [ ] Pull request represents a single change (i.e. not fixing disparate/unrelated things in a single PR).
  • [ ] Title summarizes what is changing.
  • [ ] Has a news entry file (remember to thank yourself!).
  • [ ] Appropriate comments and documentation strings in the code.
  • [ ] Has sufficient logging.
  • [ ] Has telemetry for enhancements.
  • [ ] Unit tests & system/integration tests are added/updated.
  • [ ] Test plan is updated as appropriate.
  • [ ] package-lock.json has been regenerated by running npm install (if dependencies have changed).
  • [ ] The wiki is updated with any design decisions/details.
+3402 -137

2 comments

50 changed files

DonJayamanne

pr closed time in 2 hours

Pull request review commentmicrosoft/vscode-python

Fix raw kernel running other languages

 export class KernelProcess implements IKernelProcess {      // Instead of having to use a connection file update our local copy of the kernelspec to launch     // directly with command line arguments-    private updateConnectionArgs() {+    private async updateConnectionArgs() {         // First check to see if we have a kernelspec that expects a connection file,         // Error if we don't have one. We expect '-f', '{connectionfile}' in our launch args         const indexOfConnectionFile = findIndexOfConnectionFile(this._kernelSpec);+        if (indexOfConnectionFile === -1) {+            throw new Error(`Connection file not found in kernelspec json args, ${this._kernelSpec.argv.join(' ')}`);+        }         if (-            indexOfConnectionFile === -1 ||-            indexOfConnectionFile === 0 ||+            this.isPythonKernel &&+            indexOfConnectionFile === 0 &&             this._kernelSpec.argv[indexOfConnectionFile - 1] !== '-f'         ) {             throw new Error(`Connection file not found in kernelspec json args, ${this._kernelSpec.argv.join(' ')}`);         } -        // Slice out -f and the connection file from the args-        this._kernelSpec.argv.splice(indexOfConnectionFile - 1, 2);+        // Python kernels are special. Handle the extra arguments.+        if (this.isPythonKernel) {+            // Slice out -f and the connection file from the args+            this._kernelSpec.argv.splice(indexOfConnectionFile - 1, 2); -        // Add in our connection command line args-        this._kernelSpec.argv.push(...this.addConnectionArgs());+            // Add in our connection command line args+            this._kernelSpec.argv.push(...this.addPythonConnectionArgs());+        } else {+            // For other kernels, just write to the connection file.+            // Note: We have to dispose the temp file and recreate it because otherwise the file+            // system will hold onto the file with an open handle. THis doesn't work so well when+            // a different process tries to open it.+            const tempFile = await this.file.createTemporaryFile('.json');+            this.connectionFile = tempFile.filePath;+            await tempFile.dispose();

Doesn't this delete the temporary file created, meaning the file in this.connectionFile will no longer exist!

rchiodo

comment created time in 2 hours

PR closed microsoft/vscode-python

WIP Notebooks

For #

<!-- If an item below does not apply to you, then go ahead and check it off as "done" and strikethrough the text, e.g.: - [x] ~Has unit tests & system/integration tests~ -->

  • [ ] Pull request represents a single change (i.e. not fixing disparate/unrelated things in a single PR).
  • [ ] Title summarizes what is changing.
  • [ ] Has a news entry file (remember to thank yourself!).
  • [ ] Appropriate comments and documentation strings in the code.
  • [ ] Has sufficient logging.
  • [ ] Has telemetry for enhancements.
  • [ ] Unit tests & system/integration tests are added/updated.
  • [ ] Test plan is updated as appropriate.
  • [ ] package-lock.json has been regenerated by running npm install (if dependencies have changed).
  • [ ] The wiki is updated with any design decisions/details.
+6628 -134

1 comment

35 changed files

DonJayamanne

pr closed time in 2 hours

push eventmicrosoft/vscode-python

Don Jayamanne

commit sha ac79a1751d9e94509d0af62465c1fc155a6568d5

Cancelling should invoke a single interrupt (#12106) For #10496 Runing entire notebook and clicking cancel would result in kernel being interrupted n times (where n = number of cells). I.e. user clicks cancel once, but we end up interrupting multiple times.

view details

push time in 2 hours

delete branch DonJayamanne/pythonVSCode

delete branch : interruptIssues

delete time in 2 hours

PR merged microsoft/vscode-python

Reviewers
Cancelling should invoke a single interrupt skip news

For #10496

Runing entire notebook and clicking cancel would result in kernel being interrupted n times (where n = number of cells). I.e. user clicks cancel once, but we end up interrupting multiple times.

+67 -22

1 comment

4 changed files

DonJayamanne

pr closed time in 2 hours

issue openedmicrosoft/vscode-python

Flaky file system test

https://dev.azure.com/ms/vscode-python/_build/results?buildId=85017&view=logs&j=143eea66-4597-539b-c2e7-6e457837a569&t=b63f14a6-b079-5c98-43dc-6421926d28b4

Screen Shot 2020-06-02 at 15 47 25

created time in 2 hours

push eventDonJayamanne/pythonVSCode

Don Jayamanne

commit sha f2c9933f4dd8150a5623b1410484d27c98ca320e

Fix linter

view details

push time in 3 hours

Pull request review commentmicrosoft/vscode-python

Cancelling should invoke a single interrupt

 export class NotebookExecutionService implements INotebookExecutionService {         const stopWatch = new StopWatch();          wrappedToken.onCancellationRequested(() => {-            // tslint:disable-next-line: no-suspicious-comment-            // TODO: Is this the right thing to do?-            // I think it is, as we have a stop button.-            // If we're busy executing, then interrupt the execution.             if (deferred.completed) {                 return;             }-            deferred.resolve();-            cell.metadata.runState = vscodeNotebookEnums.NotebookCellRunState.Idle;              // Interrupt kernel only if original cancellation was cancelled.-            if (token.isCancellationRequested) {+            // I.e. interrupt kernel only if user attempts to stop the execution by clicking stop button.+            if (token.isCancellationRequested && !this.tokensInterrupted.has(token)) {+                this.tokensInterrupted.add(token);                 this.commandManager.executeCommand(Commands.NotebookEditorInterruptKernel).then(noop, noop);             }         });          cell.metadata.runStartTime = new Date().getTime();         cell.metadata.runState = vscodeNotebookEnums.NotebookCellRunState.Running; -        if (!findMappedNotebookCellModel(cell, model.cells)) {

Yes, we don't need it anymore. Was there due to missing VSC API.

DonJayamanne

comment created time in 3 hours

PR opened microsoft/vscode-python

Cancelling should invoke a single interrupt

For #10496

Runing entire notebook and clicking cancel would result in kernel being interrupted n times (where n = number of cells). I.e. user clicks cancel once, but we end up interrupting multiple times.

+68 -23

0 comment

4 changed files

pr created time in 4 hours

create barnchDonJayamanne/pythonVSCode

branch : interruptIssues

created branch time in 4 hours

Pull request review commentmicrosoft/vscode-python

Save variable explorer height persistently

 export class NativeEditor extends InteractiveBase implements INotebookEditor {             // VS code is telling us to broadcast this to our UI. Tell the UI about the new change             await this.postMessage(InteractiveWindowMessages.UpdateModel, change);         }-        if (change.kind === 'saveAs' && change.model && this.model) {+        if (change.kind === 'saveAs' && change.model) {             const newFileName = change.model.file.toString();             const oldFileName = change.sourceUri.toString();

I thik its a good idea to delete the old item from the sotrage.

techwithtim

comment created time in 7 hours

Pull request review commentmicrosoft/vscode-python

Save variable explorer height persistently

 export abstract class InteractiveBase extends WebViewHost<IInteractiveWindowMapp             const updatedHeights = payload as { containerHeight: number; gridHeight: number };             const uri = await this.getOwningResource(); // Get file name -            if (!uri) {+            if (!uri || uri.scheme === 'untitled') {
            if (!uri || isUntitledFile(uri)) {

isUntitledFile can be found in nativeEditorStorage.ts

techwithtim

comment created time in 7 hours

PR merged microsoft/vscode-python

Reviewers
Use openWith command to open notebooks skip news

For #10496 #10744

Use vscode.openWith when opening a notebook.

+19 -12

1 comment

9 changed files

DonJayamanne

pr closed time in 7 hours

delete branch DonJayamanne/pythonVSCode

delete branch : useOpenWith

delete time in 7 hours

push eventmicrosoft/vscode-python

Don Jayamanne

commit sha 730c2238e253da51981d50a5ddf4610f93b43e64

Use openWith command to open notebooks (#12104) For #10496 #10744 Use vscode.openWith when opening a notebook.

view details

push time in 7 hours

Pull request review commentmicrosoft/vscode-python

Use openWith command to open notebooks

 export class CustomEditorService implements ICustomEditorService {         }     } -    public async openEditor(file: vscode.Uri): Promise<void> {+    public async openEditor(file: vscode.Uri, viewType: string): Promise<void> {

@rchiodo I've tested this with customEditor changes (new API) & it works. Also works with untitled notebooks.

DonJayamanne

comment created time in 8 hours

PR opened microsoft/vscode-python

Use openWith command to open notebooks

For #10496 #10744

Use vscode.openWith when opening a notebook.

+19 -12

0 comment

9 changed files

pr created time in 8 hours

create barnchDonJayamanne/pythonVSCode

branch : useOpenWith

created branch time in 8 hours

issue openedmicrosoft/vscode

Support relative paths for images in markdown cells (of untitled notebooks)

<!-- ⚠️⚠️ Do Not Delete This! bug_report_template ⚠️⚠️ --> <!-- Please read our Rules of Conduct: https://opensource.microsoft.com/codeofconduct/ --> <!-- Please search existing issues to avoid creating duplicates. --> <!-- Also please test using the latest insiders build to make sure your issue has not already been fixed: https://code.visualstudio.com/insiders/ -->

<!-- Use Help > Report Issue to prefill these. -->

  • Version: 1.46.0-insider
  • Commit: 1bfa086adb9271ff56be11821da686e4cfffb672
  • Date: 2020-06-02T08:10:00.819Z
  • Electron: 7.3.0
  • Chrome: 78.0.3904.130
  • Node.js: 12.8.1
  • V8: 7.8.279.23-electron.0
  • OS: Darwin x64 19.5.0

Steps to Reproduce:

  1. Create an untitled notebook, markdown with relative images do not work.
  2. Expectation is images will be resolved relative to current workspace folder However in a multi-root workspace, things might be a little bit more complicated.

Not sure how VSC handles this today, e.g. with auto completion for relative imports in untitled js/ts files.

<!-- Launch with code --disable-extensions to check. --> Does this issue occur when all extensions are disabled?: Yes

@rebornix /cc

created time in 8 hours

push eventmicrosoft/vscode-python

Don Jayamanne

commit sha 5cef0d98fc4762f7bf8820fcf164977e60166274

Let VSCode translate ascii/terminal characters in output (#12095) For #10496

view details

push time in 9 hours

delete branch DonJayamanne/pythonVSCode

delete branch : fixAsciiRendering

delete time in 9 hours

issue commentmicrosoft/vscode-python

Untitled python notebooks don't change name when saved

Unable to repro, @techwithtim Please try again with your master branch updated.

techwithtim

comment created time in 9 hours

push eventDonJayamanne/pythonVSCode

Ian Huff

commit sha 0f3e0264fae4df1e8610c802fdf490f981d5a6d7

add news and wait for backup to finish to start new one (#12064) Co-authored-by: Ian Huff <ianhuff@alex-x230.northamerica.corp.microsoft.com>

view details

David Kutugata

commit sha 5a3a49959a330898f730edbc45a91d5855268f2d

Start page (#11605) * Add command to open the start page * added the message listener and added start page to the service registry * small fix * added start page front end and its redux store * add store middleware part 1 * remove redux * remove redux * Add functionality to some links/buttons * open start page on extension activation, add the last messages like the sample notebook and update settings * start page will only open the first time the extension is activated or if the version changes * localize the start page * added telemetry * added functional test that loads the page and checks the DOM. * added news file * Address PR comments and fix scrapping of release notes * use one localization per paragraph * Stop scrapping the date from the release notes. Added some comments. * localize the sample notebook * if the localized sample notebook doesn't exist, open the english one. * fix linter complaint * Change some capitalization, set the env variable UITEST_DISABLE_INSIDERS * limit release notes to 5, increase a margin * added requested awaits * Move ipynb to 'pyhtonFiles' and its images to 'images' other PR comments * merge mistake, removed jediEnabled from IPythonSettings * add function to compare versions * removed render count from functional test added unit tests start page won't open if you go back to a privews version * moved the start page files to common * added license * changed command on package.json * open a copy of the sample notebook instead of the original file * -open a copy of the sample notebook instead of the original -set a timeout when opening the start page

view details

Rich Chiodo

commit sha 6abd30e50a36283b97f25418c357738021d2e9c8

Make sure to use webView.cspSource instead of 'vscode-resource' (#12067) * Fix CSP source to use webview.cspSource * add news entry

view details

Don Jayamanne

commit sha 176f9c3df22478785454cb0e36649c3f4640f77b

Update NotebookModel with changes from VS Code Notebook UI (#12048) For #10496 Update our model when user edits VS Code cells

view details

Don Jayamanne

commit sha b859a3de8800eb07076e51204db48fb1445a99a4

Tests to ensure we close nb when VSC is closed (#12087) * Tests to ensure we close nb when VSC is closed

view details

Jake Bailey

commit sha e42fc1e7bc135cf47c1563bd01aa19ab893d53cb

Allow LS to be bundled, versioned (#12034) Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>

view details

Sergio Villalobos

commit sha 722d81b9e6ff01d13f90d42e184838368b1139d2

Expose API to show DS Data Viewer component from external extension (#12045) * Issue#12033 Expose API to show Data Viewer component from an external extension * Issue#12033 Add headers and comments to important updated/new code * Issue12033 Fix review comments: 1. Do not trim title in DataViewer 2. More strucuted type to represent rows responses from IDataViewerDataProvider. Created IRowsResponse type {data: any[]} 3. Change createion of JupyterVariableDataProvider through a Factory Class 4. Fix initialization lock/flag in jupyterVariableDataProvider to ensure only one execution 5. showDataViewer API return void 6. Cache dataFrameInfo in DataViewer to prevent multiple fetches 7. Fix automotter change in reactSlickGrid.txt imports 8. Move IDataViewer and IDataViewerFactory to data-viewing/types * Issue#12033 Fix hygiene * Issue#12033 Change IRowsResponse to be of type any[] Co-authored-by: Sergio Villalobos <sevillal@microsoft.com>

view details

Don Jayamanne

commit sha feb74dca6b0a7e97edab2844749e4ed5fee5e802

Add ability to sync INotebookModel with cell text edits (#12092) For #10496

view details

Ian Huff

commit sha 1a4acc7ccdaf0a4c67ef6d66da3f6239d4eadae5

Support notebook completion doc strings in .ipynb files (#12089) * working completions, not cleaned up * some cleanup done and news added * remove news * ts-lint confusion on import name Co-authored-by: Ian Huff <ianhuff@alex-x230.northamerica.corp.microsoft.com>

view details

push time in 9 hours

push eventDonJayamanne/pythonVSCode

Don Jayamanne

commit sha 8d9b2de224eb36fc1c0e79ab0fcf10ee13abd2d6

Fix tests

view details

push time in 9 hours

issue closedmicrosoft/vscode-python

Remove NB custom editor code

Do we need this? If not remove it, cleaner and easier to look at the code.

closed time in a day

DonJayamanne

issue closedmicrosoft/vscode-python

Save as notebook (VSC Native Editor & Custom Editor)

Create new notebook

  • Save untitled.ipynb as b.ipynb
  • Ensure all previous mapped Uris migrate to b.ipynb (places where we index stuff with uri)
  • Migrate event handlers, kernel state
  • Ensure changes to VSC model is synced in INotebookModel
  • Ensure changes to output in INotebookModel is synced in new model (monitorModelCellOutputChangesAndUpdateNotebookDocument)

Open A.ipynb

  • Save a.ipynb as b.ipynb
  • Same as previous

Open A.ipynb (twice side by side)

  • Save a.ipynb as b.ipynb
  • No migration, treat b.ipynb as a new document.

closed time in a day

DonJayamanne

issue commentmicrosoft/vscode-python

Untitled python notebooks don't change name when saved

I'll look into this first thing tomorrow

techwithtim

comment created time in a day

Pull request review commentmicrosoft/vscode-python

Let VSCode translate ascii/terminal characters in output

 function isImagePngOrJpegMimeType(mimeType: string) {     return mimeType === 'image/png' || mimeType === 'image/jpeg'; } function translateStreamOutput(output: nbformat.IStream): CellStreamOutput | CellDisplayOutput {

We can, I'd expect the renderer to handle that. Just like vsc. Here the renderer vsc and that handles ASCII, if we use our renderer we can do that. So yes, we can still use this with interactive window

DonJayamanne

comment created time in a day

issue commentmicrosoft/vscode

Notebook output doesn't render VT-100 codes for `text/plain`

le, but it only renders as plain text. We might also want to change its name to CellTextOuput to keep aligned.

I too just came across this issue. For now, I'm using rich text.

brettfo

comment created time in a day

Pull request review commentmicrosoft/vscode-python

Let VSCode translate ascii/terminal characters in output

 function isImagePngOrJpegMimeType(mimeType: string) {     return mimeType === 'image/png' || mimeType === 'image/jpeg'; } function translateStreamOutput(output: nbformat.IStream): CellStreamOutput | CellDisplayOutput {-    const text = concatMultilineStringOutput(output.text);-    const hasAngleBrackets = text.includes('<');-    const hasAnsiChars = ansiRegex().test(text);--    if (!hasAngleBrackets && !hasAnsiChars) {-        // Plain text output.-        return {-            outputKind: vscodeNotebookEnums.CellOutputKind.Text,-            text-        };-    }--    // Format the output, but ensure we have the plain text output as well.-    const richOutput: CellDisplayOutput = {+    // Do not return as `CellOutputKind.Text`. VSC will not translate ascii output correctly.

Will file an issue on VSC.

DonJayamanne

comment created time in a day

create barnchDonJayamanne/pythonVSCode

branch : fixAsciiRendering

created branch time in a day

push eventmicrosoft/vscode-python

Don Jayamanne

commit sha feb74dca6b0a7e97edab2844749e4ed5fee5e802

Add ability to sync INotebookModel with cell text edits (#12092) For #10496

view details

push time in a day

delete branch DonJayamanne/pythonVSCode

delete branch : syncCellEdits

delete time in a day

PR merged microsoft/vscode-python

Reviewers
Add ability to sync INotebookModel with cell text edits skip news

For #10496

+234 -32

1 comment

9 changed files

DonJayamanne

pr closed time in a day

Pull request review commentmicrosoft/vscode-python

Add ability to sync INotebookModel with cell text edits

+// Copyright (c) Microsoft Corporation. All rights reserved.+// Licensed under the MIT License.++import { inject, injectable } from 'inversify';+import { TextDocument, TextDocumentChangeEvent } from 'vscode';+import type { NotebookCell, NotebookDocument } from '../../../../typings/vscode-proposed';+import { splitMultilineString } from '../../../datascience-ui/common';+import { IExtensionSingleActivationService } from '../../activation/types';+import { IDocumentManager, IVSCodeNotebook } from '../../common/application/types';+import { NativeNotebook } from '../../common/experiments/groups';+import { IDisposable, IDisposableRegistry, IExperimentsManager } from '../../common/types';+import { isNotebookCell } from '../../common/utils/misc';+import { traceError } from '../../logging';+import { INotebookEditorProvider, INotebookModel } from '../types';++@injectable()+export class CellEditSyncService implements IExtensionSingleActivationService, IDisposable {+    private readonly disposables: IDisposable[] = [];+    private mappedDocuments = new WeakMap<TextDocument, { cellId: string; model: INotebookModel }>();+    constructor(+        @inject(IDocumentManager) private readonly documentManager: IDocumentManager,+        @inject(IDisposableRegistry) disposableRegistry: IDisposableRegistry,+        @inject(IVSCodeNotebook) private readonly vscNotebook: IVSCodeNotebook,+        @inject(INotebookEditorProvider) private readonly editorProvider: INotebookEditorProvider,+        @inject(IExperimentsManager) private readonly experiment: IExperimentsManager+    ) {+        disposableRegistry.push(this);+    }+    public dispose() {+        while (this.disposables.length) {+            this.disposables.pop()?.dispose(); //NOSONAR+        }+    }+    public async activate(): Promise<void> {+        if (!this.experiment.inExperiment(NativeNotebook.experiment)) {+            return;+        }+        this.documentManager.onDidChangeTextDocument(this.onDidChangeTextDocument, this, this.disposables);+    }++    private onDidChangeTextDocument(e: TextDocumentChangeEvent) {+        if (!isNotebookCell(e.document)) {+            return;+        }++        const details = this.getEditorsAndCell(e.document);+        if (!details) {+            return;+        }++        const cell = details.model.cells.find((item) => item.id === details.cellId);+        if (!cell) {+            traceError(+                `Syncing Cell Editor aborted, Unable to find corresponding ICell for ${e.document.uri.toString()}`,+                new Error('ICell not found')+            );+            return;+        }++        cell.data.source = splitMultilineString(e.document.getText());+    }++    private getEditorsAndCell(cellDocument: TextDocument) {+        if (this.mappedDocuments.has(cellDocument)) {+            return this.mappedDocuments.get(cellDocument)!;+        }++        let document: NotebookDocument | undefined;+        let cell: NotebookCell | undefined;+        this.vscNotebook.notebookEditors.find((vscEditor) => {+            const found = vscEditor.document.cells.find((item) => item.document === cellDocument);+            if (found) {+                document = vscEditor.document;+                cell = found;+            }+            return !!found;+        });++        if (!document) {+            traceError(+                `Syncing Cell Editor aborted, Unable to find corresponding Notebook for ${cellDocument.uri.toString()}`,+                new Error('Unable to find corresponding Notebook')+            );+            return;+        }+        if (!cell) {+            traceError(+                `Syncing Cell Editor aborted, Unable to find corresponding NotebookCell for ${cellDocument.uri.toString()}`,+                new Error('Unable to find corresponding NotebookCell')+            );+            return;+        }++        // Check if we have an editor associated with this document.+        const editor = this.editorProvider.editors.find((item) => item.file.toString() === document?.uri.toString());+        if (!editor) {+            traceError(+                `Syncing Cell Editor aborted, Unable to find corresponding Editor for ${cellDocument.uri.toString()}`,+                new Error('Unable to find corresponding Editor')+            );+            return;+        }+        if (!editor.model) {+            traceError(

Should we add telemetry for these? Not sure what needs to be done here. Basically these conditions should not be met. I could throw an error, but it wouldn't get handled by anything as this is all happening within the context of an event handler (i.e. error throw will not be displayed to user).

I feel we need to atleast add some logging

DonJayamanne

comment created time in a day

Pull request review commentmicrosoft/vscode-python

Add ability to sync INotebookModel with cell text edits

+// Copyright (c) Microsoft Corporation. All rights reserved.+// Licensed under the MIT License.++import { inject, injectable } from 'inversify';+import { TextDocument, TextDocumentChangeEvent } from 'vscode';+import type { NotebookCell, NotebookDocument } from '../../../../typings/vscode-proposed';+import { splitMultilineString } from '../../../datascience-ui/common';+import { IExtensionSingleActivationService } from '../../activation/types';+import { IDocumentManager, IVSCodeNotebook } from '../../common/application/types';+import { NativeNotebook } from '../../common/experiments/groups';+import { IDisposable, IDisposableRegistry, IExperimentsManager } from '../../common/types';+import { isNotebookCell } from '../../common/utils/misc';+import { traceError } from '../../logging';+import { INotebookEditorProvider, INotebookModel } from '../types';++@injectable()+export class CellEditSyncService implements IExtensionSingleActivationService, IDisposable {+    private readonly disposables: IDisposable[] = [];+    private mappedDocuments = new WeakMap<TextDocument, { cellId: string; model: INotebookModel }>();+    constructor(+        @inject(IDocumentManager) private readonly documentManager: IDocumentManager,+        @inject(IDisposableRegistry) disposableRegistry: IDisposableRegistry,+        @inject(IVSCodeNotebook) private readonly vscNotebook: IVSCodeNotebook,+        @inject(INotebookEditorProvider) private readonly editorProvider: INotebookEditorProvider,+        @inject(IExperimentsManager) private readonly experiment: IExperimentsManager+    ) {+        disposableRegistry.push(this);+    }+    public dispose() {+        while (this.disposables.length) {+            this.disposables.pop()?.dispose(); //NOSONAR+        }+    }+    public async activate(): Promise<void> {+        if (!this.experiment.inExperiment(NativeNotebook.experiment)) {+            return;+        }+        this.documentManager.onDidChangeTextDocument(this.onDidChangeTextDocument, this, this.disposables);+    }++    private onDidChangeTextDocument(e: TextDocumentChangeEvent) {+        if (!isNotebookCell(e.document)) {+            return;+        }++        const details = this.getEditorsAndCell(e.document);+        if (!details) {+            return;+        }++        const cell = details.model.cells.find((item) => item.id === details.cellId);+        if (!cell) {+            traceError(+                `Syncing Cell Editor aborted, Unable to find corresponding ICell for ${e.document.uri.toString()}`,+                new Error('ICell not found')+            );+            return;+        }++        cell.data.source = splitMultilineString(e.document.getText());

This is the crux of the PR, when user edits a cell, we take the contents of the cell and update our cell. FYI - not performing diff updates or the like. This is more efficient.

DonJayamanne

comment created time in a day

issue openedmicrosoft/vscode

Handling untitled notebooks

<!-- ⚠️⚠️ Do Not Delete This! bug_report_template ⚠️⚠️ --> <!-- Please read our Rules of Conduct: https://opensource.microsoft.com/codeofconduct/ --> <!-- Please search existing issues to avoid creating duplicates. --> <!-- Also please test using the latest insiders build to make sure your issue has not already been fixed: https://code.visualstudio.com/insiders/ -->

<!-- Use Help > Report Issue to prefill these. -->

  • Version: 1.46.0-insider
  • Commit: 2c1871d538c64df71af4902deba47d7fa4b53f27
  • Date: 2020-06-01T10:32:27.369Z
  • Electron: 7.3.0
  • Chrome: 78.0.3904.130
  • Node.js: 12.8.1
  • V8: 7.8.279.23-electron.0
  • OS: Darwin x64 19.5.0

Steps to Reproduce:

1.Create a new untitled notebook (using VS Code Python extension) 2.When you add a cell or the like, then VSC will invoke the save method on the NotebookContentProvider

Problems

  • Adding cells should not invoke save (this happens when user has auto save turned on)
  • Errors thrown in the saveNotebook method are ignored. VSC will assume the notebook was saved and mark it as not dirty (the dirty indicator doesn't exist on the tab anymore)

I don't think VSCode should call the saveNotebook method for untitled notebooks.

FYI - We create untitled notebooks with a scehme untitled. If this isn't the way to indicate an untitled file (scheme), we might need some API or the like in the notebooks implememtation.

@rebornix /cc

created time in a day

Pull request review commentmicrosoft/vscode-python

Add ability to sync INotebookModel with cell text edits

 suite('DataScience - VSCode Notebook - Restart/Interrupt/Cancel/Errors', functio         await waitForCondition(async () => deferred.completed, 5_000, 'Execution not cancelled');         assertVSCCellIsIdle(cell);     });-    test('Cancelling using VSC Command for cell (slow)', async () => {+    test('Cancelling using VSC Command for cell (slow)', async function () {+        // Fails due to VSC bugs.+        return this.skip();

VSC Insiders is now broken.

DonJayamanne

comment created time in a day

Pull request review commentmicrosoft/vscode-python

Add ability to sync INotebookModel with cell text edits

+// Copyright (c) Microsoft Corporation. All rights reserved.+// Licensed under the MIT License.++import { inject, injectable } from 'inversify';+import { TextDocument, TextDocumentChangeEvent } from 'vscode';+import type { NotebookCell, NotebookDocument } from '../../../../typings/vscode-proposed';+import { splitMultilineString } from '../../../datascience-ui/common';+import { IExtensionSingleActivationService } from '../../activation/types';+import { IDocumentManager, IVSCodeNotebook } from '../../common/application/types';+import { NativeNotebook } from '../../common/experiments/groups';+import { IDisposable, IDisposableRegistry, IExperimentsManager } from '../../common/types';+import { isNotebookCell } from '../../common/utils/misc';+import { traceError } from '../../logging';+import { INotebookEditorProvider, INotebookModel } from '../types';++@injectable()+export class CellEditSyncService implements IExtensionSingleActivationService, IDisposable {+    private readonly disposables: IDisposable[] = [];+    private mappedDocuments = new WeakMap<TextDocument, { cellId: string; model: INotebookModel }>();+    constructor(+        @inject(IDocumentManager) private readonly documentManager: IDocumentManager,+        @inject(IDisposableRegistry) disposableRegistry: IDisposableRegistry,+        @inject(IVSCodeNotebook) private readonly vscNotebook: IVSCodeNotebook,+        @inject(INotebookEditorProvider) private readonly editorProvider: INotebookEditorProvider,+        @inject(IExperimentsManager) private readonly experiment: IExperimentsManager+    ) {+        disposableRegistry.push(this);+    }+    public dispose() {+        while (this.disposables.length) {+            this.disposables.pop()?.dispose(); //NOSONAR+        }+    }+    public async activate(): Promise<void> {+        if (!this.experiment.inExperiment(NativeNotebook.experiment)) {+            return;+        }+        this.documentManager.onDidChangeTextDocument(this.onDidChangeTextDocument, this, this.disposables);+    }++    private onDidChangeTextDocument(e: TextDocumentChangeEvent) {+        if (!isNotebookCell(e.document)) {+            return;+        }++        const details = this.getEditorsAndCell(e.document);+        if (!details) {+            return;+        }++        const cell = details.model.cells.find((item) => item.id === details.cellId);+        if (!cell) {+            traceError(+                `Syncing Cell Editor aborted, Unable to find corresponding ICell for ${e.document.uri.toString()}`,+                new Error('ICell not found')+            );+            return;+        }++        cell.data.source = splitMultilineString(e.document.getText());

@rchiodo @IanMatthewHuff I'm not using the INotebookModel.update to update the model. Editing cell could end up causing this code to get executed for every keystroke, also don't see any value in triggering model updates for cell source changes (unnecessary slicing of arrays, unnecessary CPU...).

DonJayamanne

comment created time in a day

create barnchDonJayamanne/pythonVSCode

branch : syncCellEdits

created branch time in a day

push eventmicrosoft/vscode-python

Don Jayamanne

commit sha b859a3de8800eb07076e51204db48fb1445a99a4

Tests to ensure we close nb when VSC is closed (#12087) * Tests to ensure we close nb when VSC is closed

view details

push time in a day

delete branch DonJayamanne/pythonVSCode

delete branch : addCloseTests

delete time in a day

PR merged microsoft/vscode-python

Reviewers
Tests to ensure we close nb when VSC is closed skip news

For #10496

  • Tests to ensure we close/dispose our objects when nb is closed
  • Tests for opening/closing multiple notebook editors
+92 -7

1 comment

3 changed files

DonJayamanne

pr closed time in a day

push eventDonJayamanne/pythonVSCode

Don Jayamanne

commit sha 60fc26aac06a7a862d58c61c85c92e842e0786e6

Fixes

view details

Don Jayamanne

commit sha 416aae6ece187e42f815311a5274114032cb9680

Fixes

view details

push time in a day

PR opened microsoft/vscode-python

Tests to ensure we close nb when VSC is closed

For #10496

  • Tests to ensure we close/dispose our objects when nb is closed
  • Tests for opening/closing multiple notebook editors
+90 -3

0 comment

2 changed files

pr created time in a day

create barnchDonJayamanne/pythonVSCode

branch : addCloseTests

created branch time in a day

push eventmicrosoft/vscode-python

Don Jayamanne

commit sha 176f9c3df22478785454cb0e36649c3f4640f77b

Update NotebookModel with changes from VS Code Notebook UI (#12048) For #10496 Update our model when user edits VS Code cells

view details

push time in a day

delete branch DonJayamanne/pythonVSCode

delete branch : handleNBChanges

delete time in a day

PR merged microsoft/vscode-python

Reviewers
Update NotebookModel with changes from VS Code Notebook UI skip news

For #10496

  • Update our model when user edits VS Code cells

Todo:

  • [x] Tests (changes to notebooks)
  • [ ] Updating our model when user edits code in cells (separate pr)
  • [ ] Copying/pasting cells with support for cell output (separate pr)
  • [ ] Tests for handling of closing/disposing notebooks when closing nbs (separate PR)

Will be filing issues (work items) for the pending tasks

+1309 -496

1 comment

33 changed files

DonJayamanne

pr closed time in a day

push eventDonJayamanne/pythonVSCode

Don Jayamanne

commit sha 588cc66ffb7eca9cd7131ba1bbce784ab3ef89b8

Oops

view details

Don Jayamanne

commit sha 7d0cd7e3f7bce02e8a8a3ae714f154f147b035a1

Fix tests

view details

push time in a day

push eventDonJayamanne/pythonVSCode

Don Jayamanne

commit sha 156b7f41cf96c4751460cf3aa38f3a312c1f309a

Added tests

view details

push time in a day

push eventDonJayamanne/pythonVSCode

Don Jayamanne

commit sha 8deea21f722190efdca2edec63f33e07e040a393

Add tests

view details

push time in 4 days

push eventDonJayamanne/pythonVSCode

Don Jayamanne

commit sha 70fff64c667dfa6dbf43be3c58d08b70cc82d215

Fix tests

view details

push time in 4 days

Pull request review commentmicrosoft/vscode-python

Update NotebookModel with changes from VS Code Notebook UI

 export class NotebookExecutionService implements INotebookExecutionService {                         .filter((output) => !hasTransientOutputForAnotherCell(output));                      const notebookCellModel = findMappedNotebookCellModel(cell, model.cells);++                    // Set execution count, all messages should have it+                    if (+                        cells.length &&+                        'execution_count' in cells[0].data &&+                        typeof cells[0].data.execution_count === 'number'+                    ) {+                        const executionCount = cells[0].data.execution_count as number;+                        updateCellExecutionCount(notebookCellModel, model, executionCount);

I'm going that check in the method.

DonJayamanne

comment created time in 4 days

Pull request review commentmicrosoft/vscode-python

Update NotebookModel with changes from VS Code Notebook UI

 export function monitorModelCellOutputChangesAndUpdateNotebookDocument(      return disposable; }++/**+ * If a VS Code cell changes, then ensure we update the corresponding cell in our INotebookModel.+ * I.e. if a cell is added/deleted/moved then update our model.+ */+export function updateCellModelWithChangesToVSCCell(+    change: NotebookCellsChangeEvent | NotebookCellOutputsChangeEvent | NotebookCellLanguageChangeEvent,+    model: INotebookModel+) {+    switch (change.type) {+        case 'changeCellOutputs':+            // We're not interested in changes to cell output as this happens as a result of us pushing changes to the notebook.+            // I.e. cell output is already in our INotebookModel.+            return;+        case 'changeCellLanguage':+            return changeCellLanguage(change, model);+        case 'changeCells':+            return handleChangesToCells(change, model);+        default:+            // tslint:disable-next-line: no-string-literal+            assert.fail(`Unsupported cell change ${change['type']}`);+    }+}++function changeCellLanguage(change: NotebookCellLanguageChangeEvent, model: INotebookModel) {+    if (change.language !== PYTHON_LANGUAGE && change.language !== MARKDOWN_LANGUAGE) {+        throw new Error(`Unsupported cell language ${change.language}`);+    }++    const cellModel = findMappedNotebookCellModel(change.cell, model.cells);++    // VSC fires event if changing cell language from markdown to markdown.+    // https://github.com/microsoft/vscode/issues/98836+    if (+        (change.language === PYTHON_LANGUAGE && cellModel.data.cell_type === 'code') ||+        (change.language === MARKDOWN_LANGUAGE && cellModel.data.cell_type === 'markdown')+    ) {+        return;+    }++    const newCellData = createCellFrom(cellModel.data, change.language === MARKDOWN_LANGUAGE ? 'markdown' : 'code');+    const newCell: ICell = {+        ...cellModel,+        data: newCellData+    };++    model.update({+        source: 'user',+        kind: 'modify',+        newCells: [newCell],+        oldCells: [cellModel],+        oldDirty: model.isDirty,+        newDirty: true+    });++    // tslint:disable-next-line: no-any+    change.cell.outputs = cellOutputsToVSCCellOutputs(newCellData.outputs as any);

Yes

DonJayamanne

comment created time in 4 days

push eventDonJayamanne/pythonVSCode

Don Jayamanne

commit sha 0ab8028e95d5992888e5a4a0914b3a02173fe4e3

Problems in problems window

view details

push time in 4 days

issue closedmicrosoft/vscode

Support for lazy loading of split bundles in pre-load scripts for Notebooks

<!-- ⚠️⚠️ Do Not Delete This! feature_request_template ⚠️⚠️ --> <!-- Please read our Rules of Conduct: https://opensource.microsoft.com/codeofconduct/ --> <!-- Please search existing issues to avoid creating duplicates. -->

<!-- Describe the feature you'd like. -->

Preloading scripts works as expected in output renderes. However if the preload script is a bundle that lazyloads other bundle scripts, then this doesn't work.

The reason this doesn't work is because WebPack will attempt to load the resource dynamically. However this can only be done if resources are using the vscode-resource scheme (which cannot be hardcoded).

Current approach in Python webiview notebook implementation

  • We make use of __webpack_public_path__ variable, this is initialized to a global variable window.__PVSC_Public_Path
  • In our webivew we initialize the above value as follows: window.__PVSC_Public_Path = "${webView.asWebviewUri(Uri.file(<Extension dir/xyz>)).toString()}/";

This option will not work with preload scripts for notebooks

  • At the moment the only solution I can see is to dynamically generate a JS file with the above code in it
  • Ensure the above JS file is preloaded first

Again, this might not work well

  • Output renderers do not have access to asWebViewUri method, hence any attempt to generate this value based on active Notebook Editor is not guaranteed to work.
  • We (extension authors) cannot assume this value is a constant across all webviews

@rebornix /cc

closed time in 4 days

DonJayamanne

issue commentmicrosoft/vscode

Support for lazy loading of split bundles in pre-load scripts for Notebooks

That works, that's pretty much what I'm doing today. As long as we have VSCodes blessing for such a solution I'm happy. Didn't want to make any assumptions about how the scripts are loaded and the like. Closing as this issue.

Thanks again.

DonJayamanne

comment created time in 4 days

push eventDonJayamanne/pythonVSCode

Don Jayamanne

commit sha 48222885e7d73608f2a2f098f07ba06ee4ac56b8

Linter issues

view details

push time in 4 days

issue openedmicrosoft/vscode-python

Auto Save Notebooks when executing cells

src/client/datascience/notebook/autoSaveService.ts

/**

  • When executing cells, VSCode doesn't perform a save operation.
  • However in Jupyter Lab (with auto save on), even when you execute cells auto save kicks in.
  • Solution:
    • If notebook isn't saved after a cell is executed, then we can save manually.
    • We need to take the auto save delay into account (if any, for throttling).
    • Save only if user has executed (if execution count changes or cell output changes).
    • When adding/deleting/editing cells, VSC automatically performs a save.
  • Hence, we only need to handle auto save when executing cell.s */ // @injectable() // export class AutoSaveService implements IExtensionSingleActivationService {}

created time in 4 days

issue openedmicrosoft/vscode-python

Sync Notebook cells as user edits source in cell

Handle text change events

created time in 4 days

issue openedmicrosoft/vscode-python

VSCode Notebook API - Dispose Notebook resources when closing Notebooks

Use new VSC API to dispose resources when all notebook editors associated with a nb have been closed Add tests

created time in 4 days

issue openedmicrosoft/vscode-python

Copy/Past VS Code Notebook Cells - translate output into nbformat.IOutput.

https://github.com/DonJayamanne/pythonVSCode/blob/3dfbe7110ef268e91aa7cfc1e6be23b3c56120f5/src/client/datascience/notebook/helpers.ts#L82-L82

created time in 4 days

Pull request review commentmicrosoft/vscode-python

Update NotebookModel with changes from VS Code Notebook UI

 export function notebookModelToVSCNotebookData(model: INotebookModel): NotebookD         }     }; }+export function vscNotebookCellToCellModel(cell: NotebookCellData, model: INotebookModel): ICell {+    if (cell.cellKind === vscodeNotebookEnums.CellKind.Markdown) {+        return {+            data: createMarkdownCell(splitMultilineString(cell.source), true),+            file: model.file.toString(),+            id: uuid(),+            line: 0,+            state: CellState.init+        };+    }+    assert.equal(cell.language, PYTHON_LANGUAGE, 'Cannot create a non Python cell');+    return {+        // TODO: Translate output into nbformat.IOutput.

Will add githuhub issue for this.

DonJayamanne

comment created time in 4 days

Pull request review commentmicrosoft/vscode-python

Update NotebookModel with changes from VS Code Notebook UI

 export function monitorModelCellOutputChangesAndUpdateNotebookDocument(      return disposable; }++/**+ * If a VS Code cell changes, then ensure we update the corresponding cell in our INotebookModel.+ * I.e. if a cell is added/deleted/moved then update our model.+ */+export function updateCellModelWithChangesToVSCCell(

This file ensures we update changes to VSCode cell when our notebook cell changes, e.g. when we execute cells, then our Notebook model changes and we fire events (existing code), we handle those events here and update the VS Code cells.

Similarly, when user adds/deletes cells then we handle those VSCode cells here and update our model.

I.e. this file is where we keep both models in sync.

DonJayamanne

comment created time in 4 days

Pull request review commentmicrosoft/vscode-python

Update NotebookModel with changes from VS Code Notebook UI

  'use strict'; +import * as assert from 'assert'; import type { NotebookCell, NotebookDocument } from 'vscode-proposed';+import { createCellFrom } from '../../../datascience-ui/common/cellFactory';+import {+    NotebookCellLanguageChangeEvent,+    NotebookCellOutputsChangeEvent,+    NotebookCellsChangeEvent+} from '../../common/application/types';+import { MARKDOWN_LANGUAGE, PYTHON_LANGUAGE } from '../../common/constants'; import { IDisposable } from '../../common/types'; import { traceError } from '../../logging'; import { ICell, INotebookModel } from '../types';-import { cellOutputsToVSCCellOutputs } from './helpers';+import { cellOutputsToVSCCellOutputs, vscNotebookCellToCellModel } from './helpers';  export function findMappedNotebookCellData(source: ICell, cells: NotebookCell[]): NotebookCell {-    // tslint:disable-next-line: no-suspicious-comment-    // TODO: Will metadata get copied across when copying/pasting cells (cloning a cell)?     // If so, then we have a problem.     const found = cells.filter((cell) => source.id === cell.metadata.custom?.cellId); -    // tslint:disable-next-line: no-suspicious-comment-    // TODO: Once VSC provides API, throw error here.-    if (!found || !found.length) {-        traceError(`Unable to find matching cell for ${source}`);-        return cells[0];-    }+    assert.ok(found.length, `NotebookCell not found, for CellId = ${source.id} in ${source}`);

Fall back just in case VS Code changes their API. Their API will certainly change, hence this is a good way to track it - i.e. our extension should go kaboom. FYI - Fairly certain this API will change some time soon https://github.com/microsoft/vscode/issues/98828

DonJayamanne

comment created time in 4 days

Pull request review commentmicrosoft/vscode-python

Update NotebookModel with changes from VS Code Notebook UI

+// Copyright (c) Microsoft Corporation. All rights reserved.+// Licensed under the MIT License.++'use strict';++/**+ * When executing cells, VSCode doesn't perform a save operation.+ * However in Jupyter Lab (with auto save on), even when you execute cells auto save kicks in.+ * Solution:+ * - If notebook isn't saved after a cell is executed, then we can save manually.+ * - We need to take the auto save delay into account (if any, for throttling).+ * - Save only if user has executed (if execution count changes or cell output changes).+ * - When adding/deleting/editing cells, VSC automatically performs a save.+ *+ * Hence, we only need to handle auto save when executing cell.s+ */+// @injectable()

Will create separate github issue to track this.

DonJayamanne

comment created time in 4 days

Pull request review commentmicrosoft/vscode-python

Update NotebookModel with changes from VS Code Notebook UI

+// Copyright (c) Microsoft Corporation. All rights reserved.+// Licensed under the MIT License.++'use strict';++/**+ * When executing cells, VSCode doesn't perform a save operation.+ * However in Jupyter Lab (with auto save on), even when you execute cells auto save kicks in.+ * Solution:+ * - If notebook isn't saved after a cell is executed, then we can save manually.+ * - We need to take the auto save delay into account (if any, for throttling).+ * - Save only if user has executed (if execution count changes or cell output changes).+ * - When adding/deleting/editing cells, VSC automatically performs a save.+ *+ * Hence, we only need to handle auto save when executing cell.s+ */+// @injectable()

TODO: Dumped with solution so i don't forget this.

DonJayamanne

comment created time in 4 days

Pull request review commentmicrosoft/vscode-python

Update NotebookModel with changes from VS Code Notebook UI

 export interface INotebookModelModifyChange extends INotebookModelChange {     newCells: ICell[];     oldCells: ICell[]; }+export interface INotebookModelCellExecutionCountChange extends INotebookModelChange {

New event. Using our model as the source of truth. Hence when we update cell execution count, I need an event so I can update VSC code cell.

DonJayamanne

comment created time in 4 days

push eventDonJayamanne/pythonVSCode

Don Jayamanne

commit sha 3dfbe7110ef268e91aa7cfc1e6be23b3c56120f5

Oops

view details

push time in 4 days

push eventDonJayamanne/pythonVSCode

Don Jayamanne

commit sha 9aecd5f362f0e5c7b8753e31478dfebbcc3555c7

Keep stuff in sync

view details

push time in 4 days

issue openedmicrosoft/vscode

Opening a notebook triggers a cell change

<!-- ⚠️⚠️ Do Not Delete This! bug_report_template ⚠️⚠️ --> <!-- Please read our Rules of Conduct: https://opensource.microsoft.com/codeofconduct/ --> <!-- Please search existing issues to avoid creating duplicates. --> <!-- Also please test using the latest insiders build to make sure your issue has not already been fixed: https://code.visualstudio.com/insiders/ -->

<!-- Use Help > Report Issue to prefill these. --> Version: 1.46.0-insider

  • Commit: cd41dd1f6065db76c77c6e2f659bb50e6f558dec
  • Date: 2020-05-29T05:45:24.735Z
  • Electron: 7.3.0
  • Chrome: 78.0.3904.130
  • Node.js: 12.8.1
  • V8: 7.8.279.23-electron.0
  • OS: Darwin x64 19.5.0

Steps to Reproduce:

1.Open a notebook 2.The cell change event gets fired.

User hasn't made any chanages, but opening a notebook triggers the change event to get fired. I think its unnecessary.

<!-- Launch with code --disable-extensions to check. --> Does this issue occur when all extensions are disabled?: Yes/No

@rebornix

created time in 4 days

issue openedmicrosoft/vscode

Moving cells/up down in Notebooks does not trigger a save

<!-- ⚠️⚠️ Do Not Delete This! feature_request_template ⚠️⚠️ --> <!-- Please read our Rules of Conduct: https://opensource.microsoft.com/codeofconduct/ --> <!-- Please search existing issues to avoid creating duplicates. -->

<!-- Describe the feature you'd like. -->

Currently when you move cells up/down, the save method is not triggered in the NotebookContentProvider

In Jupyter Notebooks, cell order is preserved in the underlying ipynb file.

@rebornix

created time in 4 days

issue openedmicrosoft/vscode

Change cell language fires change event

<!-- ⚠️⚠️ Do Not Delete This! bug_report_template ⚠️⚠️ --> <!-- Please read our Rules of Conduct: https://opensource.microsoft.com/codeofconduct/ --> <!-- Please search existing issues to avoid creating duplicates. --> <!-- Also please test using the latest insiders build to make sure your issue has not already been fixed: https://code.visualstudio.com/insiders/ -->

<!-- Use Help > Report Issue to prefill these. --> Version: 1.46.0-insider

  • Commit: cd41dd1f6065db76c77c6e2f659bb50e6f558dec
  • Date: 2020-05-29T05:45:24.735Z
  • Electron: 7.3.0
  • Chrome: 78.0.3904.130
  • Node.js: 12.8.1
  • V8: 7.8.279.23-electron.0
  • OS: Darwin x64 19.5.0

Steps to Reproduce:

1.Open a notebook 2.Create a markdown cell and change the language to markdown.

A notebook event if fires for change of cell language even though the current language is already the same.

I would not expect the event to get fired if the cell language is the same. Also as a side effect the cell output change event also gets fired (feels this is a noop change, hence events shouldn't get fired)

<!-- Launch with code --disable-extensions to check. --> Does this issue occur when all extensions are disabled?: Yes/No

@rebornix

created time in 4 days

Pull request review commentmicrosoft/vscode-python

Add support for VS Code's experiment service

+// Copyright (c) Microsoft Corporation. All rights reserved.+// Licensed under the MIT License.++'use strict';++import { inject, named } from 'inversify';+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 { GLOBAL_MEMENTO, IConfigurationService, IExperimentService, IMemento, IPythonSettings } from '../types';+import { ExperimentationTelemetry } from './telemetry';++export class ExperimentService implements IExperimentService {

Blocking on interface name

kimadeline

comment created time in 4 days

Pull request review commentmicrosoft/vscode-python

Add support for VS Code's experiment service

+// Copyright (c) Microsoft Corporation. All rights reserved.+// Licensed under the MIT License.++'use strict';++import { inject, named } from 'inversify';+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 { GLOBAL_MEMENTO, IConfigurationService, IExperimentService, IMemento, IPythonSettings } from '../types';+import { ExperimentationTelemetry } from './telemetry';++export class ExperimentService implements IExperimentService {

Shouldn't this class implement IExperimentsManager So tomorrow when we replace the existing experiments manager all we need to do is change the mapping, after all that's what interfaces solve, changing the implementation without having to change all of the code.

With this approach I'm concerned that we're going to modify all of the to use a new interface with both are identical (should be identical). with the exception of inExperiment returning a promise, which needs to be resolved in existing code regardless.

kimadeline

comment created time in 4 days

Pull request review commentmicrosoft/vscode-python

Add support for VS Code's experiment service

+// Copyright (c) Microsoft Corporation. All rights reserved.+// Licensed under the MIT License.++'use strict';++import { IExperimentationTelemetry } from 'vscode-tas-client';+import { sendTelemetryEvent, setSharedProperty } from '../../telemetry';++export class ExperimentationTelemetry implements IExperimentationTelemetry {+    public setSharedProperty(name: string, value: string): void {+        // Add the shared property to all telemetry being sent, not just events being sent by the experimentation package.+        setSharedProperty(name, value);+    }

Else we have two ways of sending telemetry now. We have this new class or we can just use the functions. Today we use functions directly without any dependency, now we have a new way of doing the same thing. Personally I'd prefer to see one approach.

kimadeline

comment created time in 4 days

Pull request review commentmicrosoft/vscode-python

Add support for VS Code's experiment service

+// Copyright (c) Microsoft Corporation. All rights reserved.+// Licensed under the MIT License.++'use strict';++import { IExperimentationTelemetry } from 'vscode-tas-client';+import { sendTelemetryEvent, setSharedProperty } from '../../telemetry';++export class ExperimentationTelemetry implements IExperimentationTelemetry {+    public setSharedProperty(name: string, value: string): void {+        // Add the shared property to all telemetry being sent, not just events being sent by the experimentation package.+        setSharedProperty(name, value);+    }++    public postEvent(eventName: string, properties: Map<string, string>): void {+        const formattedProperties: { [key: string]: string } = {};+        properties.forEach((value, key) => {+            formattedProperties[key] = value;+        });++        // tslint:disable-next-line: no-any+        sendTelemetryEvent(eventName as any, undefined, formattedProperties);

Why not pass properties into sendTelemetryEvent instead of copying it.

        sendTelemetryEvent(eventName as any, undefined, properties);
kimadeline

comment created time in 4 days

Pull request review commentmicrosoft/vscode-python

Add support for VS Code's experiment service

+// Copyright (c) Microsoft Corporation. All rights reserved.+// Licensed under the MIT License.++'use strict';++import { IExperimentationTelemetry } from 'vscode-tas-client';+import { sendTelemetryEvent, setSharedProperty } from '../../telemetry';++export class ExperimentationTelemetry implements IExperimentationTelemetry {+    public setSharedProperty(name: string, value: string): void {+        // Add the shared property to all telemetry being sent, not just events being sent by the experimentation package.+        setSharedProperty(name, value);+    }

Not sure why we need this class, why not call the telemetry functions directly?

kimadeline

comment created time in 4 days

Pull request review commentmicrosoft/vscode-python

Expose API to show DS Data Viewer component from external extension

 export function registerTypes(serviceManager: IServiceManager) {     serviceManager.add<IProtocolParser>(IProtocolParser, ProtocolParser);
     serviceManager.addSingleton<IJupyterDebugService>(IJupyterDebugService, MultiplexingDebugService, Identifiers.MULTIPLEXING_DEBUGSERVICE);
     serviceManager.addSingleton<IJupyterDebugService>(IJupyterDebugService, JupyterDebugService, Identifiers.RUN_BY_LINE_DEBUGSERVICE);
+    serviceManager.addFactory<IJupyterVariableDataProvider>(IJupyterVariableDataProviderFactory, (context) => {

Yup agreed, lets be consistent.

sevillal

comment created time in 4 days

Pull request review commentmicrosoft/vscode-python

Expose API to show DS Data Viewer component from external extension

 export class DataViewer extends WebViewHost<IDataViewerMapping> implements IData             useCustomEditorApi,             false         );+    } -        // Load the web panel using our current directory as we don't expect to load any other files-        super.loadWebPanel(process.cwd()).catch(traceError);+    private static trimTitle(title: string): string {

Speaking for myself, I'd go for just letting the long names through. Let VSCode deal with it and don't have to own any custom trimming.

Agreed.

sevillal

comment created time in 4 days

issue commentmicrosoft/vscode

Notebook Backlog

Python hasn't adopted the in-core implemented apis yet,

We are adding this in the python extension. You can track our progress here https://github.com/microsoft/vscode-python/issues/10496

rebornix

comment created time in 4 days

issue commentmicrosoft/vscode

Handle links with href='blob:..' in WebViews and Notebook

U might have to setup the csp (for data and blobs), this here's what we have:

<meta http-equiv="Content-Security-Policy" content="img-src 'self' data: https: http: blob: ${
                    webView.cspSource
                }; default-src 'unsafe-inline' 'unsafe-eval' vscode-resource: data: https: http: blob:;">
DonJayamanne

comment created time in 4 days

push eventDonJayamanne/pythonVSCode

Luciana Abud

commit sha e06f9513895b6562ff3cf97cc16d49737ba09b02

Fix pythonPath control group min and max values (#12042) * Enable pythonPath deprecation experiment to 4% of users * Fix min and max values for pythonPath control group

view details

Luciana Abud

commit sha 360396688e023ea1c4b806986d9dc758a84384be

Scale down number of users seeing survey prompt (#12001)

view details

Don Jayamanne

commit sha cc93436f8f8bcd5a315c4099872fa25c4fe8edbf

Support Notebook Renderers with VS Code Notebooks (disabled) (#11999) Note: It is disabled to ensure we do not ship/bundle these things with official VS Code release (not yet). For #10496 Add notebook renderers Please note there's a big hack in this code (its to get around a VS Code issue). Apart from that the rest should be ok

view details

Don Jayamanne

commit sha d4d96e30d2b272c05504b7f6ff580f7702f887e6

Use deemon package to support background compilation (#12060) For #12059 This allows developers to reload VS Code without having to re-start compilations (compilation of DS can take some time). for my workflow this is super useful (restarting VSC every now and then). Hopefully others will find this as useful. npm run compiled will ensure npm run compile is running in the background and it will need to be killed manualy. npmjs.com/package/deemon I've been trying this my personal branches for over a week now (uninstalling/re-installing the package) & it works well. Not changing any of the build steps, as this will leave a process running in the background Will change tasks to optionally use this once I have tested this internally (for now I'm just running this manually npm run compiled

view details

Don Jayamanne

commit sha 6be2eb10a63b2bab48d8d06d898fd64221845b06

Misc

view details

push time in 4 days

push eventDonJayamanne/pythonVSCode

Don Jayamanne

commit sha 8ef0b2b3b8fb4b827320326754c7ab670cb63c91

Use ts-loader instead of awesome-typescript-loader (#12012)

view details

Jake Bailey

commit sha 9cab488a6401b62206a60b4860f59f4071868940

Revert LS issue template changes (#12016)

view details

Tim Ruscica

commit sha 7fd42b58ad8a637eb2ca9d19975f0f0867a61404

changed column order (#12019)

view details

Ian Huff

commit sha 3a36ee86d47626617e0434dba68c641c1441650e

Change rawKernel process prewarm (#12014)

view details

Don Jayamanne

commit sha 9f533e527b61be7513968856cc366d94867e6186

Faster pipelines, split node unit tests from python unit tests (#12015)

view details

Ian Huff

commit sha 6b6e722aabe32f79029113fc2463565fc4b4de0f

log exception in raw kernel session start (#12018)

view details

Rich Chiodo

commit sha 9f7da8bb1b75b6bca21764c883a71614cb855e46

Disable cdn tests again (#12022)

view details

Luciana Abud

commit sha 8b83f40c2734622a3723fdee2cbde425fc29b1c1

Enable pythonPath deprecation experiment to 4% of users (#12002)

view details

Don Jayamanne

commit sha d4749aa145ad98dee3e834b674b0970b625eb435

Faster node unit tests (#12027) For #11999 When running unit tests we don't need to compile the webviews (no need to compile react, etc). Total time to compile code down from 6 minutes to 1 minute (i.e. 5 minutes faster CI to know whether tests passed/failed) Note the drop in compile times from ~7minutes to ~50s. (basically 6 minutes faster)

view details

Don Jayamanne

commit sha 8c8efb829296685aa271b7155bba7ccf10362578

Ensure we can use proposed VS Code API with ts-node (#12038) * Use a proxy type for propsed types (for ts-node) * Oh yes `ts-node` sucks, cuz it doesn't work the same way as `tsc` compiler

view details

Luciana Abud

commit sha e06f9513895b6562ff3cf97cc16d49737ba09b02

Fix pythonPath control group min and max values (#12042) * Enable pythonPath deprecation experiment to 4% of users * Fix min and max values for pythonPath control group

view details

Luciana Abud

commit sha 360396688e023ea1c4b806986d9dc758a84384be

Scale down number of users seeing survey prompt (#12001)

view details

Don Jayamanne

commit sha cc93436f8f8bcd5a315c4099872fa25c4fe8edbf

Support Notebook Renderers with VS Code Notebooks (disabled) (#11999) Note: It is disabled to ensure we do not ship/bundle these things with official VS Code release (not yet). For #10496 Add notebook renderers Please note there's a big hack in this code (its to get around a VS Code issue). Apart from that the rest should be ok

view details

Don Jayamanne

commit sha d4d96e30d2b272c05504b7f6ff580f7702f887e6

Use deemon package to support background compilation (#12060) For #12059 This allows developers to reload VS Code without having to re-start compilations (compilation of DS can take some time). for my workflow this is super useful (restarting VSC every now and then). Hopefully others will find this as useful. npm run compiled will ensure npm run compile is running in the background and it will need to be killed manualy. npmjs.com/package/deemon I've been trying this my personal branches for over a week now (uninstalling/re-installing the package) & it works well. Not changing any of the build steps, as this will leave a process running in the background Will change tasks to optionally use this once I have tested this internally (for now I'm just running this manually npm run compiled

view details

push time in 4 days

issue closedmicrosoft/vscode-python

Use deemon package for background compilations

Built by VSC === awesome.

closed time in 4 days

DonJayamanne

push eventmicrosoft/vscode-python

Don Jayamanne

commit sha d4d96e30d2b272c05504b7f6ff580f7702f887e6

Use deemon package to support background compilation (#12060) For #12059 This allows developers to reload VS Code without having to re-start compilations (compilation of DS can take some time). for my workflow this is super useful (restarting VSC every now and then). Hopefully others will find this as useful. npm run compiled will ensure npm run compile is running in the background and it will need to be killed manualy. npmjs.com/package/deemon I've been trying this my personal branches for over a week now (uninstalling/re-installing the package) & it works well. Not changing any of the build steps, as this will leave a process running in the background Will change tasks to optionally use this once I have tested this internally (for now I'm just running this manually npm run compiled

view details

push time in 4 days

delete branch DonJayamanne/pythonVSCode

delete branch : deemon

delete time in 4 days

PR merged microsoft/vscode-python

Reviewers
Use deemon package to support background compilation

For #12059

  • This allows developers to reload VS Code without having to re-start compilations (compilation of DS can take some time).

for my workflow this is super useful (restarting VSC every now and then).

Hopefully others will find this as useful.

npm run compiled will ensure npm run compile is running in the background and it will need to be killed manualy.

https://www.npmjs.com/package/deemon I've been trying this my personal branches for over a week now (uninstalling/re-installing the package) & it works well.

  • Not changing any of the build steps, as this will leave a process running in the background
  • Will change tasks to optionally use this once I have tested this internally (for now I'm just running this manually npm run compiled
+39 -0

1 comment

3 changed files

DonJayamanne

pr closed time in 4 days

issue closedmicrosoft/vscode-python

Registering a new conda interpreter as a kernel does not connect

May be related to #11646

Steps conda create -n freshEnv python In vscode select freshEnv as the current interpreter Launch the interactive window You will be prompted to install ipykernel Install will complete but server will never connect

ipykernel is installed, but if we go back and try to use this interpreter it will not ask to install ipykernel again, but it will fail to connect to the jupyter server.

closed time in 4 days

IanMatthewHuff

issue closedmicrosoft/vscode-python

Switching to a conda interpreter via the kernel switcher fails to install ipykernel if current interpreter is not conda

conda create -n myNewEnv python

Start up an Interactive Window session with a .venv as the selected python interpreter Via the kernel switcher try to change to myNewEnv It will ask to install ipykernel into myNewEnv Choose to install with conda

Result:

The default interactive shell is now zsh. To update your account to use zsh, please run chsh -s /bin/zsh. For more details, please visit https://support.apple.com/kb/HT208050. Ians-MacBook-Pro:DebuggingDemo ianhuff$ source /Users/ianhuff/Documents/DataScience/DebuggingDemo/.debugEnv/bin/activate (.debugEnv) Ians-MacBook-Pro:DebuggingDemo ianhuff$ /Users/ianhuff/Documents/DataScience/DebuggingDemo/.debugEnv/bin/python /Users/ianhuff/GitHub/vscode-python-ianhu/pythonFiles/pyvsc-run-isolated.py /Users/ianhuff/GitHub/vscode-python-ianhu/pythonFiles/shell_exec.py /Users/ianhuff/opt/miniconda3/bin/conda install --name kernelSwitchEnv4 ipykernel -y /var/folders/q7/cn8fg6s94fgdcl0h7rbxldf00000gn/T/tmp-13674iJ9OcUzhf3Qj.log Executing command in shell >> /Users/ianhuff/opt/miniconda3/bin/conda install --name kernelSwitchEnv4 ipykernel -y Traceback (most recent call last): File "/Users/ianhuff/opt/miniconda3/bin/conda", line 12, in <module> from conda.cli import main ModuleNotFoundError: No module named 'conda' Traceback (most recent call last): File "/Users/ianhuff/GitHub/vscode-python-ianhu/pythonFiles/shell_exec.py", line 26, in <module> subprocess.check_call(shell_args, stdout=sys.stdout, stderr=sys.stderr) File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py", line 363, in check_call raise CalledProcessError(retcode, cmd) subprocess.CalledProcessError: Command '['/Users/ianhuff/opt/miniconda3/bin/conda', 'install', '--name', 'kernelSwitchEnv4', 'ipykernel', '-y']' returned non-zero exit status 1.

In my quick debug into this looked like syncTerminalService.sendCommand was interesting. If you remove the cancel token the install will actually go forward and complete, but it was not able to connect after that.

closed time in 4 days

IanMatthewHuff

issue commentmicrosoft/vscode-python

Data is missing from completion items when translating to monaco

Check with @IanMatthewHuff (possibly done in Jedi implementation for NB)

rchiodo

comment created time in 4 days

more