在cc-in2p3运行的jupyter笔记本的本地显示
stackyter的Python项目详细描述
快速安装和操作方法
远程服务器上运行的Jupyter笔记本的本地显示
在本地计算机上安装stackyter的lattest版本:
pip install stackyter
如果尚未完成,请在远程主机上安装Jupyter
创建一个包含使jupyter(和其他任何东西)的指令的文件 您需要)可用(例如,mysetup.sh)
在本地计算机上运行stackyter.py:
stackyter.py --host thehost --user myusername --mysetup /path/on/the/host/mysetup.sh
将给定的url复制/粘贴到本地浏览器中以显示jupyter
目的
这个脚本允许你在远处运行jupyter笔记本(或实验室) 服务器,同时在本地浏览器中本地显示它。可以使用 任何人和任何主机上使用--host和--mysetup 选项。唯一的先决条件是jupyter必须在上可用 此脚本工作的远程主机。
安装
最新的稳定版本可以与pip:
一起安装pip install stackyter
升级到新版本:
pip install --upgrade stackyter
在本地目录中安装:
pip install --user stackyter # in your home directory pip install --prefix mypath stackyter # in 'mypath'
用法
stackyter.py [options]
然后单击由stackyter给出的绿色链接,如下所示:
Copy/paste this URL into your browser to run the notebook localy http://localhost:20001/?token=38924c48136091ade71a597218f2722dc49c669d1430db41
Ctrl-C将停止jupyter服务器并关闭连接。
您可以使用以下选项集将stackyter调整为 你的私人案件。
可选参数
在命令行上使用的选项将始终覆盖内容 对于相同选项的配置文件,如果存在的话。见 下一节介绍如何使用配置 文件。可用选项有:
-h, --help show this help message and exit -c CONFIG, --config CONFIG Name of the configuration to use, taken from your default configuration file (~/.stackyter-config.yaml or $STACKYTERCONFIG). Default if to use the 'default_config' defined in this file. The content of the configuration file will be overwritten by any given command line options. (default: None) -f CONFIGFILE, --configfile CONFIGFILE Configuration file containing a set of option values. The content of this file will be overwritten by any given command line options. (default: None) -H HOST, --host HOST Name of the target host. Allows you to connect to any host on which Jupyter is available, or to avoid conflit with the content of your $HOME/.ssh/config. (default: None) -u USERNAME, --username USERNAME Your user name on the host. If not given, ssh will try to figure it out from you ~/.ssh/config or will use your local user name. (default: None) -w WORKDIR, --workdir WORKDIR Your working directory on the host (default: None) -j JUPYTER, --jupyter JUPYTER Either launch a jupiter notebook or a jupyter lab. (default: notebook) --mysetup MYSETUP Path to a setup file (on the host) that will be used to set up the working environment. A Python installation with Jupyter must be available to make this work. (default: None) --runbefore RUNBEFORE A list of extra commands to run BEFORE sourcing your setup file. Coma separated for more than one commands, or a list in the config file. (default: None) --runafter RUNAFTER A list of extra commands to run AFTER sourcing your setup file. Coma separated for more than one commands, or a list in the config file. (default: None) -C, --compression Activate ssh compression option (-C). (default: False) -S, --showconfig Show all available configurations from your default file and exit. (default: False)
配置文件
配置字典可以包含通过 命令行。在配置文件中找到的选项将 总是被命令行覆盖。
配置文件可以以不同的方式给出,并且可以 包含从单个配置词汇到多个 配置用语:
- 配置文件可以是位于 在~/stackyter-config.yaml下或由 STACKYTERCONFIG,或在命令行中使用 --configfile选项。
- 配置名,应该在 必须使用命令行选项提供配置文件 --config。如果没有给出,则为default_config,它应该是 默认情况下,将使用配置文件中定义的。
下面是一些关于如何使用它的示例:
stackyter.py # 'default_config' in default file if it exists, default option values used otherwise stackyter.py --config config1 # 'config1' in default file which must exist stackyter.py --config config2 --configfile myfile.yaml # 'config2' in 'myfile.yaml' stackyter.py --configfile myfile.yaml # 'default_config' in 'myfile.yaml'
原则上,默认配置文件应该是这样的:
{ 'default_config': 'host1', 'host1': { 'host': 'myhost.domain.fr', # 'myhost' if you have configured your ~/.ssh/config 'jupyter': 'lab', # if installed 'username': 'myusername', 'mysetup': '/path/to/my/setup/file.sh', 'workdir': '/path/to/my/directory/' }, 'host2': { 'host': 'otherhost.fr', 'username': 'otherusername', 'mysetup': '/path/to/my/setup' }, 'host3': { 'host': 'somewhere.edu', 'username': 'ausername', # Jupyter is available by default on this host, 'mysetup' is not needed }, }
或者如果只定义了一个配置,则如下所述:
{ 'host1': { 'host': 'myhost.domain.fr', # or 'myhost' if you have configured your ~/.ssh/config file 'jupyter': 'lab', # if installed 'username': 'myusername', 'mysetup': '/path/to/my/setup/file.sh', 'workdir': '/path/to/my/directory/' }, }
您可以使用example 配置文件作为模板创建自己的。你也可以找到 configs中的几个示例配置文件 不同用户案例的目录。
远程主机配置
--host选项允许您连接到任何远程主机。这个 用于创建ssh隧道的默认选项是-X-Y-tt-L。如果要配置ssh连接,请编辑 ~/.ssh/config文件,例如,使用以下模板:
Host myjupyter Hostname thehostname User myusername GSSAPIClientIdentity myusername@HOST GSSAPIAuthentication yes GSSAPIDelegateCredentials yes GSSAPITrustDns yes
ypu只需要替换thehostname,myusername,和 myusername@HOST通过适当的值。然后你可以使用 stackyter脚本如下:
stackyter.py --host myjupyter
或者在你的 config.yaml文件。
工作环境
有几种方法可以设置你的个人工作环境, 使用--mysetup、--runbefore和runafter 选项。如果设置文件位于远程主机上,则可以 简单地做:
stackyter.py --mysetup /path/to/my/setup.sh (--username myusername)
您的本地设置文件将在连接处获得,如下所示:
source /path/to/my/setup.sh
runbefore和runafter选项允许您分别 运行命令行在获取安装文件之前或之后。它可以 如果需要通过 环境变量,或在源代码之后添加额外的命令。
您的设置必须至少包含 Jupyter可用。如果jupyter在远程服务器上默认可用 主机(可能是在连接时设置的),您只需要使用 ^运行{tt4}$和--username选项。
你当然可以用这三种方法添加任何个人设置 选项,与不属于Jupyter相关。
帮助
- 如果你有任何意见或建议,或者你发现了一个bug, 请使用专用的githubissue tracker。
- 为什么stakyter?由于历史原因:stackyter=lsst stack+Jupyter。最初是为LSST成员准备的 轻松使用lsst软件堆栈并与数据集交互。