GeezerVison is showing github.com — Add Python: Launch TensorBoard command (#14751) · lavi09/vscode-python@400b193
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboard +1Lines changed: 1 addition & 0 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +Add Python: Launch TensorBoard command behind an experiment. |
Collapse file Copy file name to clipboardExpand all lines: package.json +13Lines changed: 13 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 83 | 83 | "onCommand:python.resetInterpreterSecurityStorage", | 84 | 84 | "onCommand:python.startPage.open", | 85 | 85 | "onCommand:python.enableSourceMapSupport", | | 86 | + "onCommand:python.launchTensorBoard", | 86 | 87 | "workspaceContains:mspythonconfig.json", | 87 | 88 | "workspaceContains:pyproject.toml" | 88 | 89 | ], | | 352 | 353 | "command": "python.analysis.restartLanguageServer", | 353 | 354 | "title": "%python.command.python.analysis.restartLanguageServer.title%", | 354 | 355 | "category": "Python" | | 356 | + }, | | 357 | + { | | 358 | + "command": "python.launchTensorBoard", | | 359 | + "title": "%python.command.python.launchTensorBoard.title%", | | 360 | + "category": "Python" | 355 | 361 | } | 356 | 362 | ], | 357 | 363 | "menus": { | | 486 | 492 | "command": "python.startPage.open", | 487 | 493 | "title": "%python.command.python.startPage.open.title%", | 488 | 494 | "category": "Python" | | 495 | + }, | | 496 | + { | | 497 | + "command": "python.launchTensorBoard", | | 498 | + "category": "Python", | | 499 | + "when": "python.isInNativeTensorBoardExperiment" | 489 | 500 | } | 490 | 501 | ], | 491 | 502 | "view/title": [ | | 1043 | 1054 | "jediLSP", | 1044 | 1055 | "debuggerDataViewer", | 1045 | 1056 | "pythonSendEntireLineToREPL", | | 1057 | + "nativeTensorBoard", | 1046 | 1058 | "All" | 1047 | 1059 | ] | 1048 | 1060 | }, | | 1070 | 1082 | "jediLSP", | 1071 | 1083 | "debuggerDataViewer", | 1072 | 1084 | "pythonSendEntireLineToREPL", | | 1085 | + "nativeTensorBoard", | 1073 | 1086 | "All" | 1074 | 1087 | ] | 1075 | 1088 | }, | |
Collapse file Copy file name to clipboardExpand all lines: package.nls.json +8-1Lines changed: 8 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 36 | 36 | "python.command.python.startPage.open.title": "Open Start Page", | 37 | 37 | "python.command.python.analysis.clearCache.title": "Clear Module Analysis Cache", | 38 | 38 | "python.command.python.analysis.restartLanguageServer.title": "Restart Language Server", | | 39 | + "python.command.python.launchTensorBoard.title": "Launch TensorBoard", | 39 | 40 | "python.snippet.launch.standard.label": "Python: Current File", | 40 | 41 | "python.snippet.launch.module.label": "Python: Module", | 41 | 42 | "python.snippet.launch.module.default": "enter-your-module-name", | | 219 | 220 | "StartPage.openFolder": "Open a Folder or Workspace", | 220 | 221 | "StartPage.folderDesc": "- Open a <div class=\"link\" role=\"button\" onclick={0}>Folder</div><br /> - Open a <div class=\"link\" role=\"button\" onclick={1}>Workspace</div>", | 221 | 222 | "StartPage.badWebPanelFormatString": "<html><body><h1>{0} is not a valid file name</h1></body></html>", | 222 | | - "Jupyter.extensionRequired": "The Jupyter extension is required to perform that task. Click Yes to open the Jupyter extension installation page." | | 223 | + "Jupyter.extensionRequired": "The Jupyter extension is required to perform that task. Click Yes to open the Jupyter extension installation page.", | | 224 | + "TensorBoard.logDirectoryPrompt" : "Please select a log directory to start TensorBoard with.", | | 225 | + "TensorBoard.installPrompt" : "The package TensorBoard is required in order to launch a TensorBoard session. Would you like to install it?", | | 226 | + "TensorBoard.failedToStartSessionError" : "We failed to start a TensorBoard session due to the following error: {0}", | | 227 | + "TensorBoard.progressMessage" : "Starting TensorBoard session...", | | 228 | + "TensorBoard.usingCurrentWorkspaceFolder": "We are using the current workspace folder as the log directory for your TensorBoard session.", | | 229 | + "TensorBoard.selectAFolder": "Select a folder" | 223 | 230 | } |
Collapse file Copy file name to clipboard +26Lines changed: 26 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +import os | | 2 | +import time | | 3 | +import sys | | 4 | +import tensorboard | | 5 | + | | 6 | + | | 7 | +def main(logdir): | | 8 | + tb = tensorboard.program.TensorBoard() | | 9 | + tb.configure(bind_all=False, logdir=logdir) | | 10 | + url = tb.launch() | | 11 | + sys.stdout.write("TensorBoard started at %s\n" % (url)) | | 12 | + sys.stdout.flush() | | 13 | + while True: | | 14 | + try: | | 15 | + time.sleep(60) | | 16 | + except KeyboardInterrupt: | | 17 | + break | | 18 | + sys.stdout.write("TensorBoard is shutting down") | | 19 | + sys.stdout.flush() | | 20 | + | | 21 | + | | 22 | +if __name__ == "__main__": | | 23 | + if len(sys.argv) == 2: | | 24 | + logdir = str(sys.argv[1]) | | 25 | + sys.stdout.write("Starting TensorBoard with logdir %s" % (logdir)) | | 26 | + main(logdir) |
Collapse file Copy file name to clipboardExpand all lines: src/client/common/application/commands.ts +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -51,6 +51,7 @@ interface ICommandNameWithoutArgumentTypeMapping { | 51 | 51 | [Commands.OpenStartPage]: []; | 52 | 52 | [LSCommands.ClearAnalyisCache]: []; | 53 | 53 | [LSCommands.RestartLS]: []; | | 54 | + [Commands.LaunchTensorBoard]: []; | 54 | 55 | } | 55 | 56 |
| 56 | 57 | /** | |
Collapse file Copy file name to clipboardExpand all lines: src/client/common/constants.ts +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -70,6 +70,7 @@ export namespace Commands { | 70 | 70 | export const ClearWorkspaceInterpreter = 'python.clearWorkspaceInterpreter'; | 71 | 71 | export const ResetInterpreterSecurityStorage = 'python.resetInterpreterSecurityStorage'; | 72 | 72 | export const OpenStartPage = 'python.startPage.open'; | | 73 | + export const LaunchTensorBoard = 'python.launchTensorBoard'; | 73 | 74 | } | 74 | 75 | export namespace Octicons { | 75 | 76 | export const Test_Pass = '$(check)'; | |
Collapse file Copy file name to clipboardExpand all lines: src/client/common/experiments/groups.ts +5Lines changed: 5 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -83,6 +83,11 @@ export enum SendSelectionToREPL { | 83 | 83 | experiment = 'pythonSendEntireLineToREPL' | 84 | 84 | } | 85 | 85 |
| | 86 | +// Feature flag for 'Python: Launch TensorBoard' feature | | 87 | +export enum NativeTensorBoard { | | 88 | + experiment = 'nativeTensorBoard' | | 89 | +} | | 90 | + | 86 | 91 | // Experiment to show a prompt asking users to install or select linter | 87 | 92 | export enum LinterInstallationPromptVariants { | 88 | 93 | pylintFirst = 'pythonInstallPylintButtonFirst', | |
Collapse file Copy file name to clipboardExpand all lines: src/client/common/installer/productInstaller.ts +2Lines changed: 2 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -679,6 +679,8 @@ function translateProductToModule(product: Product, purpose: ModuleNamePurpose): | 679 | 679 | return 'nbconvert'; | 680 | 680 | case Product.kernelspec: | 681 | 681 | return 'kernelspec'; | | 682 | + case Product.tensorboard: | | 683 | + return 'tensorboard'; | 682 | 684 | default: { | 683 | 685 | throw new Error(`Product ${product} cannot be installed as a Python Module.`); | 684 | 686 | } | |
Collapse file Copy file name to clipboardExpand all lines: src/client/common/installer/productNames.ts +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -19,3 +19,4 @@ ProductNames.set(Product.pylint, 'pylint'); | 19 | 19 | ProductNames.set(Product.pytest, 'pytest'); | 20 | 20 | ProductNames.set(Product.yapf, 'yapf'); | 21 | 21 | ProductNames.set(Product.rope, 'rope'); | | 22 | +ProductNames.set(Product.tensorboard, 'tensorboard'); |
Collapse file Copy file name to clipboardExpand all lines: src/client/common/installer/productService.ts +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -34,6 +34,7 @@ export class ProductService implements IProductService { | 34 | 34 | this.ProductTypes.set(Product.nbconvert, ProductType.DataScience); | 35 | 35 | this.ProductTypes.set(Product.kernelspec, ProductType.DataScience); | 36 | 36 | this.ProductTypes.set(Product.pandas, ProductType.DataScience); | | 37 | + this.ProductTypes.set(Product.tensorboard, ProductType.DataScience); | 37 | 38 | } | 38 | 39 | public getProductType(product: Product): ProductType { | 39 | 40 | return this.ProductTypes.get(product)!; | |
|