Skip to content

Commit 94abff9

Browse files
authored
Preliminary support for editing notebooks (microsoft#7222)
* Create a native editor * Fixup after npm install * Fixup merge * Linter fix * Add news entry * Fixup news merge mishap * More merge mistakes * Merge fixup * Remove comment * Change autoNotebookEditor to useNotebookEditor * Put telemtry for creating new notebooks * More merge problems * Review feedback * Attempt to fix stalls * Fix scrolling * Review feedback * Fix build error * Fix linter problem * Put back tempspec creation to get unit tests to pass on linux/darwin
1 parent 19546f4 commit 94abff9

172 files changed

Lines changed: 11797 additions & 7113 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎news/1 Enhancements/5959.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Experimental version of a native editor for ipynb files.

‎package-lock.json‎

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

‎package.datascience-ui.dependencies.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
"@nteract/styled-blueprintjsx",
3434
"create-react-context",
3535
"dom4",
36+
"fast-deep-equal",
3637
"gud",
3738
"popper.js",
3839
"react-is",

‎package.json‎

Lines changed: 99 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@
7171
"onCommand:python.configureTests",
7272
"onCommand:python.datascience.showhistorypane",
7373
"onCommand:python.datascience.importnotebook",
74+
"onCommand:python.datascience.importnotebookfile",
75+
"onCommand:python.datascience.opennotebook",
7476
"onCommand:python.datascience.selectjupyteruri",
7577
"onCommand:python.datascience.exportfileasnotebook",
7678
"onCommand:python.datascience.exportfileandoutputasnotebook",
@@ -452,6 +454,16 @@
452454
"title": "%python.command.python.datascience.importnotebook.title%",
453455
"category": "Python"
454456
},
457+
{
458+
"command": "python.datascience.importnotebookfile",
459+
"title": "%python.command.python.datascience.importnotebookfile.title%",
460+
"category": "Python"
461+
},
462+
{
463+
"command": "python.datascience.opennotebook",
464+
"title": "%python.command.python.datascience.opennotebook.title%",
465+
"category": "Python"
466+
},
455467
{
456468
"command": "python.datascience.exportoutputasnotebook",
457469
"title": "%python.command.python.datascience.exportoutputasnotebook.title%",
@@ -477,6 +489,16 @@
477489
"title": "%python.command.python.datascience.redocells.title%",
478490
"category": "Python"
479491
},
492+
{
493+
"command": "python.datascience.notebookeditor.undocells",
494+
"title": "%python.command.python.datascience.undocells.title%",
495+
"category": "Python"
496+
},
497+
{
498+
"command": "python.datascience.notebookeditor.redocells",
499+
"title": "%python.command.python.datascience.redocells.title%",
500+
"category": "Python"
501+
},
480502
{
481503
"command": "python.datascience.removeallcells",
482504
"title": "%python.command.python.datascience.removeallcells.title%",
@@ -492,6 +514,21 @@
492514
"title": "%python.command.python.datascience.restartkernel.title%",
493515
"category": "Python"
494516
},
517+
{
518+
"command": "python.datascience.notebookeditor.removeallcells",
519+
"title": "%python.command.python.datascience.removeallcells.title%",
520+
"category": "Python"
521+
},
522+
{
523+
"command": "python.datascience.notebookeditor.interruptkernel",
524+
"title": "%python.command.python.datascience.interruptkernel.title%",
525+
"category": "Python"
526+
},
527+
{
528+
"command": "python.datascience.notebookeditor.restartkernel",
529+
"title": "%python.command.python.datascience.restartkernel.title%",
530+
"category": "Python"
531+
},
495532
{
496533
"command": "python.datascience.expandallcells",
497534
"title": "%python.command.python.datascience.expandallcells.title%",
@@ -507,6 +544,11 @@
507544
"title": "%python.command.python.datascience.addcellbelow.title%",
508545
"category": "Python"
509546
},
547+
{
548+
"command": "python.datascience.createnewnotebook",
549+
"title": "%python.command.python.datascience.createnewnotebook.title%",
550+
"category": "Python"
551+
},
510552
{
511553
"command": "python.datascience.scrolltocell",
512554
"title": "%python.command.python.datascience.scrolltocell.title%",
@@ -641,7 +683,12 @@
641683
},
642684
{
643685
"when": "resourceLangId == jupyter",
644-
"command": "python.datascience.importnotebook",
686+
"command": "python.datascience.opennotebook",
687+
"group": "Python"
688+
},
689+
{
690+
"when": "resourceLangId == jupyter",
691+
"command": "python.datascience.importnotebookfile",
645692
"group": "Python"
646693
}
647694
],
@@ -756,6 +803,11 @@
756803
"title": "%python.command.python.datascience.importnotebook.title%",
757804
"category": "Python"
758805
},
806+
{
807+
"command": "python.datascience.opennotebook",
808+
"title": "%python.command.python.datascience.opennotebook.title%",
809+
"category": "Python"
810+
},
759811
{
760812
"command": "python.datascience.exportfileasnotebook",
761813
"title": "%python.command.python.datascience.exportfileasnotebook.title%",
@@ -798,6 +850,36 @@
798850
"category": "Python",
799851
"when": "python.datascience.haveinteractive && python.datascience.featureenabled"
800852
},
853+
{
854+
"command": "python.datascience.notebookeditor.undocells",
855+
"title": "%python.command.python.datascience.undocells.title%",
856+
"category": "Python",
857+
"when": "python.datascience.haveinteractivecells && python.datascience.featureenabled"
858+
},
859+
{
860+
"command": "python.datascience.notebookeditor.redocells",
861+
"title": "%python.command.python.datascience.redocells.title%",
862+
"category": "Python",
863+
"when": "python.datascience.havenativeredoablecells && python.datascience.featureenabled"
864+
},
865+
{
866+
"command": "python.datascience.notebookeditor.removeallcells",
867+
"title": "%python.command.python.datascience.removeallcells.title%",
868+
"category": "Python",
869+
"when": "python.datascience.havenativecells && python.datascience.featureenabled"
870+
},
871+
{
872+
"command": "python.datascience.notebookeditor.interruptkernel",
873+
"title": "%python.command.python.datascience.interruptkernel.title%",
874+
"category": "Python",
875+
"when": "python.datascience.havenative && python.datascience.featureenabled"
876+
},
877+
{
878+
"command": "python.datascience.notebookeditor.restartkernel",
879+
"title": "%python.command.python.datascience.restartkernel.title%",
880+
"category": "Python",
881+
"when": "python.datascience.havenative && python.datascience.featureenabled"
882+
},
801883
{
802884
"command": "python.datascience.expandallcells",
803885
"title": "%python.command.python.datascience.expandallcells.title%",
@@ -831,6 +913,12 @@
831913
"title": "%python.command.python.datascience.addcellbelow.title%",
832914
"category": "Python",
833915
"when": "python.datascience.featureenabled"
916+
},
917+
{
918+
"command": "python.datascience.createnewnotebook",
919+
"title": "%python.command.python.datascience.createnewnotebook.title%",
920+
"category": "Python",
921+
"when": "python.datascience.featureenabled"
834922
}
835923
],
836924
"view/title": [
@@ -1518,10 +1606,17 @@
15181606
},
15191607
"python.dataScience.autoPreviewNotebooksInInteractivePane": {
15201608
"type": "boolean",
1609+
"deprecationMessage": "No longer supported. Notebooks open directly in their own editor now.",
15211610
"default": false,
15221611
"description": "When opening ipynb files, automatically preview the contents in the Python Interactive window.",
15231612
"scope": "resource"
15241613
},
1614+
"python.dataScience.useNotebookEditor": {
1615+
"type": "boolean",
1616+
"default": false,
1617+
"description": "Automatically open .ipynb files in the Notebook Editor.",
1618+
"scope": "resource"
1619+
},
15251620
"python.dataScience.allowUnauthorizedRemoteConnection": {
15261621
"type": "boolean",
15271622
"default": false,
@@ -2496,6 +2591,7 @@
24962591
"arch": "^2.1.0",
24972592
"azure-storage": "^2.10.3",
24982593
"diff-match-patch": "^1.0.0",
2594+
"fast-deep-equal": "^2.0.1",
24992595
"fs-extra": "^4.0.3",
25002596
"fuzzy": "^0.1.3",
25012597
"get-port": "^3.2.0",
@@ -2509,6 +2605,7 @@
25092605
"line-by-line": "^0.1.6",
25102606
"lodash": "^4.17.15",
25112607
"md5": "^2.2.1",
2608+
"memoize-one": "^5.1.1",
25122609
"minimatch": "^3.0.4",
25132610
"monaco-editor-textmate": "^2.1.1",
25142611
"monaco-textmate": "^3.0.0",
@@ -2587,6 +2684,7 @@
25872684
"@types/loader-utils": "^1.1.3",
25882685
"@types/lodash": "^4.14.104",
25892686
"@types/md5": "^2.1.32",
2687+
"@types/memoize-one": "^4.1.1",
25902688
"@types/mocha": "^5.2.7",
25912689
"@types/nock": "^10.0.3",
25922690
"@types/node": "9.4.7",

‎package.nls.json‎

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@
5151
"python.command.python.datascience.showhistorypane.title": "Show Python Interactive Window",
5252
"python.command.python.datascience.selectjupyteruri.title": "Specify Jupyter Server URI",
5353
"python.command.python.datascience.importnotebook.title": "Import Jupyter Notebook",
54-
"python.command.python.datascience.importnotebookonfile.title": "Import Jupyter Notebook",
54+
"python.command.python.datascience.opennotebook.title": "Open in Notebook Editor",
55+
"python.command.python.datascience.importnotebookfile.title": "Convert to Python Script",
5556
"python.command.python.enableSourceMapSupport.title": "Enable Source Map Support For Extension Debugging",
5657
"python.command.python.datascience.exportoutputasnotebook.title": "Export Python Interactive Window as Jupyter Notebook",
5758
"python.command.python.datascience.exportfileasnotebook.title": "Export Current Python File as Jupyter Notebook",
@@ -65,6 +66,7 @@
6566
"python.command.python.datascience.collapseallcells.title": "Collapse All Python Interactive Cells",
6667
"python.command.python.datascience.addcellbelow.title": "Add Empty Cell to File",
6768
"python.command.python.datascience.scrolltocell.title": "Scroll Cell Into View",
69+
"python.command.python.datascience.createnewnotebook.title": "Create New Blank Jupyter Notebook",
6870
"python.snippet.launch.standard.label": "Python: Current File",
6971
"python.snippet.launch.module.label": "Python: Module",
7072
"python.snippet.launch.module.default": "enter-your-module-name",
@@ -89,6 +91,7 @@
8991
"DataScience.exportDialogComplete": "Notebook written to {0}",
9092
"DataScience.exportDialogFailed": "Failed to export notebook. {0}",
9193
"DataScience.exportOpenQuestion": "Open in browser",
94+
"DataScience.exportOpenQuestion1": "Open in editor",
9295
"DataScience.collapseInputTooltip": "Collapse input block",
9396
"DataScience.collapseVariableExplorerTooltip": "Collapse variable explorer",
9497
"DataScience.collapseVariableExplorerLabel": "Variables",
@@ -164,6 +167,7 @@
164167
"DataScience.deleteButtonTooltip": "Remove cell",
165168
"DataScience.gotoCodeButtonTooltip": "Go to code",
166169
"DataScience.copyBackToSourceButtonTooltip": "Paste code into file",
170+
"DataScience.copyToClipboardButtonTooltip": "Copy source to clipboard",
167171
"DataScience.plotOpen": "Expand image",
168172
"Linter.enableLinter": "Enable {0}",
169173
"Linter.enablePylint": "You have a pylintrc file in your workspace. Do you want to enable pylint?",
@@ -332,5 +336,21 @@
332336
"DataScience.cellStopOnErrorFormatMessage": "{0} cells were canceled due to an error in the previous cell.",
333337
"DataScience.instructionComments": "# To add a new cell, type '#%%'\n# To add a new markdown cell, type '#%% [markdown]'\n",
334338
"DataScience.scrollToCellTitleFormatMessage": "Go to [{0}]",
335-
"DataScience.remoteDebuggerNotSupported": "Debugging while attached to a remote server is not currently supported."
339+
"DataScience.remoteDebuggerNotSupported": "Debugging while attached to a remote server is not currently supported.",
340+
"DataScience.save" : "Save file",
341+
"DataScience.invalidNotebookFileError" : "{0} is not a valid notebook file. Check the file for correct json.",
342+
"DataScience.nativeEditorTitle" : "Notebook Editor",
343+
"DataScience.untitledNotebookFileName" : "Untitled",
344+
"DataScience.untitledNotebookMessage" : "Your changes will be lost if you don't save them.",
345+
"DataScience.untitledNotebookYes" : "Save",
346+
"DataScience.untitledNotebookNo" : "Cancel",
347+
"DataScience.dirtyNotebookDialogTitle" : "Save",
348+
"DataScience.dirtyNotebookDialogFilter" : "Jupyter Notebooks",
349+
"DataScience.exportAsPythonFileTooltip" : "Convert to a python script",
350+
"DataScience.exportAsPythonFileTitle" : "Convert",
351+
"DataScience.runCell" : "Run cell",
352+
"DataScience.deleteCell" : "Move selected cell down",
353+
"DataScience.moveCellUp" : "Move cell up",
354+
"DataScience.moveCellDown" : "Move cell down",
355+
"DataScience.moveSelectedCellUp" : "Move selected cell up"
336356
}

‎pythonFiles/datascience/getJupyterVariableDataFrameInfo.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# %DATASCIENCE_INTERNAL_KEY%
12
# Query Jupyter server for the info about a dataframe
23
import json as _VSCODE_json
34
import pandas as _VSCODE_pd
@@ -101,4 +102,4 @@
101102
# Cleanup imports
102103
del _VSCODE_json
103104
del _VSCODE_pd
104-
del _VSCODE_pd_json
105+
del _VSCODE_pd_json

‎pythonFiles/datascience/getJupyterVariableDataFrameRows.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#%DATASCIENCE_INTERNAL_KEY%#
12
# Query Jupyter server for the rows of a data frame
23
import json as _VSCODE_json
34
import pandas as _VSCODE_pd
@@ -41,4 +42,4 @@
4142
del _VSCODE_result
4243
del _VSCODE_json
4344
del _VSCODE_pd
44-
del _VSCODE_pd_json
45+
del _VSCODE_pd_json

‎pythonFiles/datascience/getJupyterVariableList.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#%DATASCIENCE_INTERNAL_KEY%#
12
# Query Jupyter server for defined variables list
23
# Tested on 2.7 and 3.6
34
from sys import getsizeof as _VSCODE_getsizeof

‎pythonFiles/datascience/getJupyterVariableValue.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#%DATASCIENCE_INTERNAL_KEY%#
12
import sys as VC_sys
23
import locale as VC_locale
34

‎pythonFiles/datascience/getServerInfo.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#%DATASCIENCE_INTERNAL_KEY%#
12
# Copyright (c) Microsoft Corporation. All rights reserved.
23
# Licensed under the MIT License.
34

@@ -21,4 +22,4 @@
2122
server_info_object["url"] = si['url']
2223
server_info_list.append(server_info_object)
2324

24-
print(json.dumps(server_info_list))
25+
print(json.dumps(server_info_list))

0 commit comments

Comments
 (0)