microsoft / vscode-jupyter

VS Code Jupyter extension
https://marketplace.visualstudio.com/items?itemName=ms-toolsai.jupyter
MIT License
1.28k stars 287 forks source link

nested interact() doesn't work #15099

Open justinkao opened 7 months ago

justinkao commented 7 months ago

Applies To

What happened?

Created a notebook with the following code:

from ipywidgets import interact, fixed

def nested(s, n):
    print(s, n)

@interact(s=['a', 'b','c'])
def outer(s):
    interact(nested, s=fixed(s), n=7)

Expected to see a dropdown, a slider, and the output of the print(), instead only see the dropdown. Works fine in JupyterLab.

JupyterLab

Screenshot 2024-01-31 at 12 11 51 AM

VSCode

Screenshot 2024-01-31 at 12 12 08 AM

VS Code Version

1.85.2 (Universal)

Jupyter Extension Version

v2023.11.1100101639

Jupyter logs

No current configuration is defined in the workspace state. Assuming 'Default'.
No target defined in the workspace state. Assuming 'Default'.
Dropping various extension output files at /Users/justin/Library/Application Support/Code/User/workspaceStorage/115a0f8f0fff68c5179e3fb4e6ef0e84/ms-vscode.makefile-tools
Logging level: Normal
Configurations cached at /Users/justin/Library/Application Support/Code/User/workspaceStorage/115a0f8f0fff68c5179e3fb4e6ef0e84/ms-vscode.makefile-tools/configurationCache.log
No path to the makefile is defined in the settings file.
No folder path to the makefile is defined in the settings file.
Always pre-configure: false
Always post-configure: false
Dry-run switches: '--always-make', '--keep-going', '--print-directory'
No current launch configuration is set in the workspace state.
Default launch configuration: MIMode = undefined,
                    miDebuggerPath = undefined,
                    stopAtEntry = undefined,
                    symbolSearchPath = undefined
Configure on open: true
Configure on edit: true
Configure after command: true
Only .PHONY targets: false
Save before build or configure: true
Build before launch: true
Clear output before build: true
Ignore directory commands: true
compile_commands.json path: null
Deduced command 'make ' for configuration "Default"
The Makefile Tools extension process of configuring your project is about to run 'make --dry-run' in order to parse the output for useful information. This is needed to calculate accurate IntelliSense and targets information. Although in general 'make --dry-run' only lists (without executing) the operations 'make' would do in the current context, it is still possible some code to be executed, like $(shell) syntax in the makefile or recursive invocations of the $(MAKE) variable.
If you don't feel comfortable allowing this configure process and 'make --dry-run' to be invoked by the extension, you can chose a recent full, clean, verbose and up-to-date build log as an alternative, via the setting 'makefile.buildLog'.

Coding Language and Runtime Version

Python 3.9.16

Language Extension Version (if applicable)

v2023.22.1

Anaconda Version (if applicable)

No response

Running Jupyter locally or remotely?

Remote

deluksic commented 3 months ago

fwiw, I encountered the same problem with ipywidgets 8 in Cell scripts, but with 7.7.2 it still works.

DonJayamanne commented 3 months ago

Apologies for not getting back to you on this. Please can you verify you have the latest versions of VS Code and Jupyter extensions.

with ipywidgets 8 in Cell scripts, but with 7.7.2 it still works.

Please can you share more information on what you mean by cell scripts & some sample code

deluksic commented 2 months ago

Sorry, I meant code cells. Here's some sample code:

# %%
from ipywidgets import interact

@interact(x=(0, 5, 1))
def _(x=0):
    @interact(y=(x, 10, 1))
    def __(y=0):
        print(x, y)

It should show two sliders, second slider's minimum should be first slider's value.