Skip to content

Commit 97b1c7a

Browse files
authored
Allow for changing the jupyter command line that we use (microsoft#10062)
* Add support for changing the default command line for Jupyter * Switch command line to an array Make the default 'recommended' * Make sure default works too * Linter problems
1 parent 2a7484b commit 97b1c7a

28 files changed

Lines changed: 298 additions & 19 deletions

news/1 Enhancements/8698.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Allow user to override the arguments passed to Jupyter on startup. To change the arguments, run the 'Python: Specify Jupyter command line arguments" command.

package-lock.json

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@
8282
"onCommand:python.datascience.exportfileasnotebook",
8383
"onCommand:python.datascience.exportfileandoutputasnotebook",
8484
"onCommand:python.datascience.selectJupyterInterpreter",
85+
"onCommand:python.datascience.selectjupytercommandline",
8586
"onCommand:python.enableSourceMapSupport"
8687
],
8788
"main": "./out/client/extension",
@@ -457,6 +458,12 @@
457458
"category": "Python",
458459
"when": "python.datascience.featureenabled"
459460
},
461+
{
462+
"command": "python.datascience.selectjupytercommandline",
463+
"title": "%python.command.python.datascience.selectjupytercommandline.title%",
464+
"category": "Python",
465+
"when": "python.datascience.featureenabled"
466+
},
460467
{
461468
"command": "python.datascience.importnotebook",
462469
"title": "%python.command.python.datascience.importnotebook.title%",
@@ -1649,6 +1656,12 @@
16491656
"description": "When a Notebook Editor or Interactive Window session is started, create the kernel on the specified Jupyter server. Select 'local' to create a new Jupyter server on this local machine.",
16501657
"scope": "resource"
16511658
},
1659+
"python.dataScience.jupyterCommandLineArguments": {
1660+
"type": "array",
1661+
"default": [],
1662+
"description": "When a Notebook Editor or Interactive Window Jupyter server is started, these arguments will be passed to it. By default this list is generated by the Python Extension.",
1663+
"scope": "resource"
1664+
},
16521665
"python.dataScience.notebookFileRoot": {
16531666
"type": "string",
16541667
"default": "${fileDirname}",
@@ -2884,6 +2897,7 @@
28842897
"rxjs": "^5.5.9",
28852898
"semver": "^5.5.0",
28862899
"stack-trace": "0.0.10",
2900+
"string-argv": "^0.3.1",
28872901
"strip-ansi": "^5.2.0",
28882902
"sudo-prompt": "^8.2.0",
28892903
"svg-to-pdfkit": "^0.1.7",

package.nls.json

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
"python.command.python.datascience.runcell.title": "Run Cell",
5353
"python.command.python.datascience.showhistorypane.title": "Show Python Interactive Window",
5454
"python.command.python.datascience.selectjupyteruri.title": "Specify local or remote Jupyter server for connections",
55+
"python.command.python.datascience.selectjupytercommandline.title": "Specify Jupyter command line arguments",
5556
"python.command.python.datascience.importnotebook.title": "Import Jupyter Notebook",
5657
"python.command.python.datascience.opennotebook.title": "Open in Notebook Editor",
5758
"python.command.python.datascience.importnotebookfile.title": "Convert to Python Script",
@@ -242,7 +243,16 @@
242243
"DataScience.pythonInterruptFailedHeader": "Keyboard interrupt crashed the kernel. Kernel restarted.",
243244
"DataScience.sysInfoURILabel": "Jupyter Server URI: ",
244245
"DataScience.jupyterStartTimedout": "Starting Jupyter has timedout. Please check the 'Jupyter' output panel for further details.",
245-
"DataScience.startingJupyterLogMessage": "Starting Jupyter from {0}",
246+
"DataScience.startingJupyterLogMessage": "Starting Jupyter from {0} with command line {1}",
247+
"DataScience.jupyterCommandLineDefaultLabel": "Default (recommended)",
248+
"DataScience.jupyterCommandLineDefaultDetail": "The Python extension will determine the appropriate command line for Jupyter",
249+
"DataScience.jupyterCommandLineCustomLabel": "Custom",
250+
"DataScience.jupyterCommandLineCustomDetail": "Customize the command line passed to Jupyter on startup",
251+
"DataScience.jupyterCommandLineReloadQuestion": "Please reload the window when changing the Jupyter command line.",
252+
"DataScience.jupyterCommandLineReloadAnswer": "Reload",
253+
"DataScience.jupyterCommandLineQuickPickPlaceholder": "Choose an option",
254+
"DataScience.jupyterCommandLineQuickPickTitle": "Pick command line for Jupyter",
255+
"DataScience.jupyterCommandLinePrompt": "Enter your custom command line for Jupyter",
246256
"Common.loadingPythonExtension": "Python extension loading...",
247257
"debug.selectConfigurationTitle": "Select a debug configuration",
248258
"debug.selectConfigurationPlaceholder": "Debug Configuration",
@@ -432,4 +442,4 @@
432442
"DataScience.gettingListOfKernelSpecs": "Fetching Kernel specs",
433443
"DataScience.startingJupyterNotebook": "Starting Jupyter Notebook",
434444
"DataScience.registeringKernel": "Registering Kernel"
435-
}
445+
}

src/client/common/application/commands.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ interface ICommandNameWithoutArgumentTypeMapping {
5151
[DSCommands.RunCurrentCellAdvance]: [];
5252
[DSCommands.ExecSelectionInInteractiveWindow]: [];
5353
[DSCommands.SelectJupyterURI]: [];
54+
[DSCommands.SelectJupyterCommandLine]: [];
5455
[DSCommands.ShowHistoryPane]: [];
5556
[DSCommands.UndoCells]: [];
5657
[DSCommands.RedoCells]: [];

src/client/common/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,7 @@ export interface IDataScienceSettings {
390390
useWebViewServer?: boolean;
391391
variableQueries: IVariableQuery[];
392392
disableJupyterAutoStart?: boolean;
393+
jupyterCommandLineArguments: string[];
393394
}
394395

395396
export const IConfigurationService = Symbol('IConfigurationService');

src/client/common/utils/localize.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -759,6 +759,33 @@ export namespace DataScience {
759759
export const gettingListOfKernelSpecs = localize('DataScience.gettingListOfKernelSpecs', 'Fetching Kernel specs');
760760
export const startingJupyterNotebook = localize('DataScience.startingJupyterNotebook', 'Starting Jupyter Notebook');
761761
export const registeringKernel = localize('DataScience.registeringKernel', 'Registering Kernel');
762+
export const jupyterCommandLineDefaultLabel = localize('DataScience.jupyterCommandLineDefaultLabel', 'Default');
763+
export const jupyterCommandLineDefaultDetail = localize(
764+
'DataScience.jupyterCommandLineDefaultDetail',
765+
'The Python extension will determine the appropriate command line for Jupyter'
766+
);
767+
export const jupyterCommandLineCustomLabel = localize('DataScience.jupyterCommandLineCustomLabel', 'Custom');
768+
export const jupyterCommandLineCustomDetail = localize(
769+
'DataScience.jupyterCommandLineCustomDetail',
770+
'Customize the command line passed to Jupyter on startup'
771+
);
772+
export const jupyterCommandLineReloadQuestion = localize(
773+
'DataScience.jupyterCommandLineReloadQuestion',
774+
'Please reload the window when changing the Jupyter command line.'
775+
);
776+
export const jupyterCommandLineReloadAnswer = localize('DataScience.jupyterCommandLineReloadAnswer', 'Reload');
777+
export const jupyterCommandLineQuickPickPlaceholder = localize(
778+
'DataScience.jupyterCommandLineQuickPickPlaceholder',
779+
'Choose an option'
780+
);
781+
export const jupyterCommandLineQuickPickTitle = localize(
782+
'DataScience.jupyterCommandLineQuickPickTitle',
783+
'Pick command line for Jupyter'
784+
);
785+
export const jupyterCommandLinePrompt = localize(
786+
'DataScience.jupyterCommandLinePrompt',
787+
'Enter your custom command line for Jupyter'
788+
);
762789
}
763790

764791
export namespace DebugConfigStrings {
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
4+
'use strict';
5+
6+
import { inject, injectable } from 'inversify';
7+
import { ICommandManager } from '../../common/application/types';
8+
import { IDisposable } from '../../common/types';
9+
import { Commands } from '../constants';
10+
import { JupyterCommandLineSelector } from '../jupyter/commandLineSelector';
11+
12+
@injectable()
13+
export class JupyterCommandLineSelectorCommand implements IDisposable {
14+
private readonly disposables: IDisposable[] = [];
15+
constructor(
16+
@inject(ICommandManager) private readonly commandManager: ICommandManager,
17+
@inject(JupyterCommandLineSelector) private readonly commandSelector: JupyterCommandLineSelector
18+
) {}
19+
public register() {
20+
this.disposables.push(
21+
this.commandManager.registerCommand(
22+
Commands.SelectJupyterCommandLine,
23+
this.commandSelector.selectJupyterCommandLine,
24+
this.commandSelector
25+
)
26+
);
27+
}
28+
public dispose() {
29+
this.disposables.forEach(d => d.dispose());
30+
}
31+
}

src/client/datascience/commands/commandRegistry.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {
1717
IDataScienceCommandListener,
1818
INotebookEditorProvider
1919
} from '../types';
20+
import { JupyterCommandLineSelectorCommand } from './commandLineSelector';
2021
import { KernelSwitcherCommand } from './kernelSwitcher';
2122
import { JupyterServerSelectorCommand } from './serverSelector';
2223

@@ -32,6 +33,8 @@ export class CommandRegistry implements IDisposable {
3233
@inject(ICommandManager) private readonly commandManager: ICommandManager,
3334
@inject(JupyterServerSelectorCommand) private readonly serverSelectedCommand: JupyterServerSelectorCommand,
3435
@inject(KernelSwitcherCommand) private readonly kernelSwitcherCommand: KernelSwitcherCommand,
36+
@inject(JupyterCommandLineSelectorCommand)
37+
private readonly commandLineCommand: JupyterCommandLineSelectorCommand,
3538
@inject(IPythonExtensionBanner)
3639
@named(BANNER_NAME_DS_SURVEY)
3740
private readonly dataScienceSurveyBanner: IPythonExtensionBanner,
@@ -43,6 +46,7 @@ export class CommandRegistry implements IDisposable {
4346
this.disposables.push(this.kernelSwitcherCommand);
4447
}
4548
public register() {
49+
this.commandLineCommand.register();
4650
this.serverSelectedCommand.register();
4751
this.kernelSwitcherCommand.register();
4852
this.registerCommand(Commands.RunAllCells, this.runAllCells);

src/client/datascience/constants.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export namespace Commands {
3131
export const ImportNotebookFile = 'python.datascience.importnotebookfile';
3232
export const OpenNotebook = 'python.datascience.opennotebook';
3333
export const SelectJupyterURI = 'python.datascience.selectjupyteruri';
34+
export const SelectJupyterCommandLine = 'python.datascience.selectjupytercommandline';
3435
export const ExportFileAsNotebook = 'python.datascience.exportfileasnotebook';
3536
export const ExportFileAndOutputAsNotebook = 'python.datascience.exportfileandoutputasnotebook';
3637
export const UndoCells = 'python.datascience.undocells';
@@ -244,7 +245,8 @@ export enum Telemetry {
244245
OpenedInteractiveWindow = 'DATASCIENCE.OPENED_INTERACTIVE',
245246
FindKernelForLocalConnection = 'DS_INTERNAL.FIND_KERNEL_FOR_LOCAL_CONNECTION',
246247
CompletionTimeFromLS = 'DS_INTERNAL.COMPLETION_TIME_FROM_LS',
247-
CompletionTimeFromJupyter = 'DS_INTERNAL.COMPLETION_TIME_FROM_JUPYTER'
248+
CompletionTimeFromJupyter = 'DS_INTERNAL.COMPLETION_TIME_FROM_JUPYTER',
249+
JupyterCommandLineNonDefault = 'DS_INTERNAL.JUPYTER_CUSTOM_COMMAND_LINE'
248250
}
249251

250252
export enum NativeKeyboardCommandTelemetry {

0 commit comments

Comments
 (0)