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

Cannot execute cell or save Jupyter Notebook in remote VS connection opened with showNotebookDocument API #119891

Closed
sevillal opened this issue Mar 25, 2021 · 21 comments
Assignees
Labels
important Issue identified as high-priority info-needed Issue requires more information from poster notebook-kernel

Comments

@sevillal
Copy link

  • VS Code Version: 1.55.0-insider Commit: 6f726bc
  • OS Version: Win 10 Enterprise 10.0.19042

Steps to Reproduce:

  1. Inside the resolve() function open .ipynb file using vscode.window.showNotebookDocument([fileUri]);
  • Notebook is open and rendered fine using native notebooks
  • Cannot execute cells
  • Cannot save changes

Full log attached.
full_log.txt

notificationsAlerts.ts:40 Failed to save 'test.ipynb': NO notebook document for 'file:///home/azureuser/cloudfiles/code/test.ipynb' onDidChangeNotification @ notificationsAlerts.ts:40 console.ts:137 [Extension Host] Kernel: connected (e2434543-78ef-4522-969d-c701497f1f15) console.ts:137 [Extension Host] Starting WebSocket: ws://localhost:8891/api/kernels/147d0cee-7924-402f-97d0-383ba5c2da51 console.ts:137 [Extension Host] Kernel: connected (147d0cee-7924-402f-97d0-383ba5c2da51) log.ts:296 ERR Invalid uri, not a notebook: /home/azureuser/cloudfiles/code/test.ipynb: Error: Invalid uri, not a notebook: /home/azureuser/cloudfiles/code/test.ipynb at s.getTextDocumentWrapper (/home/azureuser/.vscode-server-insiders/extensions/ms-python.python-2021.3.680753044/out/client/extension.js:61:198474) at s.toOutgoingDocument (/home/azureuser/.vscode-server-insiders/extensions/ms-python.python-2021.3.680753044/out/client/extension.js:61:192283) at t.NotebookMiddlewareAddon.provideHover (/home/azureuser/.vscode-server-insiders/extensions/ms-python.python-2021.3.680753044/out/client/extension.js:61:186794) at y.callNext (/home/azureuser/.vscode-server-insiders/extensions/ms-python.python-2021.3.680753044/out/client/extension.js:9:431693) at y.provideHover (/home/azureuser/.vscode-server-insiders/extensions/ms-python.python-2021.3.680753044/out/client/extension.js:9:429657) at y.o.value (/home/azureuser/.vscode-server-insiders/extensions/ms-python.python-2021.3.680753044/out/client/extension.js:9:432312) at Object.provideHover (/home/azureuser/.vscode-server-insiders/extensions/ms-python.python-2021.3.680753044/out/client/extension.js:9:136682) at /home/azureuser/.vscode-server-insiders/bin/6f726bcdf6a4d6cb518a3fcdb03c21be7293f417/out/vs/server/remoteExtensionHostProcess.js:86:159486 at /home/azureuser/.vscode-server-insiders/bin/6f726bcdf6a4d6cb518a3fcdb03c21be7293f417/out/vs/server/remoteExtensionHostProcess.js:64:12046 at new Promise (<anonymous>) at g (/home/azureuser/.vscode-server-insiders/bin/6f726bcdf6a4d6cb518a3fcdb03c21be7293f417/out/vs/server/remoteExtensionHostProcess.js:64:12018) at l.provideHover (/home/azureuser/.vscode-server-insiders/bin/6f726bcdf6a4d6cb518a3fcdb03c21be7293f417/out/vs/server/remoteExtensionHostProcess.js:86:159466) at /home/azureuser/.vscode-server-insiders/bin/6f726bcdf6a4d6cb518a3fcdb03c21be7293f417/out/vs/server/remoteExtensionHostProcess.js:86:182161 at Ie._withAdapter (/home/azureuser/.vscode-server-insiders/bin/6f726bcdf6a4d6cb518a3fcdb03c21be7293f417/out/vs/server/remoteExtensionHostProcess.js:86:178959) at Ie.$provideHover (/home/azureuser/.vscode-server-insiders/bin/6f726bcdf6a4d6cb518a3fcdb03c21be7293f417/out/vs/server/remoteExtensionHostProcess.js:86:182137) at u._doInvokeHandler (/home/azureuser/.vscode-server-insiders/bin/6f726bcdf6a4d6cb518a3fcdb03c21be7293f417/out/vs/server/remoteExtensionHostProcess.js:90:12794) at u._invokeHandler (/home/azureuser/.vscode-server-insiders/bin/6f726bcdf6a4d6cb518a3fcdb03c21be7293f417/out/vs/server/remoteExtensionHostProcess.js:90:12478) at u._receiveRequest (/home/azureuser/.vscode-server-insiders/bin/6f726bcdf6a4d6cb518a3fcdb03c21be7293f417/out/vs/server/remoteExtensionHostProcess.js:90:11094) at u._receiveOneMessage (/home/azureuser/.vscode-server-insiders/bin/6f726bcdf6a4d6cb518a3fcdb03c21be7293f417/out/vs/server/remoteExtensionHostProcess.js:90:9931) at /home/azureuser/.vscode-server-insiders/bin/6f726bcdf6a4d6cb518a3fcdb03c21be7293f417/out/vs/server/remoteExtensionHostProcess.js:90:8032 at b.fire (/home/azureuser/.vscode-server-insiders/bin/6f726bcdf6a4d6cb518a3fcdb03c21be7293f417/out/vs/server/remoteExtensionHostProcess.js:57:1836) at E.fire (/home/azureuser/.vscode-server-insiders/bin/6f726bcdf6a4d6cb518a3fcdb03c21be7293f417/out/vs/server/remoteExtensionHostProcess.js:65:15496) at /home/azureuser/.vscode-server-insiders/bin/6f726bcdf6a4d6cb518a3fcdb03c21be7293f417/out/vs/server/remoteExtensionHostProcess.js:105:29935 at b.fire (/home/azureuser/.vscode-server-insiders/bin/6f726bcdf6a4d6cb518a3fcdb03c21be7293f417/out/vs/server/remoteExtensionHostProcess.js:57:1836) at E.fire (/home/azureuser/.vscode-server-insiders/bin/6f726bcdf6a4d6cb518a3fcdb03c21be7293f417/out/vs/server/remoteExtensionHostProcess.js:65:15496) at t._receiveMessage (/home/azureuser/.vscode-server-insiders/bin/6f726bcdf6a4d6cb518a3fcdb03c21be7293f417/out/vs/server/remoteExtensionHostProcess.js:65:20754) at /home/azureuser/.vscode-server-insiders/bin/6f726bcdf6a4d6cb518a3fcdb03c21be7293f417/out/vs/server/remoteExtensionHostProcess.js:65:17640 at b.fire (/home/azureuser/.vscode-server-insiders/bin/6f726bcdf6a4d6cb518a3fcdb03c21be7293f417/out/vs/server/remoteExtensionHostProcess.js:57:1836) at acceptChunk (/home/azureuser/.vscode-server-insiders/bin/6f726bcdf6a4d6cb518a3fcdb03c21be7293f417/out/vs/server/remoteExtensionHostProcess.js:65:12861) at /home/azureuser/.vscode-server-insiders/bin/6f726bcdf6a4d6cb518a3fcdb03c21be7293f417/out/vs/server/remoteExtensionHostProcess.js:65:12209 at b.fire (/home/azureuser/.vscode-server-insiders/bin/6f726bcdf6a4d6cb518a3fcdb03c21be7293f417/out/vs/server/remoteExtensionHostProcess.js:57:1836) at /home/azureuser/.vscode-server-insiders/bin/6f726bcdf6a4d6cb518a3fcdb03c21be7293f417/out/vs/server/remoteExtensionHostProcess.js:105:18820 at afterWrite (_stream_writable.js:490:5) at onwrite (_stream_writable.js:470:7) at InflateRaw.afterTransform (_stream_transform.js:98:3) at Zlib.processCallback (zlib.js:578:8)

@roblourens
Copy link
Member

Cannot execute cells

Can you give some more details about what you are doing and what's going wrong?

@sevillal
Copy link
Author

  1. Clicking the "play" icon doesn't execute the cell
    cannon_execute_cell

  2. After applying some changes and trying to save the notebooks there is an error notification "Failed to save [file]: NO notebook document for [fileUri]
    cannot_save

@roblourens
Copy link
Member

Do you have the latest version of the jupyter extension installed on your remote?

@sevillal
Copy link
Author

I have latest insiders for Jupyter 2021.5.685944597.

I tried with latest stable Jupyter 2020.11.399280825 but jupyter fails to activate.

@roblourens
Copy link
Member

Why does this document URI have the file scheme? Is it a local document? Did you open it with a file URI?

@sevillal
Copy link
Author

That's something we don't understand since we are opening with "vscode-remote://amlext/home/azureuser/cloudfiles/code/test.ipynb"

@roblourens
Copy link
Member

It's working fine for me. Could you run "Set Log Level" > Trace, run the scenario again, and share the log from the Log (Window) output channel?

@roblourens roblourens added the info-needed Issue requires more information from poster label Mar 25, 2021
@sevillal
Copy link
Author

window.txt

@SiddhanthUnnithan
Copy link

@roblourens were you able to repro and have it working for AML remote or is this with a different remote extension?

@roblourens
Copy link
Member

I was just trying it with the SSH extension, I don't know why it would be different.

In your log @sevillal it looks like it ends with just opening the notebook. Did you try to save and get the same error this time?

@sevillal
Copy link
Author

@roblourens I noticed the following behavior:

  1. Run cell (nothing happens)
  2. Change notebook and save -> error is shown

But, if I don't run the cell first I can change and save the document without issues.

Attaching log with the saving error:
save_notebook.log

@SiddhanthUnnithan
Copy link

Cc/ @DonJayamanne for visibility

@DonJayamanne
Copy link
Contributor

DonJayamanne commented Mar 25, 2021

Apologies if this information has already been provided.

@roblourens from what i can tell,

  • Things work when the notebook is opened manually from the explorer
  • When opened from the explorer the execution works & when opnened using the command by AML extension then things fall over.

This following error is interesting

Here are the logs when it fails (Logs from Jupyter Extension)
Info 2021-03-25 22:09:16: Execute Cell 0 file:///home/azureuser/cloudfiles/code/test.ipynb in kernelWithMetadata.ts
Info 2021-03-25 22:09:16: Cell Index:0, state:undefined, exec: 1. User queued cell for execution
Info 2021-03-25 22:09:16: Cell Index:0, state:undefined, exec: 1. Update cell state as it was enqueued
Info 2021-03-25 22:09:16: Hooked up kernel restart handler
Info 2021-03-25 22:09:16: Cell Index:0, state:undefined, exec: 1. Ready to execute
Info 2021-03-25 22:09:16: Cell Index:0, state:undefined, exec: 1. Before Execute individual cell
Info 2021-03-25 22:09:16: Cell Index:0, state:undefined, exec: 1. Start execution
Info 2021-03-25 22:09:16: Cell Index:0, state:undefined, exec: 1. After Execute individual cell undefined
Error 2021-03-25 22:09:16: Failed to execute cells in CellExecutionQueue Error: Can't apply edits to unknown notebook model: [object Object]
    at m.$applyEdits (file:///C:/Users/sevillal/AppData/Local/Programs/Microsoft VS Code Insiders/resources/app/out/vs/workbench/workbench.desktop.main.js:2177:4632)
    at o._doInvokeHandler (file:///C:/Users/sevillal/AppData/Local/Programs/Microsoft VS Code Insiders/resources/app/out/vs/workbench/workbench.desktop.main.js:1589:11903)
    at o._invokeHandler (file:///C:/Users/sevillal/AppData/Local/Programs/Microsoft VS Code Insiders/resources/app/out/vs/workbench/workbench.desktop.main.js:1589:11587)
    at o._receiveRequest (file:///C:/Users/sevillal/AppData/Local/Programs/Microsoft VS Code Insiders/resources/app/out/vs/workbench/workbench.desktop.main.js:1589:10257)
    at o._receiveOneMessage (file:///C:/Users/sevillal/AppData/Local/Programs/Microsoft VS Code Insiders/resources/app/out/vs/workbench/workbench.desktop.main.js:1589:9043)
    at file:///C:/Users/sevillal/AppData/Local/Programs/Microsoft VS Code Insiders/resources/app/out/vs/workbench/workbench.desktop.main.js:1589:7144
    at c.fire (file:///C:/Users/sevillal/AppData/Local/Programs/Microsoft VS Code Insiders/resources/app/out/vs/workbench/workbench.desktop.main.js:60:1836)
    at s.fire (file:///C:/Users/sevillal/AppData/Local/Programs/Microsoft VS Code Insiders/resources/app/out/vs/workbench/workbench.desktop.main.js:76:16186)
    at i._receiveMessage (file:///C:/Users/sevillal/AppData/Local/Programs/Microsoft VS Code Insiders/resources/app/out/vs/workbench/workbench.desktop.main.js:76:21444)
    at file:///C:/Users/sevillal/AppData/Local/Programs/Microsoft VS Code Insiders/resources/app/out/vs/workbench/workbench.desktop.main.js:76:18330
    at c.fire (file:///C:/Users/sevillal/AppData/Local/Programs/Microsoft VS Code Insiders/resources/app/out/vs/workbench/workbench.desktop.main.js:60:1836)
    at u.acceptChunk (file:///C:/Users/sevillal/AppData/Local/Programs/Microsoft VS Code Insiders/resources/app/out/vs/workbench/workbench.desktop.main.js:76:13551)
    at file:///C:/Users/sevillal/AppData/Local/Programs/Microsoft VS Code Insiders/resources/app/out/vs/workbench/workbench.desktop.main.js:76:12899
    at file:///C:/Users/sevillal/AppData/Local/Programs/Microsoft VS Code Insiders/resources/app/out/vs/workbench/workbench.desktop.main.js:633:108452
    at c.fire (file:///C:/Users/sevillal/AppData/Local/Programs/Microsoft VS Code Insiders/resources/app/out/vs/workbench/workbench.desktop.main.js:60:1836)
    at FileReader._fileReader.onload (file:///C:/Users/sevillal/AppData/Local/Programs/Microsoft VS Code Insiders/resources/app/out/vs/workbench/workbench.desktop.main.js:633:107069)
Info 2021-03-25 22:09:16: Cancel pending cells
Info 2021-03-25 22:09:16: Kernel got disposed, hence there is no longer a kernel associated with file:///home/azureuser/cloudfiles/code/test.ipynb file:///home/azureuser/cloudfiles/code/test.ipynb
Info 2021-03-25 22:09:16: Shutting down session file:///home/azureuser/cloudfiles/code/test.ipynb
Info 2021-03-25 22:09:16: Shutdown session - current session
Info 2021-03-25 22:09:16: shutdownSession f6615c65-f8e1-4f19-91b1-37c4ca518199, .python369jvsc74a57bd00b23af0ce16aa97b5d48acae7fae86d8f282aae2868783ba0fe17672ed39eae2./anaconda/envs/azureml_py36/bin/python./anaconda/envs/azureml_py36/bin/python.Python 3.6.9 64-bit ('azureml_py36': conda) - start
Info 2021-03-25 22:09:16: Session can be shutdown .python369jvsc74a57bd00b23af0ce16aa97b5d48acae7fae86d8f282aae2868783ba0fe17672ed39eae2./anaconda/envs/azureml_py36/bin/python./anaconda/envs/azureml_py36/bin/python.Python 3.6.9 64-bit ('azureml_py36': conda)
Info 2021-03-25 22:09:16: Python Daemon (pid: 12675): write to stderr: [I 22:09:16.662 NotebookApp] Kernel shutdown: f6615c65-f8e1-4f19-91b1-37c4ca518199
[I 22:09:16.662 NotebookApp] Kernel shutdown: f6615c65-f8e1-4f19-91b1-37c4ca518199Info 2021-03-25 22:09:16: Python Daemon (pid: 12675): write to stderr: 

Info 2021-03-25 22:09:17: shutdownSession f6615c65-f8e1-4f19-91b1-37c4ca518199, .python369jvsc74a57bd00b23af0ce16aa97b5d48acae7fae86d8f282aae2868783ba0fe17672ed39eae2./anaconda/envs/azureml_py36/bin/python./anaconda/envs/azureml_py36/bin/python.Python 3.6.9 64-bit ('azureml_py36': conda) - shutdown complete
Info 2021-03-25 22:09:17: Shutdown session - get restart session
Info 2021-03-25 22:09:17: Shutdown session - shutdown restart session
Info 2021-03-25 22:09:17: shutdownSession cabf70dd-0859-4061-b5ef-d80972194586, .python369jvsc74a57bd00b23af0ce16aa97b5d48acae7fae86d8f282aae2868783ba0fe17672ed39eae2./anaconda/envs/azureml_py36/bin/python./anaconda/envs/azureml_py36/bin/python.Python 3.6.9 64-bit ('azureml_py36': conda) - start
Info 2021-03-25 22:09:17: Session can be shutdown .python369jvsc74a57bd00b23af0ce16aa97b5d48acae7fae86d8f282aae2868783ba0fe17672ed39eae2./anaconda/envs/azureml_py36/bin/python./anaconda/envs/azureml_py36/bin/python.Python 3.6.9 64-bit ('azureml_py36': conda)
Info 2021-03-25 22:09:17: Python Daemon (pid: 12675): write to stderr: [I 22:09:17.080 NotebookApp] Kernel shutdown: cabf70dd-0859-4061-b5ef-d80972194586
[I 22:09:17.080 NotebookApp] Kernel shutdown: cabf70dd-0859-4061-b5ef-d80972194586Info 2021-03-25 22:09:17: Python Daemon (pid: 12675): write to stderr: 

Info 2021-03-25 22:09:17: shutdownSession cabf70dd-0859-4061-b5ef-d80972194586, .python369jvsc74a57bd00b23af0ce16aa97b5d48acae7fae86d8f282aae2868783ba0fe17672ed39eae2./anaconda/envs/azureml_py36/bin/python./anaconda/envs/azureml_py36/bin/python.Python 3.6.9 64-bit ('azureml_py36': conda) - shutdown complete
Info 2021-03-25 22:09:17: Shutdown session -- complete
Here are the logs when the notebook was opened from file explorer & things work (Logs from Jupyter Extension)
Info 2021-03-25 22:11:50: Execute Cell 0 file:///home/azureuser/cloudfiles/code/test2.ipynb in kernelWithMetadata.ts
Info 2021-03-25 22:11:50: Cell Index:0, state:undefined, exec: undefined. User queued cell for execution
Info 2021-03-25 22:11:50: Cell Index:0, state:undefined, exec: undefined. Update cell state as it was enqueued
Info 2021-03-25 22:11:50: Hooked up kernel restart handler
Info 2021-03-25 22:11:50: Cell Index:0, state:undefined, exec: undefined. Ready to execute
Info 2021-03-25 22:11:50: Cell Index:0, state:undefined, exec: undefined. Before Execute individual cell
Info 2021-03-25 22:11:50: Cell Index:0, state:undefined, exec: undefined. Start execution
Info 2021-03-25 22:11:50: Cell Index:0, state:3, exec: undefined. Send code for execution
Info 2021-03-25 22:11:50: Cell Index:0, state:3, exec: undefined. Wait for jupyter execution
Info 2021-03-25 22:11:50: Cell Index:0, state:3, exec: undefined. Kernel switching to busy
Info 2021-03-25 22:11:50: Notebook Session status file:///home/azureuser/cloudfiles/code/test2.ipynb # Busy
Info 2021-03-25 22:11:50: Cell Index:0, state:3, exec: undefined. Update streamed output
Info 2021-03-25 22:11:51: Cell Index:0, state:3, exec: 1. Kernel switching to idle
Info 2021-03-25 22:11:51: Notebook Session status file:///home/azureuser/cloudfiles/code/test2.ipynb # Idle
Info 2021-03-25 22:11:51: Cell Index:0, state:3, exec: 1. Jupyter execution completed
Info 2021-03-25 22:11:51: Cell Index:0, state:3, exec: 1. Completed successfully
Info 2021-03-25 22:11:51: Cell Index:0, state:3, exec: 1. Update cell state 3 and message ''
Info 2021-03-25 22:11:51: Cell Index:0, state:3, exec: 1. Completed successfully & resolving
Info 2021-03-25 22:11:51: Cell Index:0, state:3, exec: 1. After Execute individual cell 3
Info 2021-03-25 22:11:51: Cell Index:0, state:3, exec: 1. Executed successfully in executeCell
Info 2021-03-25 22:11:51: Cell Index:0, state:3, exec: 1. Execution disposed
Info 2021-03-25 22:11:52: Trusting notebook...

@sevillal
Copy link
Author

@roblourens I was able to repro with remote-ssh extension by opening the file as we do in azureml extension (maybe we are not opening it the right way)

Here the change I tested: https://github.com/sevillal/vscode-remote-ssh/commit/3042b2c18ff8b0a1f9350d85b72c4fb4eecd9fd6

@roblourens
Copy link
Member

That is not a valid URI, I'm not even sure why it opens the notebook. It's missing the host. I can repro with that URI but not a well-formed URI that includes the host. Example

vscode.window.showNotebookDocument(vscode.Uri.parse('vscode-remote://ssh-remote%2bmyhost/path/to/notebook'), {
			preserveFocus: false,
			preview: false
});

I am sure this has nothing to do with remote, and is just the result of passing the wrong URI. Try this

const uri = vscode.workspace.workspaceFolders![0].uri.with({
	path: '/path/to/notebook'
});
console.log(uri.toString());

@roblourens
Copy link
Member

In your AML scenario, try comparing the URI of the editor that is opened when you click that file in the explorer, to the URI that you pass to showNotebookDocument. I think VS Code is too tolerant in something, and we don't fail until you try to save.

@SiddhanthUnnithan
Copy link

Thanks for the suggestion @roblourens. We're wondering how to get the URI for files that are manually opened? Is that logged somewhere or do we need to add something ourselves?

@roblourens
Copy link
Member

You can read the vscode.notebook.notebookDocuments array

@sevillal
Copy link
Author

sevillal commented Apr 1, 2021

@roblourens we were able to see the right behavior after using the same URI format as in vscode.notebook.notebookDocuments, thanks for all your help!

Before closing this issue the team will test the change in stable 1.55 just to confirm is working fine for everybody.

@jrieken
Copy link
Member

jrieken commented Apr 21, 2021

ping @sevillal - can this be closed?

@github-actions github-actions bot locked and limited conversation to collaborators Jun 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
important Issue identified as high-priority info-needed Issue requires more information from poster notebook-kernel
Projects
None yet
Development

No branches or pull requests

7 participants
@roblourens @rebornix @jrieken @DonJayamanne @SiddhanthUnnithan @sevillal and others