安装Jupyterhub /实验室的Git扩展时的注意事项


介绍

当我在Jupyterhub / lab中放置Git扩展名时,我有点卡住了,所以当时给自己的备忘录。
另外,请参考此处以安装和启动Jupyterhub /实验室。

环境

1
2
3
4
$sw_vers
ProductName:    Mac OS X
ProductVersion: 10.13.6
BuildVersion:   17G14042
1
2
$docker --version
Docker version 20.10.0, build 7287ab3

要做的事情

向Jupyterhub /实验室介绍Git扩展。

我做了什么

对于Jupyterlab 3.0.7

首先,从docker获取Jupyterhub的映像并启动它。

1
docker run -d -p 8000:8000 --name jupyterhub jupyterhub/jupyterhub jupyterhub

我们将在这里进行设置。

1
2
3
4
5
6
7
8
apt update
apt install python3 python3-pip npm nodejs libnode64 vim git
npm install -g configurable-http-proxy
pip3 install -U pip
pip3 install jupyterlab==2.2.9
pip3 install jupyterlab-git==0.23.3
jupyterhub --generate-config
vim jupyterhub_config.py

将以下内容添加到jupyterhub_config.py。

jupyterhub_config

1
2
3
4
c.Spawner.default_url = '/lab'
c.Spawner.notebook_dir = '~/notebook'
c.Authenticator.admin_users = {'testadmin'}
c.Authenticator.allowed_users = {'testuser01'}

创建一个用于登录的用户。

1
2
3
4
5
6
adduser testadmin
mkdir -p -m 777 /home/testadmin/notebook
chown testadmin: /home/testadmin/notebook
adduser testuser01
mkdir -p -m 777 /home/testuser01/notebook
chown testuser01: /home/testuser01/notebook

在开始之前检查每个库的版本。

1
2
3
4
5
6
7
8
9
10
11
root@62ecd14f5e8a:/srv/jupyterhub# jupyterhub --version
1.3.0
root@62ecd14f5e8a:/srv/jupyterhub# jupyter-lab --version
3.0.7
root@62ecd14f5e8a:/srv/jupyterhub# python3
Python 3.8.5 (default, Jul 28 2020, 12:59:40)
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from  jupyterlab_git import __version__ as ver
>>> print(ver)
0.23.3

在这里启动Jupyterhub。

1
jupyterhub jupyterhub_config.py

但是,Git扩展无法正常工作。

jupyterlab-git-try01.png

当您检查Jupyterlab-git的文档时,它说您应该检查服务器端和正面的扩展名,因此请首先检查服务器端的扩展名。

1
2
3
4
5
6
7
8
9
10
11
12
root@62ecd14f5e8a:/srv/jupyterhub# jupyter server extension list
Config dir: /root/.jupyter

Config dir: /usr/etc/jupyter

Config dir: /usr/local/etc/jupyter
    jupyterlab enabled
    - Validating jupyterlab...
      jupyterlab 3.0.7 OK
    nbclassic enabled
    - Validating nbclassic...
      nbclassic  OK

我找不到Git扩展名,所以启用jupyterlab-git。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
root@62ecd14f5e8a:/srv/jupyterhub# jupyter server extension enable --py jupyterlab_git
Enabling: jupyterlab_git
- Writing config: /usr/etc/jupyter
    - Validating jupyterlab_git...
      jupyterlab_git 0.23.3 OK
    - Extension successfully enabled.
root@62ecd14f5e8a:/srv/jupyterhub# jupyter server extension list
Config dir: /root/.jupyter

Config dir: /usr/etc/jupyter
    jupyterlab_git enabled
    - Validating jupyterlab_git...
      jupyterlab_git 0.23.3 OK

Config dir: /usr/local/etc/jupyter
    jupyterlab enabled
    - Validating jupyterlab...
      jupyterlab 3.0.7 OK
    nbclassic enabled
    - Validating nbclassic...
      nbclassic  OK

接下来,检查正面的扩展名。

1
2
3
4
5
6
7
8
9
10
11
12
root@62ecd14f5e8a:/srv/jupyterhub# jupyter labextension list
JupyterLab v3.0.7
Other labextensions (built into JupyterLab)
   app dir: /usr/local/share/jupyter/lab
        @jupyterlab/git v0.23.3 enabled  X
        nbdime-jupyterlab v2.0.1 enabled  X

   The following extension are outdated:
        @jupyterlab/git
        nbdime-jupyterlab

   Consider running "jupyter labextension update --all" to check for updates.

Git扩展名已过时,因此请对其进行更新。

1
2
3
4
root@62ecd14f5e8a:/srv/jupyterhub# jupyter labextension update --all
An error occured.
ValueError: Please install nodejs >=12.0.0 before continuing. nodejs may be installed using conda or directly from the nodejs website.
See the log file for details:  /tmp/jupyterlab-debug-n1cjjsd7.log

在这里,发生错误。您将升级nodejs的版本。请参阅此处,并将nodejs升级到12。

1
2
curl -fsSL https://deb.nodesource.com/setup_12.x | bash -
apt-get install -y nodejs

然后提高扩展版本。

1
2
3
4
root@62ecd14f5e8a:/srv/jupyterhub# jupyter labextension update --all
Updating nbdime-jupyterlab to version 2.1.0-beta.1
Updating @jupyterlab/git to version 0.30.0-beta.2
Building jupyterlab assets (production, minimized)

再次检查正面的扩展名。

1
2
3
4
5
6
root@62ecd14f5e8a:/srv/jupyterhub# jupyter labextension list
JupyterLab v3.0.7
Other labextensions (built into JupyterLab)
   app dir: /usr/local/share/jupyter/lab
        @jupyterlab/git v0.30.0-beta.2 enabled OK
        nbdime-jupyterlab v2.1.0-beta.1 enabled OK

Jupyterlab-git已从0.23.3更新到0.30.0-beta.2。
查看发行信息,似乎0.30.0b1与Jupyterlab版本3兼容。但是,从2021年2月18日起,如果未使用pip install指定版本,则将安装0.23.3,因此它似乎已过时。

接下来,在服务器端升级版本。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
root@62ecd14f5e8a:/srv/jupyterhub# pip3 install jupyterlab-git==0.30.0b2
root@62ecd14f5e8a:/srv/jupyterhub# jupyter server extension list
Config dir: /root/.jupyter

Config dir: /usr/etc/jupyter
    jupyterlab_git enabled
    - Validating jupyterlab_git...
      jupyterlab_git 0.30.0b2 OK

Config dir: /usr/local/etc/jupyter
    jupyterlab enabled
    - Validating jupyterlab...
      jupyterlab 3.0.7 OK
    jupyterlab_git enabled
    - Validating jupyterlab_git...
      jupyterlab_git 0.30.0b2 OK
    nbclassic enabled
    - Validating nbclassic...
      nbclassic  OK
    nbdime enabled
    - Validating nbdime...
      nbdime 3.0.0.b1 OK

启动Jupyterhub。

1
jupyterhub jupyterhub_config.py

显示

Git按钮,它起作用了。

jupyterlab-git-sucseed_13.png

对于Jupyterlab 2.2.9

Git扩展仍处于beta中,因此我正在考虑使用0.23.3稳定版本,并且我将尝试兼容的Jupyterlab 2系列。我还尝试了先前版本1.2系列的最新版本的Jupyterhub。
根据Docker页面,1.2.2是最后一个版本,所以让我们使用它。
另外,Jupyterlab将尝试使用同时发布的2.2.9(有关详细信息,请参见官方文档)。

在下面,以相同的方式启动和设置。

1
docker run -it -p 8000:8000 --name jupyterhub122 jupyterhub/jupyterhub:1.2.2 bash
1
2
3
4
5
6
7
8
apt update
apt install python3 python3-pip npm nodejs libnode64 vim git
npm install -g configurable-http-proxy
pip3 install -U pip
pip3 install jupyterlab==2.2.9
pip3 install jupyterlab-git==0.23.3
jupyterhub --generate-config
vim jupyterhub_config.py

jupyterhub_config

1
2
3
4
c.Spawner.default_url = '/lab'
c.Spawner.notebook_dir = '~/notebook'
c.Authenticator.admin_users = {'testadmin'}
c.Authenticator.allowed_users = {'testuser01'}
1
2
3
4
5
6
adduser testadmin
mkdir -p -m 777 /home/testadmin/notebook
chown testadmin: /home/testadmin/notebook
adduser testuser01
mkdir -p -m 777 /home/testuser01/notebook
chown testuser01: /home/testuser01/notebook

在Jupyterlab 2系列中,在开始之前进行构建。

1
jupyter lab build

构建完成后启动Jupyterhub。

1
jupyterhub jupyterhub_config.py

这是一个平滑的扩展。

jupyterlab-git-sucseed.png

概括

  • 对于Jupyterlab 3.0.7

    • Jupyterlab-git为前端和服务器均指定0.30.02b(或更高)(我尝试了0.30.01b,但没有用)
    • 需要将nodejs更新到12或以上
  • 对于Jupyterlab 2.2.9

    • Jupyterlab-git可以使用0.23.3确定
    • 必须在启动之前构建

参考文章等

https://qiita.com/TaigoKuriyama/items/2d0280b0e732fd9cff8f