nteract / jupyter-paths

:city_sunrise: Pure JavaScript implementation of jupyter --paths --json
BSD 3-Clause "New" or "Revised" License
9 stars 11 forks source link

Expose higher level interfaces #1

Closed rgbkrk closed 8 years ago

rgbkrk commented 9 years ago

The Jupyter ecosystem has defined protocols for:

The kinds of things a front end for Jupyter needs to ask for are:

If it's for a notebook app or Hydrogen within Atom, it needs to know about all the kernel runtimes it has started. Typically this is through a kernel manager (in the Python Jupyter code).

Per a conversation with @karissa, we should think about an interface like this:

var jp = require('jupyter')
jp.on('kernelspecs', function(allKernelSpecs){});

Which would provide the list of kernelspecs across systems, using the directories currently pulled from require('jupyter-paths').jupyterPath('kernels'). Alternatively (or in addition) we could provide jp.kernelSpecs() to get the full listing of specs.

Beyond this, we'll want to be able to list the currently running runtimes (globally) as well as those launched by a running kernelManager.

Example kernel spec:

$ cat ~/Library/Jupyter/kernels/python2/kernel.json
{
 "display_name": "Python 2",
 "language": "python",
 "argv": [
  "/usr/local/opt/python/bin/python2.7",
  "-m",
  "ipykernel",
  "-f",
  "{connection_file}"
 ]
}

Example runtime:

$ cat ~/Library/Jupyter/runtime/kernel-ee2f228f-b0f8-4693-81f7-44b23124c9bd.json
{
  "hb_port": 64477,
  "iopub_port": 64474,
  "stdin_port": 64475,
  "key": "23a87070-5248-47c5-9dea-70f50cd3871d",
  "shell_port": 64473,
  "control_port": 64476,
  "transport": "tcp",
  "signature_scheme": "hmac-sha256",
  "ip": "127.0.0.1"
}
okdistribute commented 9 years ago

Jp would need to be a class that's dynamically allocated and inheirted from EventEmitter. Example here: https://nodejs.org/api/events.html

var jp = require('jupyter-paths')() // returns a class. can pass args here

What you're really doing though is watching the filesystem, which might get weird.. I haven't done that yet.

rgbkrk commented 8 years ago

We'll leave this standalone as just "where do I find these Jupyter things", keeping it small as an npm package.