-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Importing Pyomo module causes high VSCode Code Helper CPU usage #4484
Comments
Some added notes:
|
I am also seeing 99% CPU usage, though not the syntax coloring behavior. Also on Python 3.10.8, Conda and using Pyomo. |
Transferring to pyright, since this is a core type checker issue. |
@fleimgruber, in my case, it seems reasonably repeatable. Here, Pyomo is commented out, and colouring works fine. If I enable the import, only pyomo's colouring does not work. Then, I close then re-open VSCode while keeping pyomo's import active... I've noticed that the Code Helper goes extra crazy on CPU usage in the last case too. |
@irm-codebase Thanks for checking back! I am using a custom color highlighting where the differences were not immediately apparent (i.e. parts worked fine). With one of the default themes I can confirm and reproduce the behavior you see with your steps and Ctrl-Shift-P then "Developer: Reload Window". |
I'm able to repro the problem and will investigate further. Pyright is attempting to infer a function return type in the pyomo library (which does not contain any type annotations), and it's choking on one of the functions. |
…erring the type of a tuple in a loop. This addresses #4484.
This will be addressed in the next release of pyright and a future release of pylance. |
This is included in pyright 1.1.291, which I just published. It will also be included in a future release of pylance. |
Fantastic! Thank you, @erictraut. |
Pyright is typically published on Tuesday each week, and Pylance is published on Wednesday. Two versions of Pylance are published each week — a production version and an "insiders build". The latter includes changes from Tuesday's pyright build. The former contains pyright changes from the previous week. In other words, the production version lags the insiders version by one week. So, if you switch to the Pylance "insiders build", you will see this change within the next 24 hours. And yes, pylance and pyright will not run at the same time. The pyright VS Code extension disables itself if it sees that Pylance is installed. |
Type: Bug
Behaviour
Expected vs. Actual
Importing the pyomo library (used for optimisation modelling) should not cause any issues with VSCode.
However, if you import it as:
Code Helper will jump to 99% CPU usage and syntax coloring in VSCode will stop working (i.e., variables are no longer detected/colored in the editor).
I have noticed that this occurs mostly in files with high amounts of usage of the 'pyo' instance, and when it is present in function annotations.
Steps to reproduce:
I am using Mac with an Intel chipset.
The code below is an excerpt of my file (cannot fully share it). I assume copy-pasting the functions several times with different names should trigger the issue.
Diagnostic data
python.languageServer
setting: DefaultOutput for
Python
in theOutput
panel (View
→Output
, change the drop-down the upper-right of theOutput
panel toPython
)User Settings
Extension version: 2022.20.2
VS Code version: Code 1.74.3 (97dec172d3256f8ca4bfb2143f3f76b503ca0534, 2023-01-09T17:07:18.579Z)
OS version: Darwin x64 21.6.0
Modes:
Sandboxed: No
System Info
canvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
metal: disabled_off
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_renderer: enabled_on
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: disabled_off
A/B Experiments
The text was updated successfully, but these errors were encountered: