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

Remove kernel status #14698

Merged
merged 2 commits into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions src/api.proposed.kernelApi.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,7 @@
import type { Event, Uri } from 'vscode';

declare module './api' {
export interface Kernel {
status: 'unknown' | 'starting' | 'idle' | 'busy' | 'terminating' | 'restarting' | 'autorestarting' | 'dead';
onDidChangeStatus: Event<
'unknown' | 'starting' | 'idle' | 'busy' | 'terminating' | 'restarting' | 'autorestarting' | 'dead'
>;
}
export interface Kernel {}
export interface Kernels {
/**
* Finds a kernel for a given resource.
Expand Down
40 changes: 16 additions & 24 deletions src/kernels/api/api.vscode.common.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,7 @@ import { assert } from 'chai';
import { CancellationTokenSource, NotebookCellOutputItem, NotebookDocument } from 'vscode';
import { traceInfo } from '../../platform/logging';
import { IDisposable } from '../../platform/common/types';
import {
captureScreenShot,
createEventHandler,
initialize,
startJupyterServer,
suiteMandatory,
testMandatory,
waitForCondition
} from '../../test/common';
import { captureScreenShot, initialize, startJupyterServer, suiteMandatory, testMandatory } from '../../test/common';
import {
closeNotebooksAndCleanUpAfterTests,
createEmptyPythonNotebook,
Expand Down Expand Up @@ -94,23 +86,23 @@ suiteMandatory('Kernel API Tests @python', function () {
if (!kernel) {
throw new Error('Kernel not found');
}
const statusChange = createEventHandler(kernel, 'onDidChangeStatus', disposables);
// const statusChange = createEventHandler(kernel, 'onDidChangeStatus', disposables);

// Verify we can execute code using the kernel.
traceInfo(`Execute code silently`);
const expectedMime = NotebookCellOutputItem.stdout('').mime;
const token = new CancellationTokenSource();
await waitForOutput(kernel.executeCode('print(1234)', token.token), '1234', expectedMime);
traceInfo(`Execute code silently completed`);
// Wait for kernel to be idle.
await waitForCondition(
() => kernel.status === 'idle',
5_000,
`Kernel did not become idle, current status is ${kernel.status}`
);
// // Wait for kernel to be idle.
// await waitForCondition(
// () => kernel.status === 'idle',
// 5_000,
// `Kernel did not become idle, current status is ${kernel.status}`
// );

// Verify state transition.
assert.deepEqual(Array.from(new Set(statusChange.all)), ['busy', 'idle'], 'States are incorrect');
// // Verify state transition.
// assert.deepEqual(Array.from(new Set(statusChange.all)), ['busy', 'idle'], 'States are incorrect');

// Verify we can execute code using the kernel in parallel.
await Promise.all([
Expand All @@ -119,12 +111,12 @@ suiteMandatory('Kernel API Tests @python', function () {
waitForOutput(kernel.executeCode('print(3)', token.token), '3', expectedMime)
]);

// Wait for kernel to be idle.
await waitForCondition(
() => kernel.status === 'idle',
5_000,
`Kernel did not become idle, current status is ${kernel.status}`
);
// // Wait for kernel to be idle.
// await waitForCondition(
// () => kernel.status === 'idle',
// 5_000,
// `Kernel did not become idle, current status is ${kernel.status}`
// );
});

async function waitForOutput(executionResult: ExecutionResult, expectedOutput: string, expectedMimetype: string) {
Expand Down
4 changes: 2 additions & 2 deletions src/kernels/api/kernel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,13 @@ class KernelExecutionProgressIndicator {
*/
class WrappedKernelPerExtension implements Kernel {
get status(): 'unknown' | 'starting' | 'idle' | 'busy' | 'terminating' | 'restarting' | 'autorestarting' | 'dead' {
sendApiTelemetry(this.extensionId, this.kernel, 'status', this.execution.executionCount).catch(noop);
// sendApiTelemetry(this.extensionId, this.kernel, 'status', this.execution.executionCount).catch(noop);
return this.kernel.status;
}
get onDidChangeStatus(): Event<
'unknown' | 'starting' | 'idle' | 'busy' | 'terminating' | 'restarting' | 'autorestarting' | 'dead'
> {
sendApiTelemetry(this.extensionId, this.kernel, 'onDidChangeStatus', this.execution.executionCount).catch(noop);
// sendApiTelemetry(this.extensionId, this.kernel, 'onDidChangeStatus', this.execution.executionCount).catch(noop);
return this.kernel.onStatusChanged;
}

Expand Down
Loading