-
Notifications
You must be signed in to change notification settings - Fork 767
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
Pylance server crashes and/or doesn't complete run of notebook pane in VS Code using Azure ML compute instance #3433
Comments
Hi Alex, thanks for posting the issue here. Please wait for a reply. |
|
@alex-graham-claritiai, the issue with running cells wouldn't be related to Pylance. We're not involved with code execution. Please file a separate issue on the Jupyter team: https://github.com/microsoft/vscode-jupyter/issues I can help you with the crash though. Can you please set the following config setting in your "python.trace.server": "verbose", |
Hi Debonte I did this and it looks like it's crashing because of the amount of files in the workspace. I've now cleared these and it's solved the issue of crashing. Apologies - I thought the issues were related as they started at the same time. I'll post on the Jupyter page now. Thanks Alex |
Hi Debonte I spoke too soon. I started VS code up again and Pylance was crashing. Here is the output with python.trace.server set to verbose. Thanks for your help! |
Are you sure that you have set With this setting I would expect the log to start with a line like this:
|
Hi Debonte I managed to get it to crash again with python.trace.server set to verbose. Here is the output text. Thanks |
Hmm, that log still doesn't contain the output that I'm expecting. Not sure what's going on. Can you send me your I was able to repro a similar issue. The error is slightly different:
But it comes from the same area of our code, so maybe figuring out that issue will fix what you are seeing too. |
Really what I want to know is what structural changes you applied to the notebook (moving/adding/deleting cells) before Pylance crashed. It's highly likely that if I could reproduce that series of structural changes on my side, I would be able to reproduce the bug. I did some adhoc testing and found two issues in this area. I have fixes pending for both. But I still haven't seen the specific failure that you are seeing. |
@alex-graham-claritiai, looks like you set |
I can reliably reproduce this by running a script I have which deletes cell contents and replaces them by something from a file (using #!/usr/bin/python3
import pathlib
import argparse
from typing import Any
import nbformat
OLD_KEY = "old_source"
def load_solution(path: pathlib.Path, cell: dict[Any, Any]) -> None:
tags = cell["metadata"].get("tags")
if not tags:
return
if len(tags) != 1:
raise Exception(f"Expected exactly 1 tag in {cell}")
if OLD_KEY in cell["metadata"]:
raise Exception(f"Cowardly refusing to overwrite existing old source in {cell}")
solution_path = path.parent / "solutions" / f"{tags[0]}.py"
if not solution_path.exists():
print(f"WARNING: Could not find {solution_path}, skipping the cell")
return
source = [line + "\n" for line in solution_path.read_text().splitlines()]
cell["metadata"][OLD_KEY] = cell["source"]
cell["source"] = source
def undo_load_solution(cell: dict[Any, Any]) -> None:
metadata = cell["metadata"]
if OLD_KEY not in metadata:
return
cell["source"] = metadata[OLD_KEY]
del metadata[OLD_KEY]
IGNORES = [".ipynb_checkpoints"]
def run(path: pathlib.Path, undo: bool = False) -> None:
if any(ign in path.parts for ign in IGNORES):
return
print(path)
with path.open("r") as f:
nb = nbformat.read(f, as_version=4)
for cell in nb["cells"]:
if undo:
undo_load_solution(cell)
else:
load_solution(path, cell)
with path.open("w") as f:
nbformat.write(nb, f)
def parse_args() -> argparse.Namespace:
parser = argparse.ArgumentParser()
parser.add_argument("filename", type=pathlib.Path, nargs="*")
parser.add_argument("--undo", action="store_true", help="Restore old cell content")
return parser.parse_args()
def main() -> None:
args = parse_args()
paths = args.filename or [pathlib.Path("notebooks")]
for path in paths:
if path.is_dir():
for subpath in path.rglob("*.ipynb"):
run(subpath, undo=args.undo)
else:
run(path, undo=args.undo)
if __name__ == "__main__":
main() I do have debug logs, but I'd rather not make them public, given that they contain code I don't want to release. @debonte could I send them to you privately perhaps? As an aside, the log has a line which is almost half a million characters long. The "gedit" editor I usually use to paste random stuff into wasn't amused: |
@The-Compiler, I was unable to repro any Pylance problems using your script. So, yes, a log would be helpful. I emailed you using the address in your GitHub profile. Could you email me your Pylance log or make it available for download somewhere? |
It's a hidden setting. Please set it directly in your |
@The-Compiler, thanks for the log, that was extremely helpful! I have a fix pending for the crash that you hit. @alex-graham-claritiai, if you have a chance to provide a log file with |
Hi debonte I managed to get it to crash again. Here's the output. In terms of the settings.json, I'm not 100% sure I got it right. I went to the extension, opened settings and then clicked on 'edit settings in JSON'. I then manually added the line "python.trace.server": "verbose" to the user, remote and workspace settings as I don't know which one I need to adjust. Finally, and I don't know if this is a cause or not, but I'm working with sensitive client data and so the compute instances I'm using are connected to a virtual network. That said, VS code worked fine with the previous compute instances I set up. |
@alex-graham-claritiai, thanks for the log. Given what I saw in there, I'm pretty confident that you are hitting the same issue as @The-Compiler.
Did you file an issue with vscode-jupyter on this? Pylance isn't involved with running cells. |
Thanks @debonte I'll file an issue with vscode-jupyter. Just to clarify, is this the root cause of the issue, which subsequently crashes pylance? |
I believe there are two distinct issues.
|
Thanks @debonte I've added the issue to the Jupyter team. |
Since I mentioned a few crashes in this issue, I wanted to clarify where/when you can get them:
|
This issue has been fixed in prerelease version 2022.10.41, which we've just released. You can find the changelog here: CHANGELOG.md |
Environment data
requirements.txt
Code Snippet
Repro Steps
Open VS code
Expected behavior
Pane should finish running,
Tick mark should appear when pane has finished running
Actual behavior
Pane does not run
Sometimes notification that pylance server has crashed over xx times in yy minutes and won't be restarted
Logs
VS code Python Language Server Output.txt
The text was updated successfully, but these errors were encountered: