Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into rchiodo/variable_flash
Browse files Browse the repository at this point in the history
  • Loading branch information
rchiodo committed Jun 30, 2020
2 parents 4282243 + 0ac2757 commit 50e8df4
Show file tree
Hide file tree
Showing 71 changed files with 6,466 additions and 561 deletions.
1 change: 1 addition & 0 deletions news/2 Fixes/10993.md
@@ -0,0 +1 @@
Provided a method for external partners to participate in jupyter server URI picking/authentication.
1 change: 1 addition & 0 deletions news/3 Code Health/12539.md
@@ -0,0 +1 @@
Fix linux nightly tests so they run and report results. Also seems to get rid of stream destroyed messages for raw kernel.
18 changes: 9 additions & 9 deletions package.json
Expand Up @@ -1081,55 +1081,55 @@
"command": "python.datascience.notebookeditor.undocells",
"title": "%python.command.python.datascience.undocells.title%",
"category": "Python",
"when": "python.datascience.haveinteractivecells && python.datascience.featureenabled && python.datascience.isnativeactive && !notebookEditorFocused"
"when": "python.datascience.haveinteractivecells && python.datascience.featureenabled && python.datascience.isnativeactive && !notebookEditorFocused && python.datascience.isnotebooktrusted"
},
{
"command": "python.datascience.notebookeditor.redocells",
"title": "%python.command.python.datascience.redocells.title%",
"category": "Python",
"when": "python.datascience.havenativeredoablecells && python.datascience.featureenabled && python.datascience.isnativeactive && !notebookEditorFocused"
"when": "python.datascience.havenativeredoablecells && python.datascience.featureenabled && python.datascience.isnativeactive && !notebookEditorFocused&& python.datascience.isnotebooktrusted"
},
{
"command": "python.datascience.notebookeditor.removeallcells",
"title": "%python.command.python.datascience.notebookeditor.removeallcells.title%",
"category": "Python",
"when": "python.datascience.havenativecells && python.datascience.featureenabled && python.datascience.isnativeactive"
"when": "python.datascience.havenativecells && python.datascience.featureenabled && python.datascience.isnativeactive && python.datascience.isnotebooktrusted"
},
{
"command": "python.datascience.notebookeditor.interruptkernel",
"title": "%python.command.python.datascience.interruptkernel.title%",
"category": "Python",
"when": "python.datascience.isnativeactive && python.datascience.featureenabled"
"when": "python.datascience.isnativeactive && python.datascience.featureenabled && python.datascience.isnotebooktrusted"
},
{
"command": "python.datascience.notebookeditor.restartkernel",
"title": "%python.command.python.datascience.restartkernel.title%",
"category": "Python",
"when": "python.datascience.isnativeactive && python.datascience.featureenabled"
"when": "python.datascience.isnativeactive && python.datascience.featureenabled && python.datascience.isnotebooktrusted"
},
{
"command": "python.datascience.notebookeditor.runallcells",
"title": "%python.command.python.datascience.notebookeditor.runallcells.title%",
"category": "Python",
"when": "python.datascience.isnativeactive && python.datascience.featureenabled"
"when": "python.datascience.isnativeactive && python.datascience.featureenabled && python.datascience.isnotebooktrusted"
},
{
"command": "python.datascience.notebookeditor.runselectedcell",
"title": "%python.command.python.datascience.notebookeditor.runselectedcell.title%",
"category": "Python",
"when": "python.datascience.isnativeactive && python.datascience.featureenabled && python.datascience.havecellselected && !notebookEditorFocused"
"when": "python.datascience.isnativeactive && python.datascience.featureenabled && python.datascience.havecellselected && !notebookEditorFocused && python.datascience.isnotebooktrusted"
},
{
"command": "python.datascience.notebookeditor.runselectedcell",
"title": "%python.command.python.datascience.notebookeditor.runselectedcell.title%",
"category": "Python",
"when": "python.datascience.isnativeactive && python.datascience.featureenabled && notebookEditorFocused"
"when": "python.datascience.isnativeactive && python.datascience.featureenabled && notebookEditorFocused && python.datascience.isnotebooktrusted"
},
{
"command": "python.datascience.notebookeditor.addcellbelow",
"title": "%python.command.python.datascience.notebookeditor.addcellbelow.title%",
"category": "Python",
"when": "python.datascience.isnativeactive && python.datascience.featureenabled"
"when": "python.datascience.isnativeactive && python.datascience.featureenabled && python.datascience.isnotebooktrusted"
},
{
"command": "python.datascience.expandallcells",
Expand Down
10 changes: 9 additions & 1 deletion package.nls.json
Expand Up @@ -544,5 +544,13 @@
"DataScience.step": "Run next line (F10)",
"DataScience.usingPreviewNotebookWithOtherNotebookWarning": "Using the Preview Notebook Editor along with the stable Notebook Editor is not recommended. Doing so could result in data loss or corruption of notebooks.",
"DataScience.previewNotebookOnlySupportedInVSCInsiders": "The Preview Notebook Editor is supported only in the Insiders version of Visual Studio Code.",
"DataScienceNotebookSurveyBanner.bannerMessage": "Can you please take 2 minutes to tell us how the Preview Notebook Editor is working for you?"
"DataScienceNotebookSurveyBanner.bannerMessage": "Can you please take 2 minutes to tell us how the Preview Notebook Editor is working for you?",
"DataScience.unknownServerUri": "Server URI cannot be used. Did you uninstall an extension that provided a Jupyter server connection?",
"DataScienceRendererExtension.installingExtension": "Installing Notebook Renderers extension...",
"DataScienceRendererExtension.installationCompleteMessage": "complete.",
"DataScienceRendererExtension.startingDownloadOutputMessage": "Starting download of Notebook Renderers extension.",
"DataScienceRendererExtension.downloadingMessage": "Downloading Notebook Renderers Extension...",
"DataScienceRendererExtension.downloadCompletedOutputMessage": "Notebook Renderers extension download complete.",
"DataScience.uriProviderDescriptionFormat": "{0} (From {1} extension)",
"DataScience.unknownPackage": "unknown"
}
12 changes: 12 additions & 0 deletions src/client/api.ts
Expand Up @@ -8,6 +8,7 @@ import { isTestExecution } from './common/constants';
import { traceError } from './common/logger';
import { IConfigurationService, Resource } from './common/types';
import { IDataViewerDataProvider, IDataViewerFactory } from './datascience/data-viewing/types';
import { IJupyterUriProvider, IJupyterUriProviderRegistration } from './datascience/types';
import { getDebugpyLauncherArgs, getDebugpyPackagePath } from './debugger/extension/adapter/remoteLaunchers';
import { IInterpreterService } from './interpreter/contracts';
import { IServiceContainer, IServiceManager } from './ioc/types';
Expand Down Expand Up @@ -82,6 +83,11 @@ export interface IExtensionApi {
* @param {string} title Data Viewer title
*/
showDataViewer(dataProvider: IDataViewerDataProvider, title: string): Promise<void>;
/**
* Registers a remote server provider component that's used to pick remote jupyter server URIs
* @param serverProvider object called back when picking jupyter server URI
*/
registerRemoteServerProvider(serverProvider: IJupyterUriProvider): void;
};
}

Expand Down Expand Up @@ -127,6 +133,12 @@ export function buildApi(
async showDataViewer(dataProvider: IDataViewerDataProvider, title: string): Promise<void> {
const dataViewerProviderService = serviceContainer.get<IDataViewerFactory>(IDataViewerFactory);
await dataViewerProviderService.create(dataProvider, title);
},
registerRemoteServerProvider(picker: IJupyterUriProvider): void {
const container = serviceContainer.get<IJupyterUriProviderRegistration>(
IJupyterUriProviderRegistration
);
container.registerProvider(picker);
}
}
};
Expand Down
34 changes: 26 additions & 8 deletions src/client/common/application/notebook.ts
Expand Up @@ -17,6 +17,7 @@ import { UseProposedApi } from '../constants';
import { NotebookEditorSupport } from '../experiments/groups';
import { IDisposableRegistry, IExperimentsManager } from '../types';
import {
IApplicationEnvironment,
IVSCodeNotebook,
NotebookCellLanguageChangeEvent,
NotebookCellOutputsChangeEvent,
Expand All @@ -26,24 +27,34 @@ import {
@injectable()
export class VSCodeNotebook implements IVSCodeNotebook {
public get onDidChangeActiveNotebookEditor(): Event<NotebookEditor | undefined> {
return this.notebook.onDidChangeActiveNotebookEditor;
return this.canUseNotebookApi
? this.notebook.onDidChangeActiveNotebookEditor
: new EventEmitter<NotebookEditor | undefined>().event;
}
public get onDidOpenNotebookDocument(): Event<NotebookDocument> {
return this.notebook.onDidOpenNotebookDocument;
return this.canUseNotebookApi
? this.notebook.onDidOpenNotebookDocument
: new EventEmitter<NotebookDocument>().event;
}
public get onDidCloseNotebookDocument(): Event<NotebookDocument> {
return this.notebook.onDidCloseNotebookDocument;
return this.canUseNotebookApi
? this.notebook.onDidCloseNotebookDocument
: new EventEmitter<NotebookDocument>().event;
}
public get notebookDocuments(): ReadonlyArray<NotebookDocument> {
return this.notebook.notebookDocuments;
return this.canUseNotebookApi ? this.notebook.notebookDocuments : [];
}
public get notebookEditors() {
return this.notebook.visibleNotebookEditors;
return this.canUseNotebookApi ? this.notebook.visibleNotebookEditors : [];
}
public get onDidChangeNotebookDocument(): Event<
NotebookCellsChangeEvent | NotebookCellOutputsChangeEvent | NotebookCellLanguageChangeEvent
> {
return this._onDidChangeNotebookDocument.event;
return this.canUseNotebookApi
? this._onDidChangeNotebookDocument.event
: new EventEmitter<
NotebookCellsChangeEvent | NotebookCellOutputsChangeEvent | NotebookCellLanguageChangeEvent
>().event;
}
public get activeNotebookEditor(): NotebookEditor | undefined {
if (!this.useProposedApi) {
Expand All @@ -63,14 +74,21 @@ export class VSCodeNotebook implements IVSCodeNotebook {
>();
private addedEventHandlers?: boolean;
private _notebook?: typeof notebook;
private readonly canUseNotebookApi?: boolean;
private readonly handledCellChanges = new WeakSet<VSCNotebookCellsChangeEvent>();
constructor(
@inject(UseProposedApi) private readonly useProposedApi: boolean,
@inject(IDisposableRegistry) private readonly disposables: IDisposableRegistry,
@inject(IExperimentsManager) readonly experimentManager: IExperimentsManager
@inject(IExperimentsManager) readonly experimentManager: IExperimentsManager,
@inject(IApplicationEnvironment) readonly env: IApplicationEnvironment
) {
if (this.useProposedApi && experimentManager.inExperiment(NotebookEditorSupport.nativeNotebookExperiment)) {
if (
this.useProposedApi &&
experimentManager.inExperiment(NotebookEditorSupport.nativeNotebookExperiment) &&
this.env.channel === 'insiders'
) {
this.addEventHandlers();
this.canUseNotebookApi = true;
}
}
public registerNotebookContentProvider(notebookType: string, provider: NotebookContentProvider): Disposable {
Expand Down
30 changes: 22 additions & 8 deletions src/client/common/process/baseDaemon.ts
Expand Up @@ -8,6 +8,7 @@ import * as os from 'os';
import { Subject } from 'rxjs/Subject';
import * as util from 'util';
import { MessageConnection, NotificationType, RequestType, RequestType0 } from 'vscode-jsonrpc';
import { IPlatformService } from '../../common/platform/types';
import { traceError, traceInfo, traceVerbose, traceWarning } from '../logger';
import { IDisposable } from '../types';
import { createDeferred, Deferred } from '../utils/async';
Expand Down Expand Up @@ -49,6 +50,7 @@ export abstract class BasePythonDaemon {
private disposed = false;
constructor(
protected readonly pythonExecutionService: IPythonExecutionService,
protected readonly platformService: IPlatformService,
protected readonly pythonPath: string,
public readonly proc: ChildProcess,
public readonly connection: MessageConnection
Expand All @@ -61,15 +63,27 @@ export abstract class BasePythonDaemon {
this.monitorConnection();
}
public dispose() {
try {
this.disposed = true;
// The daemon should die as a result of this.
this.connection.sendNotification(new NotificationType('exit'));
this.proc.kill();
} catch {
noop();
// Make sure that we only dispose once so we are not sending multiple kill signals or notifications
// This daemon can be held by multiple disposes such as a jupyter server daemon process which can
// be disposed by both the connection and the main async disposable
if (!this.disposed) {
try {
this.disposed = true;

// Proc.kill uses a 'SIGTERM' signal by default to kill. This was failing to kill the process
// sometimes on Mac and Linux. Changing this over to a 'SIGKILL' to fully kill the process.
// Windows closes with a different non-signal message, so keep that the same
// See kill_kernel message of kernel_launcher_daemon.py for and example of this.
if (this.platformService.isWindows) {
this.proc.kill();
} else {
this.proc.kill('SIGKILL');
}
} catch {
noop();
}
this.disposables.forEach((item) => item.dispose());
}
this.disposables.forEach((item) => item.dispose());
}
public execObservable(args: string[], options: SpawnOptions): ObservableExecutionResult<string> {
if (this.isAlive && this.canExecFileUsingDaemon(args, options)) {
Expand Down
4 changes: 3 additions & 1 deletion src/client/common/process/pythonDaemon.ts
Expand Up @@ -9,6 +9,7 @@ import { PythonExecInfo } from '../../pythonEnvironments/exec';
import { InterpreterInformation } from '../../pythonEnvironments/info';
import { extractInterpreterInfo } from '../../pythonEnvironments/info/interpreter';
import { traceWarning } from '../logger';
import { IPlatformService } from '../platform/types';
import { BasePythonDaemon } from './baseDaemon';
import { PythonEnvInfo } from './internal/scripts';
import {
Expand All @@ -34,11 +35,12 @@ export class DaemonError extends Error {
export class PythonDaemonExecutionService extends BasePythonDaemon implements IPythonDaemonExecutionService {
constructor(
pythonExecutionService: IPythonExecutionService,
platformService: IPlatformService,
pythonPath: string,
proc: ChildProcess,
connection: MessageConnection
) {
super(pythonExecutionService, pythonPath, proc, connection);
super(pythonExecutionService, platformService, pythonPath, proc, connection);
}
public async getInterpreterInformation(): Promise<InterpreterInformation | undefined> {
try {
Expand Down
10 changes: 9 additions & 1 deletion src/client/common/process/pythonDaemonFactory.ts
Expand Up @@ -13,6 +13,7 @@ import {
import { EXTENSION_ROOT_DIR } from '../../constants';
import { PYTHON_WARNINGS } from '../constants';
import { traceDecorators, traceError } from '../logger';
import { IPlatformService } from '../platform/types';
import { IDisposable, IDisposableRegistry } from '../types';
import { createDeferred } from '../utils/async';
import { BasePythonDaemon } from './baseDaemon';
Expand All @@ -26,6 +27,7 @@ export class PythonDaemonFactory {
protected readonly disposables: IDisposableRegistry,
protected readonly options: DaemonExecutionFactoryCreationOptions,
protected readonly pythonExecutionService: IPythonExecutionService,
protected readonly platformService: IPlatformService,
protected readonly activatedEnvVariables?: NodeJS.ProcessEnv
) {
if (!options.pythonPath) {
Expand Down Expand Up @@ -82,7 +84,13 @@ export class PythonDaemonFactory {
await this.testDaemon(connection);

const cls = this.options.daemonClass ?? PythonDaemonExecutionService;
const instance = new cls(this.pythonExecutionService, this.pythonPath, daemonProc.proc, connection);
const instance = new cls(
this.pythonExecutionService,
this.platformService,
this.pythonPath,
daemonProc.proc,
connection
);
if (instance instanceof BasePythonDaemon) {
this.disposables.push(instance);
return (instance as unknown) as T;
Expand Down
4 changes: 3 additions & 1 deletion src/client/common/process/pythonDaemonPool.ts
@@ -1,6 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

import { IPlatformService } from '../../common/platform/types';
import { PythonExecInfo } from '../../pythonEnvironments/exec';
import { InterpreterInformation } from '../../pythonEnvironments/info';
import { IDisposableRegistry } from '../types';
Expand Down Expand Up @@ -32,10 +33,11 @@ export class PythonDaemonExecutionServicePool extends PythonDaemonFactory implem
disposables: IDisposableRegistry,
options: PooledDaemonExecutionFactoryCreationOptions,
pythonExecutionService: IPythonExecutionService,
platformService: IPlatformService,
activatedEnvVariables?: NodeJS.ProcessEnv,
private readonly timeoutWaitingForDaemon: number = 1_000
) {
super(disposables, options, pythonExecutionService, activatedEnvVariables);
super(disposables, options, pythonExecutionService, platformService, activatedEnvVariables);
this.disposables.push(this);
}
public async initialize() {
Expand Down

0 comments on commit 50e8df4

Please sign in to comment.