前提・実現したいこと
Jupyterのメニューから『Cell ⇒ All Output ⇒ Clear』を選択し、
outputのcellを全て消す挙動をショートカットで実現したいです。
Dockerを使っており、永続化のため、
『Help ⇒ Edit Keyboard ShortCuts』からではなく、
~/.jupyter/custom/custom.js
に追記する形で実現する方法を教えてください。
なお、以下のコマンドにてbuildとコンテナの起動を行っています。
build docker-compose build --no-cache
起動 docker-compose up -d
発生している問題・エラーメッセージ
エラーメッセージ
該当のソースコード
Dockerfile
1FROM jupyter/datascience-notebook:latest 2ENV container docker 3 4USER jovyan 5COPY --chown=jovyan:users custom.js /home/jovyan/.jupyter/custom/ 6COPY --chown=jovyan:users jupyter_notebook_config.py /home/jovyan/.jupyter
dockercompose
1version: '3.3' 2 3services: 4 jupyter: 5 image: datascience:01 6 build: 7 dockerfile: ./Dockerfile 8 context: . 9 command: start-notebook.sh --NotebookApp.password=${JUPYTER_PASSWORD} 10 hostname: jupyter 11 restart: always 12 ports: 13 - 8888:8888 14 volumes: 15 - ~/work/jupyter:/home/jovyan/work 16 tty: true 17 environment: 18 - TZ
custom.js
js
1Jupyter.keyboard_manager.command_shortcuts.add_shortcut('shift-x', 2 function(event) { 3 IPython.notebook.execute_all_cells(); 4 return false; 5 } 6); 7 8Jupyter.keyboard_manager.command_shortcuts.add_shortcut('ctrl-x', 9 function(event) { 10 IPython.notebook.kernel.restart(); 11 setTimeout(function(){ IPython.notebook.execute_all_cells(); }, 100); 12 return false; 13 } 14);
試したこと
現状ではcustom.js
の設定により、メニューから『Cell ⇒ All Run』の挙動はShift-x
のショートカットにて実現できています。
補足情報(FW/ツールのバージョンなど)
$JUPYTER_PASSWORD
については以下を参考にして環境変数に設定しました。
Dockerで基本的なData Science環境(Jupyter, Python, R, Julia, 定番ライブラリ)を構築する。
具体的には、
python -c 'from notebook.auth import passwd;print(passwd())'
を実行し、
「sha1:〜」のようなhashが表示されるので$JUPYTER_PASSWORD
に設定する。
docker info
Containers: 1
Running: 1
Paused: 0
Stopped: 0
Images: 60
Server Version: 18.06.1-ce
Storage Driver: overlay2
Backing Filesystem: extfs
Supports d_type: true
Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: bridge host macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 468a545b9edcd5932818eb9de8e72413e616e86e
runc version: 69663f0bd4b60df09991c08812a60108003fa340
init version: fec3683
Security Options:
apparmor
seccomp
Profile: default
Kernel Version: 4.4.0-134-generic
Operating System: Ubuntu 16.04.5 LTS
OSType: linux
Architecture: x86_64
CPUs: 4
Total Memory: 3.33GiB
ID: IQX3:MTCR:L2ZV:5LU7:WT2A:XSRM:PH6E:NZWO:R55Q:SQJT:J5FS:P224
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
WARNING: No swap limit support
あなたの回答
tips
プレビュー