有一个带有 Jupyterhub 的服务器。它可以通过浏览器进行远程访问(仅限 IP 地址)。用户可以使用 ipywidgets.fileupload 上传大文件(几 GB)。但是我通常不能上传超过 100MB 的文件:文件大约 200MB 上传约 10 分钟。 (scp 命令 - 少于 2 分钟。)。文件超过 250MB - 以内核错误结尾(但带有“--debug”的 jupyterhub 不显示任何内容)。
浏览器控制台错误:
API request failed (0): error
:8000/user/aleksandr/api/contents/Untitled1.ipynb:1 Failed to load resource: net::ERR_EMPTY_RESPONSE
main.min.js?v=eef572336006937e9a017afbdebc65fe:24805 Uncaught (in promise) XhrError: error
at wrap_ajax_error (http://192.168.1.49:8000/user/aleksandr/static/notebook/js/main.min.js?v=eef572336006937e9a017afbdebc65fe:24805:29)
at Object.settings.error (http://192.168.1.49:8000/user/aleksandr/static/notebook/js/main.min.js?v=eef572336006937e9a017afbdebc65fe:24861:24)
at u (http://192.168.1.49:8000/user/aleksandr/static/notebook/js/main.min.js?v=eef572336006937e9a017afbdebc65fe:2:27457)
at Object.fireWith [as rejectWith] (http://192.168.1.49:8000/user/aleksandr/static/notebook/js/main.min.js?v=eef572336006937e9a017afbdebc65fe:2:28202)
at k (http://192.168.1.49:8000/user/aleksandr/static/notebook/js/main.min.js?v=eef572336006937e9a017afbdebc65fe:2:77676)
at XMLHttpRequest.<anonymous> (http://192.168.1.49:8000/user/aleksandr/static/notebook/js/main.min.js?v=eef572336006937e9a017afbdebc65fe:2:79882)
wrap_ajax_error @ main.min.js?v=eef572336006937e9a017afbdebc65fe:24805
settings.error @ main.min.js?v=eef572336006937e9a017afbdebc65fe:24861
u @ main.min.js?v=eef572336006937e9a017afbdebc65fe:2
fireWith @ main.min.js?v=eef572336006937e9a017afbdebc65fe:2
k @ main.min.js?v=eef572336006937e9a017afbdebc65fe:2
(anonymous) @ main.min.js?v=eef572336006937e9a017afbdebc65fe:2
部分源码:
import ipywidgets as widgets
def ff(b):
s.style.button_color = "yellow"
for elem in b.new.values():
print(elem['metadata']['name'])
with open(elem['metadata']['name'], 'wb') as file:
file.write( elem['content'])
print("Done")
s.style.button_color = "lightgreen"
s = widgets.FileUpload(
accept='', # Accepted file extension e.g. '.txt', '.pdf', 'image/*', 'image/*,.pdf'
multiple=True # True to accept multiple files upload else False
)
s.style.button_color = "lightgreen"
s.observe(ff, names='value')
s
卡住时,不执行“ff”功能。
我使用:
一些 Action :
据此:https://github.com/jupyter-widgets/ipywidgets/issues/2522 ,我在 jupyer_config.py 里改了:
c.Spawner.args=['--SingleUserNotebookApp.tornado_settings = {"websocket_max_message_size": 1073741824}']
在用户笔记本启动时执行。和:
c.JupyterHub.tornado_settings= {"websocket_max_message_size": 1073741824}}
一般来说,更改这些字段不会影响问题的状态。
是否可以通过 ipywidgets.fileupload 以正常速度上传大文件?
最佳答案
该问题的解决方案在 Jupyter 社区中仍然是一个悬而未决的问题。
但是有一个解决方法 可用,即增加 tornado 支持的 websocket 消息大小。
请引用这个link .
关于python - 如何使用 ipywidgets fileupload 上传大文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58158779/