rx-jupyter
Advanced tools
Comparing version 0.0.1 to 1.0.0
{ | ||
"name": "rx-jupyter", | ||
"version": "0.0.1", | ||
"description": "RxJS5 bindings for the Jupyter Notebook API", | ||
"version": "1.0.0", | ||
"description": "RxJS 5 bindings for the Jupyter Notebook API", | ||
"main": "lib/index.js", | ||
@@ -9,4 +9,7 @@ "scripts": { | ||
"build:docs": "jsdoc src --recurse -d docs", | ||
"test": "npm run build && mocha --compilers js:babel-core/register --recursive", | ||
"precoverage": "nyc npm run test", | ||
"pretest": "npm run build", | ||
"test": "npm run test:unit && npm run test:lint", | ||
"test:unit": "mocha --compilers js:babel-core/register --recursive", | ||
"test:lint": "eslint .", | ||
"precoverage": "nyc npm run test:unit", | ||
"coverage": "nyc report --reporter=text-lcov > coverage.lcov && codecov" | ||
@@ -36,5 +39,9 @@ }, | ||
"codecov": "^1.0.1", | ||
"eslint": "^3.8.0", | ||
"eslint-config-airbnb": "^12.0.0", | ||
"eslint-plugin-import": "^2.0.1", | ||
"jsdoc": "^3.4.2", | ||
"mocha": "^3.1.2", | ||
"nyc": "^8.3.1" | ||
"nyc": "^8.3.1", | ||
"ws": "^1.1.1" | ||
}, | ||
@@ -41,0 +48,0 @@ "babel": { |
@@ -6,9 +6,19 @@ # rx-jupyter | ||
rx-jupyter is a Reactive wrapper around the Jupyter Server API. What is this | ||
rx-jupyter is a Reactive wrapper around the Jupyter Server API. What is this | ||
library useful for? It can help you query the services API on local and remote | ||
instances of Jupyter and integrate it seamlessly with RxJS's functional tooling. | ||
## Roadmap | ||
Complete coverage of the [Jupyter Server API](http://jupyter-api.surge.sh/): | ||
* [ ] Contents | ||
* [ ] Checkpoints | ||
* [X] Kernels | ||
* [X] Kernelspecs | ||
* [ ] Sessions | ||
### Development Install | ||
To install rx-jupyter for development, you will need to do the following. | ||
To install `rx-jupyter` for development, do the following: | ||
@@ -21,2 +31,2 @@ ``` | ||
You can use `npm test` to run the test suite. | ||
Use `npm test` to run the test suite. |
@@ -1,58 +0,185 @@ | ||
import * as kernel from '../lib/kernel'; | ||
import { expect } from 'chai'; | ||
describe('createAllKernelSpec', () => { | ||
it('creates a payload for a kernelspec request', () => { | ||
const request = kernel.createAllKernelSpec(); | ||
import * as kernels from '../src/kernels'; | ||
expect(request).to.deep.equal({ | ||
url: 'http://localhost:8888/api/kernelspecs', | ||
crossDomain: true, | ||
responseType: 'json', | ||
// For the test using a websocket | ||
global.WebSocket = require('ws'); | ||
const serverConfig = { | ||
endpoint: 'http://localhost:8888', | ||
crossDomain: true, | ||
}; | ||
describe('kernels', () => { | ||
describe('createSettingsForList', () => { | ||
it('create AJAX settings for listing kernels', () => { | ||
const request = kernels.createSettingsForList(serverConfig); | ||
expect(request).to.deep.equal({ | ||
url: 'http://localhost:8888/api/kernels', | ||
crossDomain: true, | ||
responseType: 'json', | ||
}); | ||
}); | ||
}); | ||
}); | ||
describe('createAllKernel', () => { | ||
it('creates a payload for a kernels request', () => { | ||
const request = kernel.createAllKernel(); | ||
describe('createSettingsForGet', () => { | ||
it('create AJAX settings for getting a kernel by ID', () => { | ||
const request = kernels.createSettingsForGet(serverConfig, 'test-id'); | ||
expect(request).to.deep.equal({ | ||
url: 'http://localhost:8888/api/kernels', | ||
crossDomain: true, | ||
responseType: 'json', | ||
expect(request).to.deep.equal({ | ||
url: 'http://localhost:8888/api/kernels/test-id', | ||
crossDomain: true, | ||
responseType: 'json', | ||
}); | ||
}); | ||
}); | ||
}); | ||
describe('createKernel', () => { | ||
it('creates a payload for a single kernel request', () => { | ||
const request = kernel.createKernel('test-id'); | ||
describe('createSettingsForStart', () => { | ||
it('create AJAX settings for creating a kernel', () => { | ||
const request = kernels.createSettingsForStart(serverConfig, 'python3', '~'); | ||
expect(request).to.deep.equal({ | ||
url: 'http://localhost:8888/api/kernels/test-id', | ||
crossDomain: true, | ||
responseType: 'json', | ||
expect(request).to.deep.equal({ | ||
url: 'http://localhost:8888/api/kernels', | ||
crossDomain: true, | ||
responseType: 'json', | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
method: 'POST', | ||
body: { | ||
path: '~', | ||
kernel_name: 'python3', | ||
}, | ||
}); | ||
}); | ||
}); | ||
}); | ||
describe('createLaunchKernel', () => { | ||
it('creates a payload for a launch kernel request', () => { | ||
const request = kernel.createLaunchKernel('python3', '~'); | ||
describe('createSettingsForKill', () => { | ||
it('creates AJAX settings for killing a kernel', () => { | ||
const id = '0000-1111-2222-3333'; | ||
const request = kernels.createSettingsForKill(serverConfig, id); | ||
expect(request).to.deep.equal({ | ||
url: 'http://localhost:8888/api/kernels', | ||
crossDomain: true, | ||
responseType: 'json', | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
method: 'POST', | ||
body: { | ||
path: '~', | ||
kernel_name: 'python3', | ||
} | ||
expect(request).to.deep.equal({ | ||
url: `http://localhost:8888/api/kernels/${id}`, | ||
crossDomain: true, | ||
method: 'DELETE', | ||
responseType: 'json', | ||
}); | ||
}); | ||
}); | ||
describe('createSettingsForInterrupt', () => { | ||
it('creates AJAX settings for interrupting a kernel', () => { | ||
const id = '0000-1111-2222-3333'; | ||
const request = kernels.createSettingsForInterrupt(serverConfig, id); | ||
expect(request).to.deep.equal({ | ||
url: `http://localhost:8888/api/kernels/${id}/interrupt`, | ||
crossDomain: true, | ||
method: 'POST', | ||
responseType: 'json', | ||
}); | ||
}); | ||
}); | ||
describe('createSettingsForRestart', () => { | ||
it('creates AJAX settings for restarting a kernel', () => { | ||
const id = '0000-1111-2222-3333'; | ||
const request = kernels.createSettingsForRestart(serverConfig, id); | ||
expect(request).to.deep.equal({ | ||
url: `http://localhost:8888/api/kernels/${id}/restart`, | ||
crossDomain: true, | ||
method: 'POST', | ||
responseType: 'json', | ||
}); | ||
}); | ||
}); | ||
describe('get', () => { | ||
it('creates an AjaxObservable configured for getting a kernel by id', () => { | ||
const id = '0000-1111-2222-3333'; | ||
const kernel$ = kernels.get(serverConfig, id); | ||
const request = kernel$.request; | ||
expect(request.url).to.equal(`http://localhost:8888/api/kernels/${id}`); | ||
expect(request.method).to.equal('GET'); | ||
}); | ||
}); | ||
describe('list', () => { | ||
it('creates an AjaxObservable configured for listing kernels', () => { | ||
const kernel$ = kernels.list(serverConfig); | ||
const request = kernel$.request; | ||
expect(request.url).to.equal('http://localhost:8888/api/kernels'); | ||
expect(request.method).to.equal('GET'); | ||
}); | ||
}); | ||
describe('start', () => { | ||
it('creates an AjaxObservable configured for starting a kernel', () => { | ||
const kernel$ = kernels.start(serverConfig, 'python3000', '/tmp'); | ||
const request = kernel$.request; | ||
expect(request.url).to.equal('http://localhost:8888/api/kernels'); | ||
expect(request.method).to.equal('POST'); | ||
expect(request.body.path).to.equal('/tmp'); | ||
expect(request.body.kernel_name).to.equal('python3000'); | ||
}); | ||
}); | ||
describe('kill', () => { | ||
it('creates an AjaxObservable configured for killing a kernel', () => { | ||
const id = '0000-1111-2222-3333'; | ||
const kernel$ = kernels.kill(serverConfig, id); | ||
const request = kernel$.request; | ||
expect(request.url).to.equal(`http://localhost:8888/api/kernels/${id}`); | ||
expect(request.method).to.equal('DELETE'); | ||
}); | ||
}); | ||
describe('interrupt', () => { | ||
it('creates an AjaxObservable configured for interrupting a kernel', () => { | ||
const id = '0000-1111-2222-3333'; | ||
const kernel$ = kernels.interrupt(serverConfig, id); | ||
const request = kernel$.request; | ||
expect(request.url).to.equal(`http://localhost:8888/api/kernels/${id}/interrupt`); | ||
expect(request.method).to.equal('POST'); | ||
}); | ||
}); | ||
describe('restart', () => { | ||
it('creates an AjaxObservable configured for restarting a kernel', () => { | ||
const id = '0000-1111-2222-3333'; | ||
const kernel$ = kernels.restart(serverConfig, id); | ||
const request = kernel$.request; | ||
expect(request.url).to.equal(`http://localhost:8888/api/kernels/${id}/restart`); | ||
expect(request.method).to.equal('POST'); | ||
}); | ||
}); | ||
describe('formWebSocketURL', () => { | ||
it('creates websocket URLs that match the originating scheme', () => { | ||
const config = { | ||
endpoint: 'https://tmp58.tmpnb.org/user/TOTefPUbkgOu', | ||
}; | ||
const wsURL = kernels.formWebSocketURL(config, '0000-1111'); | ||
expect(wsURL).to.equal( | ||
'wss://tmp58.tmpnb.org/user/TOTefPUbkgOu/api/kernels/0000-1111/channels' | ||
); | ||
config.endpoint = 'http://127.0.0.1:8888'; | ||
const wsURL2 = kernels.formWebSocketURL(config, '4444-2222'); | ||
expect(wsURL2).to.equal( | ||
'ws://127.0.0.1:8888/api/kernels/4444-2222/channels' | ||
); | ||
}); | ||
}); | ||
describe('connect', () => { | ||
it('returns a WebSocketSubject attached to the kernel', () => { | ||
const subject = kernels.connect(serverConfig, '777'); | ||
expect(subject.url).to.equal('ws://localhost:8888/api/kernels/777/channels'); | ||
}); | ||
}); | ||
}); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
1094660
49
1540
0
31
12