2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Jupyterプロセスの管理

Last updated at Posted at 2020-07-07

課題

起動済みのJupyterにブラウザでアクセスするためには、そのJupyterがつながっているポート番号と、アクセストークンが必要になる。これらは、Jupyterプロセスの標準エラーに出力されるログに記載されている。Jupyterにアクセスする度に、この情報を端末やログファイルから探し出すのが面倒なので、これらを管理するコマンドjmanagerを作成した。

インストール

pip install jmanager

使い方

jupyterを使いたいディレクトリで

$ jmanager

を実行する。この時、既にカレントディレクトリから起動済みのjupyterサーバーがあれば、それに接続し、なければ新しいjupyterサーバーを立ち上げる。

仕組み

初回実行時に、ポート・トークン・プロセスIDをローカルのjupyter.pidファイルに保存する。この時、単純にjupyterサーバーを立ち上げるだけではなく、サーバープロセスの終了を待つプロセスも同時に作成し、サーバープロセス終了時にjupyter.pidファイルを削除する。

ソース

コマンドラインオプション

COMMANDを省略すると、runが選ばれる。

$ jmanager --help
Usage: jmanager [OPTIONS] COMMAND [ARGS]...

Options:
  --help  Show this message and exit.

Commands:
  ignore  Print lines for .gitignore
  kill    Terminate jupyter process
  run     Launch new jupyter or connect to existing one.
2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?