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

Not working in JupyterLab or Visual Studio Code (only in hosted Jupyter Notebook) #5

Closed
opoloko opened this issue May 19, 2020 · 4 comments

Comments

@opoloko
Copy link

opoloko commented May 19, 2020

I find this module super useful, very elegant and quick solution, but can't get it to work in Jupyter Lab (<IPython.core.display.Javascript object> error in console) or Visual Studio Code (no errors).

Do you have any clue what I could try?

@kafonek
Copy link
Owner

kafonek commented May 20, 2020

@opoloko thanks for flagging this, I haven't done any extensive testing with JupyterLab or VSCode. After a bit of cursory fiddling this evening, I'm leaning towards the issue being with magic commands (%block, %blockrun) working differently in JupyterLab / VSCode versus classic Notebook.

I was able to get this minimal example to work with expected behavior in Jupyterlab:

### cell 1
import ipywidgets as widgets

dropdown = widgets.Dropdown(options=['', 'foo', 'bar', 'baz'])
dropdown

### cell 2
import ipython_blocking
ctx = ipython_blocking.CaptureExecution()
with ctx:     
    while True:
        if dropdown.value:
            break
        ctx.step()

### cell 3
print("just a string to demonstrate blocking until dropdown changes")

### cell 4
print(dropdown.value)

After a cell -> run all, cells 3 and 4 didn't execute until after I chose an option in the dropdown widget.

I haven't spent a lot of time looking at IPython magic commands outside of classic Notebook. If you have any leads on the differences between classic vs Lab/VSCode, I'd appreciate pointers. Thanks.

@bryceschober
Copy link

Me too, FWIW...

@kafonek
Copy link
Owner

kafonek commented Oct 2, 2020

@bryceschober I'm afraid I'm having trouble replicating these errors. I just ran the 4-cell example code in both a VSCode (centos7 / python 3.6 / VSCode Python extension) and JupyterLab (Lab 2.2.5, using docker-stacks image, installed @jupyter-widgets from extension manager).

Can you give any more details about system or versions that aren't working for you? Thanks.

@bryceschober
Copy link

@kafonek Hey, I guess you're right. I must have been doing something else wrong, because I switched a separate notebook to %block dropdown and it does work... You can go ahead and close this case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants