【发布时间】:2021-10-06 03:34:48
【问题描述】:
我有一个支持 python 语言的 jupyter 服务器。我已经创建了带有打印语句的 jupyter 笔记本,并将该笔记本下载到我的本地计算机上。 现在我必须读取本地存储的笔记本的内容,并使用 jupyter 服务器 rest api 调用上传到正在运行的 jupyter 服务器。 我更喜欢 java 编程语言来与 jupyter 服务器 rest api 调用交互以上传笔记本内容。
问题:我可以通过准备请求中预期的请求正文来读取内容并调用 jupyter 服务器 api。 我正在调用jupyter服务器的这个api:PUT:{base_url}/api/contents/a.ipynb
请求正文:
log.info("jsonNode string : "+jsonNode);
JSONObject modelRequest = new JSONObject();
modelRequest.put("name", "a.ipynb");
modelRequest.put("path", "");
modelRequest.put("type","notebook");
modelRequest.put("format","json");
modelRequest.put("mimetype","None");
modelRequest.put("content",new JSONObject(jsonNode.toPrettyString()));
modelRequest.put("writable","True");
log.info("json model object : "+modelRequest);
我尝试上传不同格式的内容键值,如 String、JSONObject、json String 等,但我无法成功上传 jupyter 服务器笔记本中的内容。 我看到笔记本正在创建,但内容为空。实际上,我希望内容密钥中传递的数据应该被上传,我应该在 jupyter 服务器的笔记本中看到。
任何人在java中有任何想法或线索或实现,我该如何实现? 我正在关注 jupyter server rest api 文档, https://jupyter-server.readthedocs.io/en/latest/developers/rest-api.html https://petstore.swagger.io/?url=https://raw.githubusercontent.com/jupyter/jupyter_server/master/jupyter_server/services/api/api.yaml
【问题讨论】:
标签: java jupyter-notebook jupyter