-
Notifications
You must be signed in to change notification settings - Fork 64
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
Displaying ipycanvas in google colab? #170
Comments
Hello! Thanks for opening an issue. Custom widgets libraries are not supported by Google colab yet, you can follow the discussion here: googlecolab/colabtools#60 |
Alright, thank you for the quick answer! |
Note that it should work in Jupyter Notebook, JupyterLab, Voila, Pycharm and VSCode though, maybe on more platforms that I am not aware of :) |
Thank you! Unfortunately we recommended Colab to the students who couldn't install stuff in their computers when we opened this lecture about 4 months ago, so now we're stuck with that decision until the end of the course :-P Not doing that mistake again next year :-D |
Also apparently the correct issue on googlecolab about custom widget libraries is now on googlecolab/colabtools#498 |
A helpful related discussion about not trying to build support for proprietary colab APIs one by one into jupyter extensions cytoscape/ipycytoscape#148 |
There is some update about this on https://github.com/googlecolab/colabtools. For short, they are working on experimental support for custom widgets. Some working examples using ipyleaflet, ipympl or qgrid are already available! I think that would be awesome if The proposal for the API is in: https://github.com/googlecolab/colab-cdn-widget-manager On mne-tools/mne-python, we rely on output.mp4Related to mne-tools/mne-python#8080 (comment) |
Thanks for commenting @GuillaumeFavelier :) Did you give it a try in Colab? If ipympl and ipyleaflet are working, I am hoping that ipycanvas could work out of the box now! EDIT: display(Javascript('''
google.colab.widgets.installCustomManager('https://ssl.gstatic.com/colaboratory-static/widgets/colab-cdn-widget-manager/6a14374f468a145a/manager.min.js');
''')) |
Yes! I tried the
But unfortunately, I did not get any output except the displayed time (we expect the clock to appear). I shared the results of my experiment in mne-tools/mne-python#8080 (comment) |
Ok, thanks for trying. There might be a useful error showing up in the JavaScript console when trying that. If you can report what you see it would be great, otherwise I will give it a try myself 😃 |
Thanks. I am seing the same when trying to draw something on the canvas, I will open an issue on Colab and we can follow there. |
ipycanvas seems to work very nicely with Colab now thanks to @blois 's amazing work! !pip install -q ipycanvas
from google.colab import output
output.enable_custom_widget_manager()
from ipycanvas import Canvas
testipycanvas = Canvas(width = 20, height = 20)
testipycanvas.fill_style = "green"
testipycanvas.fill_rect(0,0,20)
display(testipycanvas) |
Awesome news, I can't wait to try it out 🚀 |
hi friends, i am excited about this new feature but I believe am getting the issue mentioned above, where my output area is sized adaptively for the canvas dimensions but doesn't actually draw the canvas, with no error message. I created this notebook in january- is there a chance there is some versioning/state associated with my notebook that is preventing me from using the new feature? thank you for this great product! |
I'm seeing this happen on the second execution of the cell- if I restart the runtime then it works for the first execution but then not the second. Will try to dig in but nothing comes to mind that would be causing this. |
Having the same issue. Only thing I see in console is |
I found that when I change my line to
the canvas works, and does not vanish on subsequent runs of the cell. Even in this case I also get the error |
@blois the new ipycanvas version needs a |
Opened googlecolab/colab-cdn-widget-manager#24 this sounds similar to jslink which currently has a sort of one-off approach. |
Thanks a lot @blois |
For anyone having issues with ipycanvas in Colab, please downgrade to
|
Hey, @martinRenou, is there any fix that would allow me to take advantage of the performance improvements with |
Unfortunately, even downgrading ipycanvas to v11 still seems to have some problems in Google Colab. In the example below, shown in VS Code, I draw a green square onto the canvas in the first cell, then can display the same canvas again in the next cell, and finally target both the canvases to draw a small blue square from the final cell: However, when I try the same thing from Colab, the second cell doesn't display the green square, yet strangely the blue square does get drawn to both canvases. Here's the same code in Colab: As you can see, the green square wasn't drawn when the second cell just tried to show the canvas. Is there any way to work around this, as Colab seems to be a bit hit-or-miss when it actually comes to showing the canvas? |
Unfortunately, it's unlikely the behavior you are describing here will be fixed. You can probably workaround this behavior by passing canvas = Canvas(sync_image_data=True) This parameter makes the actual pixels part of the widget model, syncing those pixels between canvas views with best effort. |
It seems that even with
In this example, taken from the documentation of copying from one canvas to another, the canvas copy doesn't work. When displaying 'canvas2' it only shows a coloured rectangle. Whereas 'canvas' shows the canvas with image, so it appears that it hasn't been able to copy from one canvas to the other. Would you know if there's anyway to get this to work? |
You are describing another example use-case here. If you want you can open your own issue to not pollute this one. I'd be happy to help you there. |
Hello! I'm preparing a tutorial using ipycanvas, and while it works perfectly in my local jupyter installation, I can't get the same code to display in google colab (for remote students).
I know this is much more likely to be a google colab issue than a ipycanvas issue, but I was wondering if you know any workarounds from experience?
This is the code that I'm trying to run.
(I have already !pip install'ed the module with no errors. The code above gives me a blank output with no error messages)
The text was updated successfully, but these errors were encountered: