vscode-jupyter icon indicating copy to clipboard operation
vscode-jupyter copied to clipboard

jupyter.notebookFileRoot setting doesn't work properly in multi-project workspace

Open maestro4 opened this issue 4 years ago • 6 comments

It seems like that jupyter.notebookFileRoot setting doesn't take in effect in a multi-project workspace where the Python project is not defined as the first project in workspace settings.

How to reproduce the bug

  • Create two project folders
cd ~/git
mkdir -p test/java-project test/python-project
mkdir -p test/python-project/src/notebooks
  • Open VScode

  • Important: Add first folder to workspace test/python-project

  • Important: Add second folder to workspace test/java-project

  • Save workspace as "test-workspace.code-workspace"

  • Create test.py in python-project/src/notebooks with

# %% 
import sys
import os
#print(sys.path)
print(os.getcwd())
  • Running test.py as "python interactive" will output
~/git/test/python-project/src/notebooks
  • Add in folder settings for python-project
{
    "jupyter.notebookFileRoot": "${workspaceFolder}"
}
  • Running test.py as "python interactive" will output
~/git/test/python-project
  • Open workspace settings as JSON and change the order of the Python project to:
{
	"folders": [
		{
			"path": "../../git/test/java-project"
		},
		{
			"path": "../../git/test/python-project"
		},
	],
	"settings": {}
}
  • Running test.py as "python interactive" will output the incorrect path
~/git/test/python-project/src/notebooks

maestro4 avatar Mar 17 '21 11:03 maestro4

Thanks for the bug. I believe the root cause of this problem is how we start the interactive window when it's in 'multiple' interactive window mode.

If you set the interactive window mode to perfile, it will work:

"jupyter.interactiveWindowMode": "perFile"

rchiodo avatar Mar 17 '21 17:03 rchiodo

If you set the interactive window mode to perfile, it will work:

"jupyter.interactiveWindowMode": "perFile"

Thanks for the reply.

I applied this setting for user, workspace, and for all folders. Unfortunately, the setting doesn't seem to have any effect. I'm still getting the wrong path (not the ${workspaceFolder} path). I've also restarted VSCode mutlipe times in between the tests just to be sure that the setting will be used.

maestro4 avatar Mar 18 '21 10:03 maestro4

Actually never mind, it's not working for me with 'perFile' either. We aren't passing the file to the startup of the notebook kernel for the interactive window so it doesn't have a way to identify which 'workspace' it's in.

rchiodo avatar Mar 18 '21 16:03 rchiodo

Actually never mind, it's not working for me with 'perFile' either. We aren't passing the file to the startup of the notebook kernel for the interactive window so it doesn't have a way to identify which 'workspace' it's in.

Ah alright.

I'll just mention that I'm using the latest stable version of Visual Studio Code (1.54.3), ms-python.python (v2021.3.658691958), ms-python.vscode-pylance (v2021.3.2), ms-toolsai.jupyter (v2021.3.619093157) on Mac.

What would be the next step? Classify as bug?

maestro4 avatar Mar 19 '21 08:03 maestro4

Yeah sorry I thought it was already classified that way. The next step now is for our triage to decide the priority for fixing this.

The root cause of the problem is a little tricky as it would require reworking when we start the underlying kernel for the interactive window.

rchiodo avatar Mar 19 '21 16:03 rchiodo

We should look at the telemetry of the use of this setting.

greazer avatar Mar 22 '21 17:03 greazer

looks like this has been fixed

amunger avatar Dec 07 '22 22:12 amunger