okdistribute / jupyter-kernel-watch

Watches a jupyter kernel for you. Emits events when things are changed!
2 stars 0 forks source link

jupyter-kernel-watch

Watches jupyter kernel directories for you.

NPM

| Travis

var KernelWatch = require('jupyter-kernel-watch')
var watcher = KernelWatch(['/path/to/kernels', '/another/path/to/.jupyter/kernels'])

watcher.on('data', function (kernelSpecs) {
  // kernelSpecs is a list of the contents of the kernel.json as a JSON object
  // e.g. [
  // {
  //   "filepath": "/path/to/kernels/python/kernel.json",
  //   "data": { "display_name": "Python 2", "language": "python", "argv": [ etc...]}
  //  }
  // ]
  //
})

watcher.close()

API

KernelWatch(dirs)

Returns a watcher

dirs: the directories to watch

watcher.close()

Closes the watcher -- stops watching the filesystem.

Events

There should be more, but right now it just emits one event -- that's when the kernel spec (kernel.json) has changed.

kernelspecs

watcher.on('data', function (kernelSpecs) {
  // list of kernelspecs
})