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

ipywidgets: implement buffers from client to server #6022

Closed
williamstein opened this issue Jun 28, 2022 · 1 comment
Closed

ipywidgets: implement buffers from client to server #6022

williamstein opened this issue Jun 28, 2022 · 1 comment

Comments

@williamstein
Copy link
Contributor

For example, I think the FileUpload widget uses this:

import ipywidgets as widgets

w = widgets.FileUpload(
    accept='',  # Accepted file extension e.g. '.txt', '.pdf', 'image/*', 'image/*,.pdf'
    multiple=False  # True to accept multiple files upload else False
)

---

w

---

w.metadata

All the client stuff works, but the file isn't actually uploaded and created in the project. Vidar says this is probably because I haven't implemented Buffer's for sending data from the client to the server (only the other way around). See also

#6011

NOTE: Interestingly the ipywidgets 8.x release will change the FileUpload API... but that shouldn't impact this: https://github.com/jupyter-widgets/ipywidgets/pull/3501/files#diff-96c1cb3714b9750f89a64c05634b5559ad20428416dc64aab026ce4b6212341d

@williamstein
Copy link
Contributor Author

Binary buffers from client to server are now supported, even with compute servers. That said, for FileUpload right now make sure you upgrade to the 8.x version of ipywidgets:

pip install ipywidgets==8.1.3

since that what we are using on the frontend and the protocol changed (so 7.x fileupload won't work). And obviously restart your project if it has been running forever, and refresh your browser. Then:

image
import ipywidgets as widgets
print(widgets.__version__)
w = widgets.FileUpload(accept='.png', multiple=True); w
print(w.value)
widgets.Image(value=w.value[0].content.tobytes())

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

No branches or pull requests

1 participant