Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unify node/web kernel and remove iw reference in kernel component #10853

Merged
merged 10 commits into from
Jul 20, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
172 changes: 86 additions & 86 deletions TELEMETRY.md
Original file line number Diff line number Diff line change
Expand Up @@ -927,29 +927,29 @@ No properties for event

[src/kernels/telemetry/sendKernelTelemetryEvent.ts](https://github.com/microsoft/vscode-jupyter/tree/main/src/kernels/telemetry/sendKernelTelemetryEvent.ts)
```typescript
properties?: P[E] & { waitBeforeSending?: Promise<void> },
ex?: Error
) {
if (eventName === Telemetry.ExecuteCell) {
setSharedProperty('userExecutedCell', 'true');
}
properties?: P[E] & { waitBeforeSending?: Promise<void> },
ex?: Error
) {
if (eventName === Telemetry.ExecuteCell) {
setSharedProperty('userExecutedCell', 'true');
}

```


[src/kernels/telemetry/sendKernelTelemetryEvent.ts](https://github.com/microsoft/vscode-jupyter/tree/main/src/kernels/telemetry/sendKernelTelemetryEvent.ts)
```typescript
stopWatch?: StopWatch,
properties?: P[E] & { [waitBeforeSending]?: Promise<void> }
) {
if (eventName === Telemetry.ExecuteCell) {
setSharedProperty('userExecutedCell', 'true');
}
stopWatch?: StopWatch,
properties?: P[E] & { [waitBeforeSending]?: Promise<void> }
) {
if (eventName === Telemetry.ExecuteCell) {
setSharedProperty('userExecutedCell', 'true');
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
```


[src/kernels/kernel.base.ts](https://github.com/microsoft/vscode-jupyter/tree/main/src/kernels/kernel.base.ts)
[src/kernels/kernel.ts](https://github.com/microsoft/vscode-jupyter/tree/main/src/kernels/kernel.ts)
```typescript
}
public async executeCell(cell: NotebookCell, codeOverride?: string): Promise<NotebookCellRunState> {
Expand Down Expand Up @@ -1889,7 +1889,7 @@ No description provided

## Locations Used

[src/kernels/kernel.base.ts](https://github.com/microsoft/vscode-jupyter/tree/main/src/kernels/kernel.base.ts)
[src/kernels/kernel.ts](https://github.com/microsoft/vscode-jupyter/tree/main/src/kernels/kernel.ts)
```typescript
await this.executeSilently(session, startupCode, {
traceErrors: true,
Expand Down Expand Up @@ -2655,36 +2655,36 @@ No properties for event

[src/kernels/telemetry/sendKernelTelemetryEvent.ts](https://github.com/microsoft/vscode-jupyter/tree/main/src/kernels/telemetry/sendKernelTelemetryEvent.ts)
```typescript
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function resetData(resource: Resource, eventName: string, properties: any) {
// Once we have successfully interrupted, clear the interrupt counter.
if (eventName === Telemetry.NotebookInterrupt) {
let kv: Pick<IEventNamePropertyMapping, Telemetry.NotebookInterrupt>;
const data: undefined | typeof kv[Telemetry.NotebookInterrupt] = properties;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function resetData(resource: Resource, eventName: string, properties: any) {
// Once we have successfully interrupted, clear the interrupt counter.
if (eventName === Telemetry.NotebookInterrupt) {
let kv: Pick<IEventNamePropertyMapping, Telemetry.NotebookInterrupt>;
const data: undefined | typeof kv[Telemetry.NotebookInterrupt] = properties;
// Check result to determine if success.
```


[src/kernels/telemetry/sendKernelTelemetryEvent.ts](https://github.com/microsoft/vscode-jupyter/tree/main/src/kernels/telemetry/sendKernelTelemetryEvent.ts)
```typescript
function resetData(resource: Resource, eventName: string, properties: any) {
// Once we have successfully interrupted, clear the interrupt counter.
if (eventName === Telemetry.NotebookInterrupt) {
let kv: Pick<IEventNamePropertyMapping, Telemetry.NotebookInterrupt>;
const data: undefined | typeof kv[Telemetry.NotebookInterrupt] = properties;
// Check result to determine if success.
function resetData(resource: Resource, eventName: string, properties: any) {
// Once we have successfully interrupted, clear the interrupt counter.
if (eventName === Telemetry.NotebookInterrupt) {
let kv: Pick<IEventNamePropertyMapping, Telemetry.NotebookInterrupt>;
const data: undefined | typeof kv[Telemetry.NotebookInterrupt] = properties;
// Check result to determine if success.
if (data && 'result' in data && data.result === InterruptResult.Success) {
```


[src/kernels/telemetry/sendKernelTelemetryEvent.ts](https://github.com/microsoft/vscode-jupyter/tree/main/src/kernels/telemetry/sendKernelTelemetryEvent.ts)
```typescript
// Once we have successfully interrupted, clear the interrupt counter.
if (eventName === Telemetry.NotebookInterrupt) {
let kv: Pick<IEventNamePropertyMapping, Telemetry.NotebookInterrupt>;
const data: undefined | typeof kv[Telemetry.NotebookInterrupt] = properties;
// Check result to determine if success.
if (data && 'result' in data && data.result === InterruptResult.Success) {
// Once we have successfully interrupted, clear the interrupt counter.
if (eventName === Telemetry.NotebookInterrupt) {
let kv: Pick<IEventNamePropertyMapping, Telemetry.NotebookInterrupt>;
const data: undefined | typeof kv[Telemetry.NotebookInterrupt] = properties;
// Check result to determine if success.
if (data && 'result' in data && data.result === InterruptResult.Success) {
clearInterruptCounter(resource);
```

Expand Down Expand Up @@ -2736,12 +2736,12 @@ No properties for event

[src/notebooks/telemetry/notebookOrKernelLanguageTelemetry.ts](https://github.com/microsoft/vscode-jupyter/tree/main/src/notebooks/telemetry/notebookOrKernelLanguageTelemetry.ts)
```typescript
import { getTelemetrySafeLanguage } from '../../platform/telemetry/helpers';

export function sendNotebookOrKernelLanguageTelemetry(
telemetryEvent: Telemetry.SwitchToExistingKernel | Telemetry.NotebookLanguage,
language?: string
) {
import { getTelemetrySafeLanguage } from '../../platform/telemetry/helpers';
export function sendNotebookOrKernelLanguageTelemetry(
telemetryEvent: Telemetry.SwitchToExistingKernel | Telemetry.NotebookLanguage,
language?: string
) {
language = getTelemetrySafeLanguage(language);
```

Expand All @@ -2764,41 +2764,41 @@ No properties for event

[src/kernels/telemetry/sendKernelTelemetryEvent.ts](https://github.com/microsoft/vscode-jupyter/tree/main/src/kernels/telemetry/sendKernelTelemetryEvent.ts)
```typescript
}
}
// Once we have successfully restarted, clear the interrupt counter.
if (eventName === Telemetry.NotebookRestart) {
let kv: Pick<IEventNamePropertyMapping, Telemetry.NotebookRestart>;
const data: undefined | typeof kv[Telemetry.NotebookRestart] = properties;
}
}
// Once we have successfully restarted, clear the interrupt counter.
if (eventName === Telemetry.NotebookRestart) {
let kv: Pick<IEventNamePropertyMapping, Telemetry.NotebookRestart>;
const data: undefined | typeof kv[Telemetry.NotebookRestart] = properties;
// For restart to be successful, we should not have `failed`
```


[src/kernels/telemetry/sendKernelTelemetryEvent.ts](https://github.com/microsoft/vscode-jupyter/tree/main/src/kernels/telemetry/sendKernelTelemetryEvent.ts)
```typescript
}
// Once we have successfully restarted, clear the interrupt counter.
if (eventName === Telemetry.NotebookRestart) {
let kv: Pick<IEventNamePropertyMapping, Telemetry.NotebookRestart>;
const data: undefined | typeof kv[Telemetry.NotebookRestart] = properties;
// For restart to be successful, we should not have `failed`
}
// Once we have successfully restarted, clear the interrupt counter.
if (eventName === Telemetry.NotebookRestart) {
let kv: Pick<IEventNamePropertyMapping, Telemetry.NotebookRestart>;
const data: undefined | typeof kv[Telemetry.NotebookRestart] = properties;
// For restart to be successful, we should not have `failed`
const failed = data && 'failed' in data ? data.failed : false;
```


[src/kernels/telemetry/sendKernelTelemetryEvent.ts](https://github.com/microsoft/vscode-jupyter/tree/main/src/kernels/telemetry/sendKernelTelemetryEvent.ts)
```typescript
// Once we have successfully restarted, clear the interrupt counter.
if (eventName === Telemetry.NotebookRestart) {
let kv: Pick<IEventNamePropertyMapping, Telemetry.NotebookRestart>;
const data: undefined | typeof kv[Telemetry.NotebookRestart] = properties;
// For restart to be successful, we should not have `failed`
const failed = data && 'failed' in data ? data.failed : false;
// Once we have successfully restarted, clear the interrupt counter.
if (eventName === Telemetry.NotebookRestart) {
let kv: Pick<IEventNamePropertyMapping, Telemetry.NotebookRestart>;
const data: undefined | typeof kv[Telemetry.NotebookRestart] = properties;
// For restart to be successful, we should not have `failed`
const failed = data && 'failed' in data ? data.failed : false;
if (!failed) {
```


[src/kernels/kernel.base.ts](https://github.com/microsoft/vscode-jupyter/tree/main/src/kernels/kernel.base.ts)
[src/kernels/kernel.ts](https://github.com/microsoft/vscode-jupyter/tree/main/src/kernels/kernel.ts)
```typescript
await (this._jupyterSessionPromise
? this.kernelExecution.restart(this._jupyterSessionPromise)
Expand All @@ -2810,7 +2810,7 @@ No properties for event
```


[src/kernels/kernel.base.ts](https://github.com/microsoft/vscode-jupyter/tree/main/src/kernels/kernel.base.ts)
[src/kernels/kernel.ts](https://github.com/microsoft/vscode-jupyter/tree/main/src/kernels/kernel.ts)
```typescript
this.restarting = undefined;
// If we get a kernel promise failure, then restarting timed out. Just shutdown and restart the entire server.
Expand Down Expand Up @@ -2840,36 +2840,36 @@ No properties for event

[src/kernels/telemetry/sendKernelTelemetryEvent.ts](https://github.com/microsoft/vscode-jupyter/tree/main/src/kernels/telemetry/sendKernelTelemetryEvent.ts)
```typescript

// eslint-disable-next-line @typescript-eslint/no-explicit-any
function incrementStartFailureCount(resource: Resource, eventName: any, properties: any) {
if (eventName === Telemetry.NotebookStart) {
let kv: Pick<IEventNamePropertyMapping, Telemetry.NotebookStart>;
const data: undefined | typeof kv[Telemetry.NotebookStart] = properties;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function incrementStartFailureCount(resource: Resource, eventName: any, properties: any) {
if (eventName === Telemetry.NotebookStart) {
let kv: Pick<IEventNamePropertyMapping, Telemetry.NotebookStart>;
const data: undefined | typeof kv[Telemetry.NotebookStart] = properties;
// Check start failed.
```


[src/kernels/telemetry/sendKernelTelemetryEvent.ts](https://github.com/microsoft/vscode-jupyter/tree/main/src/kernels/telemetry/sendKernelTelemetryEvent.ts)
```typescript
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function incrementStartFailureCount(resource: Resource, eventName: any, properties: any) {
if (eventName === Telemetry.NotebookStart) {
let kv: Pick<IEventNamePropertyMapping, Telemetry.NotebookStart>;
const data: undefined | typeof kv[Telemetry.NotebookStart] = properties;
// Check start failed.
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function incrementStartFailureCount(resource: Resource, eventName: any, properties: any) {
if (eventName === Telemetry.NotebookStart) {
let kv: Pick<IEventNamePropertyMapping, Telemetry.NotebookStart>;
const data: undefined | typeof kv[Telemetry.NotebookStart] = properties;
// Check start failed.
if (data && 'failed' in data && data.failed) {
```


[src/kernels/telemetry/sendKernelTelemetryEvent.ts](https://github.com/microsoft/vscode-jupyter/tree/main/src/kernels/telemetry/sendKernelTelemetryEvent.ts)
```typescript
function incrementStartFailureCount(resource: Resource, eventName: any, properties: any) {
if (eventName === Telemetry.NotebookStart) {
let kv: Pick<IEventNamePropertyMapping, Telemetry.NotebookStart>;
const data: undefined | typeof kv[Telemetry.NotebookStart] = properties;
// Check start failed.
if (data && 'failed' in data && data.failed) {
function incrementStartFailureCount(resource: Resource, eventName: any, properties: any) {
if (eventName === Telemetry.NotebookStart) {
let kv: Pick<IEventNamePropertyMapping, Telemetry.NotebookStart>;
const data: undefined | typeof kv[Telemetry.NotebookStart] = properties;
// Check start failed.
if (data && 'failed' in data && data.failed) {
trackKernelResourceInformation(resource, { startFailed: true });
```

Expand Down Expand Up @@ -4655,7 +4655,7 @@ No description provided

## Locations Used

[src/kernels/kernel.base.ts](https://github.com/microsoft/vscode-jupyter/tree/main/src/kernels/kernel.base.ts)
[src/kernels/kernel.ts](https://github.com/microsoft/vscode-jupyter/tree/main/src/kernels/kernel.ts)
```typescript
await this.executeSilently(session, this.getUserStartupCommands(), {
traceErrors: true,
Expand Down Expand Up @@ -7177,7 +7177,7 @@ No properties for event

## Locations Used

[src/kernels/kernel.base.ts](https://github.com/microsoft/vscode-jupyter/tree/main/src/kernels/kernel.base.ts)
[src/kernels/kernel.ts](https://github.com/microsoft/vscode-jupyter/tree/main/src/kernels/kernel.ts)
```typescript
// Setup telemetry
if (!this.perceivedJupyterStartupTelemetryCaptured) {
Expand All @@ -7189,7 +7189,7 @@ No properties for event
```


[src/kernels/kernel.base.ts](https://github.com/microsoft/vscode-jupyter/tree/main/src/kernels/kernel.base.ts)
[src/kernels/kernel.ts](https://github.com/microsoft/vscode-jupyter/tree/main/src/kernels/kernel.ts)
```typescript

sendKernelTelemetryEvent(
Expand Down Expand Up @@ -8569,7 +8569,7 @@ No properties for event

## Locations Used

[src/kernels/kernel.base.ts](https://github.com/microsoft/vscode-jupyter/tree/main/src/kernels/kernel.base.ts)
[src/kernels/kernel.ts](https://github.com/microsoft/vscode-jupyter/tree/main/src/kernels/kernel.ts)
```typescript
sendTelemetryEvent(Telemetry.PerceivedJupyterStartupNotebook, stopWatch.elapsedTime);
executionPromise
Expand Down Expand Up @@ -8718,12 +8718,12 @@ No description provided

[src/notebooks/telemetry/notebookOrKernelLanguageTelemetry.ts](https://github.com/microsoft/vscode-jupyter/tree/main/src/notebooks/telemetry/notebookOrKernelLanguageTelemetry.ts)
```typescript
import { getTelemetrySafeLanguage } from '../../platform/telemetry/helpers';

export function sendNotebookOrKernelLanguageTelemetry(
telemetryEvent: Telemetry.SwitchToExistingKernel | Telemetry.NotebookLanguage,
language?: string
) {
import { getTelemetrySafeLanguage } from '../../platform/telemetry/helpers';
export function sendNotebookOrKernelLanguageTelemetry(
telemetryEvent: Telemetry.SwitchToExistingKernel | Telemetry.NotebookLanguage,
language?: string
) {
language = getTelemetrySafeLanguage(language);
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { DataScience } from '../../platform/common/utils/localize';
import { Identifiers } from '../../platform/common/constants';
import { Telemetry } from '../../telemetry';
import { JupyterDebuggerNotInstalledError } from '../../kernels/errors/jupyterDebuggerNotInstalledError';
import { getPlainTextOrStreamOutput } from '../../kernels/kernel.base';
import { getPlainTextOrStreamOutput } from '../../kernels/kernel';
import { IKernel, isLocalConnection } from '../../kernels/types';
import { IInteractiveWindowDebugger } from '../types';
import { IFileGeneratedCodes } from '../editor-integration/types';
Expand Down
44 changes: 44 additions & 0 deletions src/interactive-window/debugger/startupCodeProvider.node.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

import { inject, injectable } from 'inversify';
import { getAssociatedNotebookDocument } from '../../kernels/helpers';
import { IKernel, isLocalConnection, IStartupCodeProvider } from '../../kernels/types';
import { InteractiveWindowView } from '../../platform/common/constants';
import { IFileSystem } from '../../platform/common/platform/types';
import { AddRunCellHook } from '../../platform/common/scriptConstants';
import { IConfigurationService, IExtensionContext } from '../../platform/common/types';
import { traceError } from '../../platform/logging';

@injectable()
export class InteractiveWindowDebuggingStartupCodeProvider implements IStartupCodeProvider {
public priority: number = 10;
constructor(
@inject(IConfigurationService) private readonly configService: IConfigurationService,
@inject(IFileSystem) private readonly fs: IFileSystem,
@inject(IExtensionContext) private readonly context: IExtensionContext
) {}

async getCode(kernel: IKernel): Promise<string[]> {
const useNewDebugger = this.configService.getSettings(undefined).forceIPyKernelDebugger === true;
if (useNewDebugger) {
return [];
}
if (!isLocalConnection(kernel.kernelConnectionMetadata)) {
return [];
}
// Only do this for interactive windows. IPYKERNEL_CELL_NAME is set other ways in
// notebooks
if (getAssociatedNotebookDocument(kernel)?.notebookType === InteractiveWindowView) {
// If using ipykernel 6, we need to set the IPYKERNEL_CELL_NAME so that
// debugging can work. However this code is harmless for IPYKERNEL 5 so just always do it
const scriptPath = AddRunCellHook.getScriptPath(this.context);
if (await this.fs.exists(scriptPath)) {
const fileContents = await this.fs.readFile(scriptPath);
return fileContents.splitLines({ trim: false });
}
traceError(`Cannot run non-existent script file: ${scriptPath}`);
}
return [];
}
}
Loading