如何与非程序员共享Jupyter笔记本?[关闭]

问题:如何与非程序员共享Jupyter笔记本?[关闭]

我试图用Jupyter做我不能做的事情。

我的内部服务器上运行着Jupyter服务器,可通过VPN和受密码保护的服务器进行访问。

我是唯一实际创建笔记本的人,但是我想以只读方式使其他团队成员可以看到一些笔记本。理想情况下,我可以与他们共享一个URL,当他们希望查看带有刷新数据的笔记本时,他们将为其添加书签。

我看到了导出选项,但找不到任何有关“发布”或“公开”本地现场笔记本的信息。这不可能吗?考虑应该如何使用Jupyter可能只是错误的方式?

I am trying to wrap my head around what I can/cannot do with Jupyter.

I have a Jupyter server running on our internal server, accessible via VPN and password protected.

I am the only one actually creating notebooks but I would like to make some notebooks visible to other team members in a read-only way. Ideally I could just share a URL with them that they would bookmark for when they want to see the notebook with refreshed data.

I saw export options but cannot find any mention of “publishing” or “making public” local live notebooks. Is this impossible? Is it maybe just a wrong way to think about how Jupyter should be used?


回答 0

共享Jupyter笔记本的“最佳”方法是将其放置在GitHub(直接查看)或其他公共链接上,然后使用Jupyter Notebook Viewer。当隐私更多是一个问题时,可以有其他选择,但肯定会更复杂。仅Jupyter并没有内置的方法来执行此操作,但是有两个选项:

托管您自己的nbviewer

GitHub和Jupyter Notebook Veiwer都使用相同的工具将.ipynb文件呈现为静态HTML,此工具为nbviewer

安装说明比我愿意介绍的要复杂,但是如果您的公司/团队拥有不需要密码访问的共享服务器,则可以在该服务器上托管nbviewer并指示其从您的凭据服务器加载。这可能需要比您将在文档中找到的配置更高级的配置。

设置部署脚本

如果您不一定需要实时更新HTML,则可以在有证书的服务器上设置一个脚本,该脚本将仅使用Jupyter的内置导出选项来创建静态HTML文件,然后将其发送到更易于访问的服务器上。

The “best” way to share a Jupyter notebook is to simply to place it on GitHub (and view it directly) or some other public link and use the Jupyter Notebook Viewer. When privacy is more of an issue then there are alternatives but it’s certainly more complex; there’s no built-in way to do this in Jupyter alone, but a couple of options are:

Host your own nbviewer

GitHub and the Jupyter Notebook Veiwer both use the same tool to render .ipynb files into static HTML, this tool is nbviewer.

The installation instructions are more complex than I’m willing to go into here but if your company/team has a shared server that doesn’t require password access then you could host the nbviewer on that server and direct it to load from your credentialed server. This will probably require some more advanced configuration than you’re going to find in the docs.

Set up a deployment script

If you don’t necessarily need live updating HTML then you could set up a script on your credentialed server that will simply use Jupyter’s built-in export options to create the static HTML files and then send those to a more publicly accessible server.


回答 1

Google最近公开了其内部协作项目(此处链接)。您可以使用与启动Google表格或Google文档相同的方式来启动笔记本,然后简单地共享笔记本或添加协作者。

目前,这对我来说是最简单的方法。

Google has recently made public its internal Collaboratory project (link here). You can start a notebook in the same way as starting a Google Sheet or Google Doc, and then simply share the notebook or add collaborators..

For now, this is the easiest way for me.


回答 2

迈克尔建议运行自己的nbviewer实例是我过去在Enterprise Github服务器上使用的一个很好的建议。

另一个轻量级替代方法是在笔记本的末尾有一个单元格,该单元格对nbconvert进行shell调用,以便在运行整个过程后自动刷新该单元格:

!ipython nbconvert <notebook name>.ipynb --to html

编辑:使用Jupyter / IPython的Big Split,您可能需要将其更改为!jupyter nbconvert <notebook name>.ipynb --to html现在。

Michael’s suggestion of running your own nbviewer instance is a good one I used in the past with an Enterprise Github server.

Another lightweight alternative is to have a cell at the end of your notebook that does a shell call to nbconvert so that it’s automatically refreshed after running the whole thing:

!ipython nbconvert <notebook name>.ipynb --to html

EDIT: With Jupyter/IPython’s Big Split, you’ll probably want to change this to !jupyter nbconvert <notebook name>.ipynb --to html now.


回答 3

这取决于您打算如何使用笔记本电脑:您是否希望用户可以重新计算结果或只是玩游戏?

静态笔记本

NBViewer是一个很棒的工具。您可以在Jupyter中直接使用它。Github也有一个渲染器,因此您可以直接链接文件(例如https://github.com/my-name/my-repo/blob/master/mynotebook.ipynb

活着的笔记本

如果希望用户能够重新计算某些部分,则也可以使用MyBinder。启动笔记本需要花费一些时间,但是这样做值得。

正如@Mapl称,谷歌可以承载您的笔记本Colab。一项不错的功能是通过GPU计算单元。

It depends on what you are intending to do with your Notebook: do you want that the user can recompute the results or just playing with them?

Static notebook

NBViewer is a great tool. You can directly use it inside Jupyter. Github has also a render, so you can directly link your file (such as https://github.com/my-name/my-repo/blob/master/mynotebook.ipynb)

Alive notebook

If you want your user to be able to recompute some parts, you can also use MyBinder. It takes some time to start your notebook, but the result is worth it.

As said by @Mapl, Google can host your notebook with Colab. A nice feature is to compute your cells over a GPU.


回答 4

在WordPress上执行此操作的一种好方法包括以下步骤:

步骤1:在文本编辑器中打开Jupyter笔记本,然后复制内容,如下所示: 在文本编辑器中打开您的.ipynb文件时,可能看起来像这样

步骤2: 按Ctrl + ACtrl + C此内容。然后按Ctrl + V到您应该创建的GitHub Gist。

第3步:创建公共要点,然后像通常将要点要嵌入到WordPress一样,将要点嵌入,请转到HTML编辑器并按如下所示添加:

[gist gist_url]

我实际上已经在我的博客上实现了此功能。你可以在这里找到帖子

A great way of doing this on WordPress consists of the following steps:

Step 1: Open your Jupyter notebook in a text editor and copy the content which may look like so: Your .ipynb file may look like this when opened in a text editor

Step 2: Ctrl + A and Ctrl + C this content. Then Ctrl + V this to a GitHub Gist that you should create.

Step 3: Create a public gist and embed the gist like you always embed gists on WordPress, viz., go to the HTML editor and add like so:

[gist gist_url]

I have actually implemented this on my blog. You can find the post here


回答 5

实现此目标的一种方法是使用JupyterHub

使用JupyterHub,您可以创建一个多用户中心,该中心可以生成,管理和代理单用户Jupyter笔记本服务器的多个实例。由于其灵活性和定制选项,JupyterHub可用于为学生,公司数据科学小组或科研小组的笔记本电脑提供服务。

One more way to achieve this goal would be using JupyterHub.

With JupyterHub you can create a multi-user Hub which spawns, manages, and proxies multiple instances of the single-user Jupyter notebook server. Due to its flexibility and customization options, JupyterHub can be used to serve notebooks to a class of students, a corporate data science group, or a scientific research group.