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

Refactor kernel code into a 'kernels' folder #9313

Merged
merged 13 commits into from
Mar 10, 2022
1 change: 0 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,6 @@ module.exports = {
'src/client/datascience/plotting/plotViewerMessageListener.ts',
'src/client/datascience/plotting/types.ts',
'src/client/datascience/plotting/plotViewerProvider.ts',
'src/client/datascience/commands/commandLineSelector.ts',
'src/client/datascience/notebook/renderer.ts',
'src/client/datascience/notebook/survey.ts',
'src/client/datascience/export/exportToHTML.ts',
Expand Down
1 change: 1 addition & 0 deletions news/3 Code Health/8970.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Refactor kernel related code into a 'kernels' subfolder.
12 changes: 6 additions & 6 deletions src/client/api/kernelApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@

import { injectable, inject } from 'inversify';
import { Disposable, Event, EventEmitter, NotebookDocument } from 'vscode';
import { KernelConnectionWrapper } from '../../kernels/kernelConnectionWrapper';
import {
IKernelProvider,
IKernel,
KernelConnectionMetadata as IKernelKernelConnectionMetadata
} from '../../kernels/types';
import { disposeAllDisposables } from '../common/helpers';
import { traceInfo } from '../common/logger';
import { IDisposable, IDisposableRegistry, IExtensions } from '../common/types';
import { PromiseChain } from '../common/utils/async';
import { Telemetry } from '../datascience/constants';
import { KernelConnectionWrapper } from '../datascience/jupyter/kernels/kernelConnectionWrapper';
import {
IKernel,
IKernelProvider,
KernelConnectionMetadata as IKernelKernelConnectionMetadata
} from '../datascience/jupyter/kernels/types';
import { INotebookControllerManager } from '../datascience/notebook/types';
import { IKernelSocket as ExtensionKernelSocket } from '../datascience/types';
import { sendTelemetryEvent } from '../telemetry';
Expand Down
2 changes: 1 addition & 1 deletion src/client/common/errors/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Licensed under the MIT License.

import { EOL } from 'os';
import { KernelConnectionMetadata } from '../../datascience/jupyter/kernels/types';
import { KernelConnectionMetadata } from '../../../kernels/types';

export abstract class BaseError extends Error {
public stdErr?: string;
Expand Down
4 changes: 2 additions & 2 deletions src/client/common/net/portAttributeProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
import { inject, injectable } from 'inversify';
import { workspace } from 'vscode';
import { CancellationToken, PortAttributes, PortAttributesProvider, PortAutoForwardAction } from 'vscode';
import { NotebookStarter } from '../../../kernels/jupyter/launcher/notebookStarter';
import { KernelLauncher } from '../../../kernels/raw/launcher/kernelLauncher';
import { IExtensionSyncActivationService } from '../../activation/types';
import { NotebookStarter } from '../../datascience/jupyter/notebookStarter';
import { KernelLauncher } from '../../datascience/kernel-launcher/kernelLauncher';
import { traceError } from '../logger';
import { IDisposableRegistry } from '../types';

Expand Down
2 changes: 1 addition & 1 deletion src/client/datascience/activation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ import { debounceAsync, swallowExceptions } from '../common/utils/decorators';
import { sendTelemetryEvent } from '../telemetry';
import { JupyterDaemonModule, Telemetry } from './constants';
import { ActiveEditorContextService } from './commands/activeEditorContext';
import { JupyterInterpreterService } from './jupyter/interpreter/jupyterInterpreterService';
import { INotebookCreationTracker, IRawNotebookSupportedService } from './types';
import { IVSCodeNotebook } from '../common/application/types';
import { NotebookDocument } from 'vscode';
import { isJupyterNotebook } from './notebook/helpers/helpers';
import { JupyterInterpreterService } from '../../kernels/jupyter/interpreter/jupyterInterpreterService';

@injectable()
export class Activation implements IExtensionSingleActivationService {
Expand Down
2 changes: 1 addition & 1 deletion src/client/datascience/commands/activeEditorContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
'use strict';
import { inject, injectable } from 'inversify';
import { NotebookEditor, TextEditor } from 'vscode';
import { IKernel, IKernelProvider } from '../../../kernels/types';
import { IExtensionSingleActivationService } from '../../activation/types';
import { ICommandManager, IDocumentManager, IVSCodeNotebook } from '../../common/application/types';
import { PYTHON_LANGUAGE } from '../../common/constants';
Expand All @@ -12,7 +13,6 @@ import { IDisposable, IDisposableRegistry } from '../../common/types';
import { isNotebookCell, noop } from '../../common/utils/misc';
import { EditorContexts } from '../constants';
import { getActiveInteractiveWindow } from '../interactive-window/helpers';
import { IKernel, IKernelProvider } from '../jupyter/kernels/types';
import { InteractiveWindowView, JupyterNotebookView } from '../notebook/constants';
import { getNotebookMetadata, isJupyterNotebook, isPythonNotebook } from '../notebook/helpers/helpers';
import { INotebookControllerManager } from '../notebook/types';
Expand Down
2 changes: 1 addition & 1 deletion src/client/datascience/commands/commandLineSelector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
'use strict';

import { inject, injectable } from 'inversify';
import { JupyterCommandLineSelector } from '../../../kernels/jupyter/launcher/commandLineSelector';
import { ICommandManager } from '../../common/application/types';
import { IDisposable } from '../../common/types';
import { Commands } from '../constants';
import { JupyterCommandLineSelector } from '../jupyter/commandLineSelector';

@injectable()
export class JupyterCommandLineSelectorCommand implements IDisposable {
Expand Down
6 changes: 3 additions & 3 deletions src/client/datascience/commands/commandRegistry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
import { inject, injectable, multiInject, named, optional } from 'inversify';
import { CodeLens, ConfigurationTarget, env, Range, Uri } from 'vscode';
import { DebugProtocol } from 'vscode-debugprotocol';
import { NotebookCreator } from '../../../kernels/common/notebookCreator';
import { IKernelProvider } from '../../../kernels/types';
import { convertDebugProtocolVariableToIJupyterVariable } from '../../../kernels/variables/debuggerVariables';
import { ICommandNameArgumentTypeMapping } from '../../common/application/commands';
import {
IApplicationShell,
Expand All @@ -29,9 +32,6 @@ import { DataViewerDependencyService } from '../data-viewing/dataViewerDependenc
import { IDataViewerFactory } from '../data-viewing/types';
import { DataViewerChecker } from '../interactive-common/dataViewerChecker';
import { IShowDataViewerFromVariablePanel } from '../interactive-common/interactiveWindowTypes';
import { convertDebugProtocolVariableToIJupyterVariable } from '../jupyter/debuggerVariables';
import { IKernelProvider } from '../jupyter/kernels/types';
import { NotebookCreator } from '../notebook/creation/notebookCreator';
import {
ICodeWatcher,
IDataScienceCodeLensProvider,
Expand Down
2 changes: 1 addition & 1 deletion src/client/datascience/commands/serverSelector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import { inject, injectable } from 'inversify';
import { ICommandManager } from '../../common/application/types';
import { IDisposable } from '../../common/types';
import { Commands } from '../constants';
import { JupyterServerSelector } from '../jupyter/serverSelector';
import { traceInfo } from '../../common/logger';
import { Uri } from 'vscode';
import { JupyterServerSelector } from '../../../kernels/jupyter/serverSelector';

@injectable()
export class JupyterServerSelectorCommand implements IDisposable {
Expand Down
2 changes: 1 addition & 1 deletion src/client/datascience/data-viewing/dataViewer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import {
} from './types';
import { isValidSliceExpression, preselectedSliceExpression } from '../../../datascience-ui/data-explorer/helpers';
import { CheckboxState } from '../../telemetry/constants';
import { IKernel } from '../jupyter/kernels/types';
import { IKernel } from '../../../kernels/types';

const PREFERRED_VIEWGROUP = 'JupyterDataViewerPreferredViewColumn';
const dataExplorerDir = path.join(EXTENSION_ROOT_DIR, 'out', 'datascience-ui', 'viewers');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { IJupyterVariable, IJupyterVariableDataProvider, IJupyterVariables } fro
import { DataViewerDependencyService } from './dataViewerDependencyService';
import { ColumnType, IDataFrameInfo, IRowsResponse } from './types';
import { traceError } from '../../common/logger';
import { IKernel } from '../jupyter/kernels/types';
import { IKernel } from '../../../kernels/types';

@injectable()
export class JupyterVariableDataProvider implements IJupyterVariableDataProvider {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { inject, injectable } from 'inversify';

import { IServiceContainer } from '../../ioc/types';
import { IJupyterVariable, IJupyterVariableDataProvider, IJupyterVariableDataProviderFactory } from '../types';
import { IKernel } from '../jupyter/kernels/types';
import { IKernel } from '../../../kernels/types';

@injectable()
export class JupyterVariableDataProviderFactory implements IJupyterVariableDataProviderFactory {
Expand Down
2 changes: 1 addition & 1 deletion src/client/datascience/data-viewing/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { IDisposable } from '../../common/types';
import { SharedMessages } from '../messages';
import { Event } from 'vscode';
import { SliceOperationSource } from '../../telemetry/constants';
import { IKernel } from '../jupyter/kernels/types';
import { IKernel } from '../../../kernels/types';

export const CellFetchAllLimit = 100000;
export const CellFetchSizeFirst = 100000;
Expand Down
2 changes: 1 addition & 1 deletion src/client/datascience/datascience.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { EditorContexts, Telemetry } from './constants';
import { IDataScience, IDataScienceCodeLensProvider, IRawNotebookSupportedService } from './types';

@injectable()
export class DataScience implements IDataScience {
export class GlobalActivation implements IDataScience {
public isDisposed: boolean = false;
private changeHandler: IDisposable | undefined;
private startTime: number = Date.now();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { IDocumentManager, IDebugService } from '../../common/application/types'
import { IFileSystem } from '../../common/platform/types';
import { IConfigurationService } from '../../common/types';
import { IServiceContainer } from '../../ioc/types';
import { IKernel, IKernelProvider } from '../jupyter/kernels/types';
import { IKernel, IKernelProvider } from '../../../kernels/types';
import { ICellHashListener } from '../types';
import { CellHashProvider } from './cellhashprovider';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import { IConfigurationService } from '../../common/types';
import { getCellResource } from '../cellFactory';
import { CellMatcher } from '../cellMatcher';
import { getInteractiveCellMetadata } from '../interactive-window/interactiveWindow';
import { IKernel } from '../jupyter/kernels/types';
import { IKernel } from '../../../kernels/types';
import { InteractiveWindowView } from '../notebook/constants';
import { ICellHash, ICellHashListener, ICellHashProvider, IFileHashes } from '../types';
import { stripAnsi } from '../../common/utils/regexp';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import * as localize from '../../common/utils/localize';
import { generateCellRangesFromDocument } from '../cellFactory';
import { CodeLensCommands, Commands } from '../constants';
import { getInteractiveCellMetadata } from '../interactive-window/interactiveWindow';
import { IKernelProvider } from '../jupyter/kernels/types';
import { IKernelProvider } from '../../../kernels/types';
import { InteractiveWindowView } from '../notebook/constants';
import { ICellHashProvider, ICellRange, ICodeLensFactory, IFileHashes } from '../types';
import { CellHashProviderFactory } from './cellHashProviderFactory';
Expand Down
2 changes: 1 addition & 1 deletion src/client/datascience/editor-integration/hoverProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { StopWatch } from '../../common/utils/stopWatch';
import { sendTelemetryEvent } from '../../telemetry';
import { Identifiers, Telemetry } from '../constants';
import { getInteractiveCellMetadata } from '../interactive-window/interactiveWindow';
import { IKernel, IKernelProvider } from '../jupyter/kernels/types';
import { IKernel, IKernelProvider } from '../../../kernels/types';
import { InteractiveWindowView } from '../notebook/constants';
import { IInteractiveWindowProvider, IJupyterVariables } from '../types';
@injectable()
Expand Down
6 changes: 3 additions & 3 deletions src/client/datascience/errors/errorHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { Common, DataScience } from '../../common/utils/localize';
import { noop } from '../../common/utils/misc';
import { JupyterInstallError } from './jupyterInstallError';
import { JupyterSelfCertsError } from './jupyterSelfCertsError';
import { getDisplayNameOrNameOfKernelConnection } from '../jupyter/kernels/helpers';
import { getDisplayNameOrNameOfKernelConnection } from '../../../kernels/helpers';
import {
IDataScienceErrorHandler,
IJupyterInterpreterDependencyManager,
Expand All @@ -31,18 +31,18 @@ import {
getErrorMessageFromPythonTraceback,
KernelFailureReason
} from '../../common/errors/errorUtils';
import { KernelConnectionMetadata } from '../jupyter/kernels/types';
import { KernelConnectionMetadata } from '../../../kernels/types';
import { IBrowserService, IConfigurationService, Resource } from '../../common/types';
import { Commands, Telemetry } from '../constants';
import { sendTelemetryEvent } from '../../telemetry';
import { JupyterConnectError } from './jupyterConnectError';
import { JupyterInterpreterDependencyResponse } from '../jupyter/interpreter/jupyterInterpreterDependencyService';
import { DisplayOptions } from '../displayOptions';
import { JupyterKernelDependencyError } from './jupyterKernelDependencyError';
import { EnvironmentType } from '../../pythonEnvironments/info';
import { translateProductToModule } from '../../../kernels/installer/moduleInstaller';
import { ProductNames } from '../../../kernels/installer/productNames';
import { Product } from '../../../kernels/installer/types';
import { JupyterInterpreterDependencyResponse } from '../../../kernels/jupyter/interpreter/jupyterInterpreterDependencyService';

@injectable()
export class DataScienceErrorHandler implements IDataScienceErrorHandler {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import { BaseKernelError } from '../../common/errors/types';
import '../../common/extensions';
import * as localize from '../../common/utils/localize';
import { KernelConnectionMetadata } from '../jupyter/kernels/types';
import { KernelConnectionMetadata } from '../../../kernels/types';

export class JupyterDebuggerNotInstalledError extends BaseKernelError {
constructor(debuggerPkg: string, message: string | undefined, kernelConnectionMetadata: KernelConnectionMetadata) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import { BaseKernelError } from '../../common/errors/types';
import '../../common/extensions';
import * as localize from '../../common/utils/localize';
import { KernelConnectionMetadata } from '../jupyter/kernels/types';
import { KernelConnectionMetadata } from '../../../kernels/types';

export class JupyterDebuggerRemoteNotSupportedError extends BaseKernelError {
constructor(kernelConnectionMetadata: KernelConnectionMetadata) {
Expand Down
4 changes: 2 additions & 2 deletions src/client/datascience/errors/jupyterInvalidKernelError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import { BaseKernelError } from '../../common/errors/types';
import * as localize from '../../common/utils/localize';
import { sendTelemetryEvent } from '../../telemetry';
import { Telemetry } from '../constants';
import { getDisplayNameOrNameOfKernelConnection } from '../jupyter/kernels/helpers';
import { KernelConnectionMetadata } from '../jupyter/kernels/types';
import { getDisplayNameOrNameOfKernelConnection } from '../../../kernels/helpers';
import { KernelConnectionMetadata } from '../../../kernels/types';

export class JupyterInvalidKernelError extends BaseKernelError {
constructor(kernelConnectionMetadata: KernelConnectionMetadata) {
Expand Down
4 changes: 2 additions & 2 deletions src/client/datascience/errors/jupyterKernelDependencyError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import { BaseKernelError } from '../../common/errors/types';
import { DataScience } from '../../common/utils/localize';
import { KernelInterpreterDependencyResponse } from '../types';
import { getDisplayNameOrNameOfKernelConnection } from '../jupyter/kernels/helpers';
import { KernelConnectionMetadata } from '../jupyter/kernels/types';
import { getDisplayNameOrNameOfKernelConnection } from '../../../kernels/helpers';
import { KernelConnectionMetadata } from '../../../kernels/types';

export class JupyterKernelDependencyError extends BaseKernelError {
constructor(
Expand Down
2 changes: 1 addition & 1 deletion src/client/datascience/errors/jupyterWaitForIdleError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { BaseKernelError } from '../../common/errors/types';
import { DataScience } from '../../common/utils/localize';
import { sendTelemetryEvent } from '../../telemetry';
import { Telemetry } from '../constants';
import { KernelConnectionMetadata } from '../jupyter/kernels/types';
import { KernelConnectionMetadata } from '../../../kernels/types';

export class JupyterWaitForIdleError extends BaseKernelError {
constructor(kernelConnectionMetadata: KernelConnectionMetadata) {
Expand Down
4 changes: 2 additions & 2 deletions src/client/datascience/errors/kernelConnectionTimeoutError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

import { BaseKernelError } from '../../common/errors/types';
import { DataScience } from '../../common/utils/localize';
import { getDisplayNameOrNameOfKernelConnection } from '../jupyter/kernels/helpers';
import { KernelConnectionMetadata } from '../jupyter/kernels/types';
import { getDisplayNameOrNameOfKernelConnection } from '../../../kernels/helpers';
import { KernelConnectionMetadata } from '../../../kernels/types';

export class KernelConnectionTimeoutError extends BaseKernelError {
constructor(kernelConnection: KernelConnectionMetadata) {
Expand Down
2 changes: 1 addition & 1 deletion src/client/datascience/errors/kernelDiedError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Licensed under the MIT License.

import { WrappedKernelError } from '../../common/errors/types';
import { KernelConnectionMetadata } from '../jupyter/kernels/types';
import { KernelConnectionMetadata } from '../../../kernels/types';

export class KernelDiedError extends WrappedKernelError {
constructor(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import { BaseKernelError } from '../../common/errors/types';
import { DataScience } from '../../common/utils/localize';
import { KernelConnectionMetadata } from '../jupyter/kernels/types';
import { KernelConnectionMetadata } from '../../../kernels/types';

export class KernelInterruptTimeoutError extends BaseKernelError {
constructor(kernelConnection: KernelConnectionMetadata) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

import { BaseKernelError } from '../../common/errors/types';
import { DataScience } from '../../common/utils/localize';
import { getDisplayNameOrNameOfKernelConnection } from '../jupyter/kernels/helpers';
import { KernelConnectionMetadata } from '../jupyter/kernels/types';
import { getDisplayNameOrNameOfKernelConnection } from '../../../kernels/helpers';
import { KernelConnectionMetadata } from '../../../kernels/types';

export class KernelPortNotUsedTimeoutError extends BaseKernelError {
constructor(kernelConnection: KernelConnectionMetadata) {
Expand Down
2 changes: 1 addition & 1 deletion src/client/datascience/errors/kernelProcessExitedError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import { BaseKernelError } from '../../common/errors/types';
import { DataScience } from '../../common/utils/localize';
import { KernelConnectionMetadata } from '../jupyter/kernels/types';
import { KernelConnectionMetadata } from '../../../kernels/types';

export class KernelProcessExitedError extends BaseKernelError {
constructor(
Expand Down
2 changes: 1 addition & 1 deletion src/client/datascience/export/exportDialog.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { inject, injectable } from 'inversify';
import * as path from 'path';
import { SaveDialogOptions, Uri } from 'vscode';
import { computeWorkingDirectory } from '../../../kernels/jupyter/jupyterUtils';
import { IApplicationShell, IWorkspaceService } from '../../common/application/types';
import * as localize from '../../common/utils/localize';
import { computeWorkingDirectory } from '../jupyter/jupyterUtils';
import { ExportFormat, IExportDialog } from './types';

// File extensions for each export method
Expand Down
2 changes: 1 addition & 1 deletion src/client/datascience/export/exportInterpreterFinder.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { inject, injectable } from 'inversify';
import { JupyterInterpreterService } from '../../../kernels/jupyter/interpreter/jupyterInterpreterService';
import * as localize from '../../common/utils/localize';
import { PythonEnvironment } from '../../pythonEnvironments/info';
import { JupyterInterpreterService } from '../jupyter/interpreter/jupyterInterpreterService';
import { IJupyterInterpreterDependencyManager, INbConvertInterpreterDependencyChecker } from '../types';

@injectable()
Expand Down
2 changes: 1 addition & 1 deletion src/client/datascience/extensionRecommendation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
getKernelConnectionLanguage,
getLanguageInNotebookMetadata,
isPythonKernelConnection
} from './jupyter/kernels/helpers';
} from '../../kernels/helpers';
import { getNotebookMetadata, isJupyterNotebook } from './notebook/helpers/helpers';
import { INotebookControllerManager } from './notebook/types';
import { VSCodeNotebookController } from './notebook/vscodeNotebookController';
Expand Down
Loading