microsoft / vscode-jupyter

VS Code Jupyter extension
https://marketplace.visualstudio.com/items?itemName=ms-toolsai.jupyter
MIT License
1.28k stars 290 forks source link

DS: MVP using VS Code notebook API (June Insiders-only) #2180

Closed greazer closed 3 years ago

greazer commented 4 years ago

This epic includes all issues that should be solvable when/if VS Code adds native notebook support.

See microsoft/vscode#91987 for details on the VS Code side of the work.

Instructions to try the new Notebook Editor

DonJayamanne commented 4 years ago

Issues

Outdated/Resolved

**for VSC** * We will need to know the theme. * Today we add custom background colors to ensure images/widgets render correctly. * Else some output will not render correctly against dark background. * Proper fix is to use Jupyter styles, but then we need to map each VSC style/class against Jupyter vars (theme). * API in insiders. **TODO** * Use standard VS Code markdown renderer, if there are no latex equations. * Check if this is at all possible. * Decided not to * Review extending VSC markdown renderer to support latex * Decided not to **Changes/Discuss** * ~Use standard VS Code markdown renderer, if there are no latex equations.~ * ~Check if this is at all possible.~ * Add extension for latex in mD * Split `cellOutput.tsx` into smaller parts * At least to the level where we can give it output and it will render output * It should only handle `nbformat.IOutput`. * If we want to display errors or custom messages with links and the like, then its better for Extension to send these as separate output. This way it will work in all scenarios. * E.g. if output is truncated, then extension should send links and information in a new output accordingly, rather than expecting UI to add this stuff. * This way it will persist * We had issues when adding errors from UI side onto cell, doing this would make things lot simpler. * Split execution into separate class * Execution should update local NotebookModel with the output. * As we update local model, the updated cells are pushed up to the UI * This way, extension always has model updated (worked in nb, custom, native and VS Code notebooks). * **Question: How do we handle Interactive Windows.** * See next suggestion * Interactive Windows will have notebook models * This way exporting, execution etc will be consistent across all paradigms (nb & interactive) * I.e. model in extension and info sent to UI * Exporting, saving, etc all happen on extension, rather than UI sending cells * Also cleans up some code * Today when we execute a cell, we generate code from cell, * THen we generate a cell out of raw text * When sending results back, we send cells * i.e. we convert from cell to text, then text to cell and back again * This will be unnecessary with a unified model

DonJayamanne commented 4 years ago

Costing

MVP

Breakdown

### Area - Output (**4.5**) * [x] React Renderers for Output (non-ipywidgets) (**3.5**) * [x] (0.5) Include necessary CSS (only what we need, not everything). * [x] (2) Copy stuff from cellOutput.tsx or pull it out into separate react control (**prototype available**, I copied it sideways) * [x] (0.5) Create index.tsx purely for new Notebook API with global API to be call ed from renderer (**prototype available**) * [ ] (0.5) Bundling (**prototype available**) ### Save notebook (untitled notebooks). (**0.5**) * [x] (0.5) Save * **Prototype available** ## Miscellaneous (**2**) * [x] (0.5) Messages for interrupting kernels * [x] We have messages for restarting kernels in native editor * [x] We need same messages (interrupting kernel API already available) * [x] Tested/tests * [x] (0.5) Error handler for when execution fails * this.errorHandler.handleError(exc).ignoreErrors(); * [x] Add to executionProvider in prototype * [x] (1) Disable code lenses & interactive window related stuff in python files when in nb * [x] Send line to terminal, etc * [x] Code lenses ### Notebook handling (**3.5**) * [x] (1) INativeEditor * [x] (1) Handle other public methods on API **Prototype available** * [x] (1) INativeEditorProvider * Prototype available * Service registrations * [x] (0.1) No need of autosave * [x] (0.1) Intellisense provider (will need to refactor line by line to get that working without intellisense) * [x] (0.5) Remove code related to syncing (completely for custom, vsc nb) * [x] (0.5) Update notebook model as we execute cells instead of sending to UI * Update VS Code Cells and Notebook as we make changes to INotebookModel * Prototype available ### Telemetry/Experiments/Keyboard shortcuts & commands (**6.5**) * [x] (1.5) Like for like telemetry * Identify all telemetry individually & ensure we have all of them in new Notebook API * [x] (2) New experiments library * [ ] (2) Support Jupyter keyboard shortcuts * [x] Prototype available * [ ] Identify all missing shortcuts and add them * [x] (1) Update VS Code contexts * [x] Context keys are used to enable/disable commands (show/hide/enable/disable). * [ ] Tests/Tested # Language features (**2**) * [ ] (1.5) Intellisense * [ ] (1) With Jedi (it works today with our nb, hence should be possible) * Prototype available * [ ] (0.5) Default to MS LSP if Jedi will not work * [x] (0.2) Disable refactor, formatting, sorting imports, linting

Non-MVP (47)

Click for breakdown

### Area - Output (**1.5**) * [ ] React Renderers for Output (non-ipywidgets) (**1.5**) * [ ] (0.5) Handle special click events (links, etc) & send a message (postMessage) * Generic link click handler for output. * **prototype available** * [ ] Renderer extension code (**1**) * [ ] (0.2) Metadata in images (custom height, backgrounds, retina) (**prototype available**) * [ ] (0.2) Adding white/black backgrounds for images when necessary * **Prototype available** * [ ] (0.5) Display icons to open plots in our (this should be done in extension side of Renderer, leaving React to do absolutely nothing but render) * Link in HTML can contain `acquireVsCodeAPI().postMessage({type:'openPlot', payload:{cellIdOrPlotId:'xxx'})` * This way renderer doesn't need to know anything. * **Prototype available** * [ ] (0) Scrolling of output and the like * ~Discuss: We can control what gets displayed, when to dislplay scroll bars, etc by altering the output (nbformat.CellOutput).~ * ~I.e. keep logic for scrolling & localized messages in extension~ * **Personally I think its best to re-visit this whole scrolling thing**. * **We probably shouldn't do anything as VSC is taking this up** https://github.com/microsoft/vscode/issues/93541 ### IPyWidgets (**8**) * [ ] Renderers for IPyWidgets (3) * **Prototype available** * [ ] (2) Copy stuff from `container.tsx` and hook up comms * [ ] (1) Create index.tsx purely widgets * [ ] Extension Listeners (3) * [ ] (2) IPyWidgetHandler * [ ] (1) IPyWidgetScriptSource * [ ] Refactor our UI tests (2) * Launch HTML page act like NB that only displays output ### Variable Explorer (**9**) * [ ] (1) Jupyter side in Activity Bar * [ ] (5) Varialbles * Variables in a new panel (in Jupyter sidebar panel) * Use treeview. * [ ] (2) Kernels * [ ] (1) Metadata ### Liveshare * Won't be doing anything special at this stage. ### Save/SaveAs/Rename notebook (untitled notebooks). (**2.5**) * [ ] (2) Transition kernel session to right Uri (when saving, save as and rename) * **Prototype available** * [ ] (0.5) Dispose kernel when closing notebooks * Filed issue on VSC (need to know when all editors for file are closed) * **Prototype available** * [x] Kernel is no longer attached to nb when using `save as` when multiple editors are opened * Mention to team **Prototype available** ### Miscellaneous (**4.5**) * [ ] (1) Export/import (ipynb to python, python to ipynb) * Move into common area in new implementation * [ ] (0.5) Messages for restarting kernels * Assuming its similar to interrupting kernels * [ ] (3) Kernel selection & Updating metadata * Move or copy (little code), but needs to be done in right place * Automatically & manually selecting a kernel & updating metadata * Move or copy code, but needs to be done in right place * Preferably move (to ensure we do things right, as this has a lot of business rules) ### Notebook handling (**5**) * [ ] (2.5) INativeEditor * [ ] (2) Pass messages to all the listeners & handle output from listeners * [ ] (0.5) Handle messages from renderers and pass onto listeners * [ ] (0.5) Standardize names for notebook objects (we will have 4) * nbformat.xx for Jupyter Cells and Output * INotebookModel & ICell for out models * NotebookData & NotebookCellData for VSCode model * NotebookDocument & NotebookCell for VS Code models * [ ] Refactor to use new naming convention (to discuss if this is confusing). With the new VSC API, this is very confusing. ### Toolsbars and runby line (**12**) * [ ] (10) Run line by line * [ ] (2) Toolbars * Icons should fire commands * Modify existing command handler to delegate the actions. ### Language features (4) * [ ] (2) Hover provider (new work done as part of Run by line) * [ ] (2) Formatting * We'll need to update core extension to handle formatting of non-file based text documents. * Suggestion - Support most popular formatters (check telemetry) * [ ] (2) Formatting * Same as formatting