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

How to explicitly specify that Pylance only scans specific a few directories in a large multi-root workspace #5794

Open
vbem opened this issue Apr 23, 2024 · 8 comments
Assignees
Labels
bug Something isn't working

Comments

@vbem
Copy link

vbem commented Apr 23, 2024

Hi, I have a large multi-root workspace containing many project-directories, but only a few among them are Python related. Every time a start VScode, the Pylance starts scanning every project-directory in my multi-root workspace, it consumes several minutes before I can work in Python related project-directories.

Is it possible I can limit the directories Pylance will scan in a multi-root workspace? Thanks in advance.

image
image

@github-actions github-actions bot added the needs repro Issue has not been reproduced yet label Apr 23, 2024
@StellaHuang95
Copy link
Contributor

Hi @vbem, if you don't want certain directories or paths to be included in the analysis, you can do the followings:

  1. Open command palette, search for workspace settings.
  2. Add the following to your settings:
"settings": {
	"python.analysis.exclude": ["full path of directories or files"]
}

Globbing is supported, so please refer to this doc for more details.

Please use full paths for now as I found a bug with using variables like ${workspaceFolder:<workspace folder name>}. I will mark this issue as a bug and give an update once the bug is fixed. Thanks.

@StellaHuang95 StellaHuang95 added bug Something isn't working and removed needs repro Issue has not been reproduced yet labels Apr 23, 2024
@vbem
Copy link
Author

vbem commented Apr 24, 2024

"settings": {
	"python.analysis.exclude": ["full path of directories or files"]
}

Thanks a lot for your guidance @StellaHuang95 . I added other non-python directories (full-path) into python.analysis.exclude of my multi-root workspace settings, restarted VScode, but the scanning on every project-directory still shown up:

image

image

image

@rchiodo
Copy link
Contributor

rchiodo commented Apr 24, 2024

I believe you need to actually use a glob like so:

"python.analysis.exclude: ["/root/_git/foo/bar/**/*.py*"]

The Starting server instance entries will still show up though. We should just skip the indexing and analysis then.

@vbem
Copy link
Author

vbem commented Apr 24, 2024

I believe you need to actually use a glob like so:

"python.analysis.exclude: ["/root/_git/foo/bar/**/*.py*"]

The Starting server instance entries will still show up though. We should just skip the indexing and analysis then.

Thanks a lot for your hints.

But is it possible to disable/enable pylance scanning instances for certain project-directories? Because in a large multi-root workspace with only 1 python related project-directory, user still need to wait all scanning instance done before working on the python directory, which consumes a lot of unnecessary time and resources.

@rchiodo
Copy link
Contributor

rchiodo commented Apr 24, 2024

But is it possible to disable/enable pylance scanning instances for certain project-directories? Because in a large multi-root workspace with only 1 python related project-directory, user still need to wait all scanning instance done before working on the python directory, which consumes a lot of unnecessary time and resources.

Sorry there's no way to completely ignore a workspace folder. The ignore logic is actually independent of the folder handling.

Internally there should be no scanning. We will create data structures to track those other folders, but then any documents in that folder will be marked as skipped. The only work that should happen is that it finds no source or files in those folders.

@heejaechang
Copy link
Contributor

heejaechang commented Apr 29, 2024

But is it possible to disable/enable pylance scanning instances for certain project-directories?

you can have folder specific setting for multi workspaces in vscode using this - https://code.visualstudio.com/docs/editor/workspaces#_multiroot-workspace-settings

for your specific issue, create .vscode/settings.json in the root that you want to ignore python files completely.

and add

{
    "python.analysis.exclude": ["**/*.py", "**/*.pyi"]
}

any setting in code-workspace will apply to all workspaces so, that place is not right place if you want settings that apply for only some of roots.

@djettah
Copy link

djettah commented Jul 8, 2024

add

{
    "python.analysis.exclude": ["**/*.py", "**/*.pyi"]
}

I've tried this but unfortunately it doesn't prevent pylance instances from starting and consequently using a big slice of RAM (around 2 GB for 30 roots) in a devcontainer. Are there any other workarounds?

@heejaechang
Copy link
Contributor

@djettah can you take a look at https://github.com/microsoft/pylance-release/wiki/Opening-Large-Workspaces-in-VS-Code ?

that should have more detail instructions on how to set up large workspace.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants