• This repository has been archived on 01/Sep/2022
  • Stars
    star
    120
  • Rank 295,983 (Top 6 %)
  • Language
    HTML
  • License
    Other
  • Created about 9 years ago
  • Updated about 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

[RETIRED] Jupyter Declarative Widget Extension

Build Status

Jupyter Declarative Widget Extension

Extension for Jupyter / IPython Notebook to build interactive areas using declarative widgets.

What It Gives You

Watch from minute 21 to 41 of the September 1st Jupyter meeting video recording.

  • A base extension that enable the use of Web Components and Polymer elements
  • A set of core elements facilitate interacting with code running on the kernel
  • Ability of read and query DataFrames from a variety of implementations (i.e. Spark, R, Pandas).
  • Extensions to data binding support and installing of 3rd party elements.
  • Implementations for Python, R (using IRkernel) and Scala (using Apache Toree)

What It Lacks

  • Support for disconnected (no kernel) environments (i.e. nbviewer)

Runtime Requirements

  • Jupyter Notebook 4.0.x, 4.1.x, or 4.2.x running on Python 3.x or Python 2.7.x (see the 0.1.x branch for IPython Notebook 3.2.x compatibility)
  • IPywidgets 4.1.x and 5.1.1+ (R and Scala support not available for 5.0.0 nor 5.1.0)
  • Bower, git - Necessary for installing 3rd party elements straight out of notebook
Optional Requirements based on language support
  • Apache Toree for access to Spark using Scala
  • IRkernel for R language
Additional requirements for Pandas DataFrame queries
  • pip install numexpr
Additional requirements for Python 2.7
  • pip install futures==3.0.3

Try It

We're running a tmpnb instance at http://jupyter.cloudet.xyz with a snapshot of this project (and other related projects) pre-installed.

Install It

In Jupyter 4.2.x
# install the python package
pip install jupyter_declarativewidgets

# Install all parts of the extension to the active conda / venv / python env
# and enable all parts of it in the jupyter profile in that environment
# See jupyter declarativewidgets quick-setup --help for other options (e.g., --user)
jupyter declarativewidgets quick-setup --sys-prefix
# The above command is equivalent to this sequence of commands:
# jupyter serverextension enable --py declarativewidgets --sys-prefix
# jupyter nbextension install --py declarativewidgets --sys-prefix
# jupyter nbextension enable --py declarativewidgets --sys-prefix
In Jupyter 4.0.x and 4.1.x
# install the python package
pip install jupyter_declarativewidgets

# register the notebook frontend extensions into ~/.local/jupyter
# see jupyter cms install --help for other options
jupyter declarativewidgets install --user --symlink --overwrite
# enable the JS and server extensions in your ~/.jupyter
jupyter declarativewidgets activate
Optional install of R support (all Jupyter versions)
# installing R support
jupyter declarativewidgets installr --library path/to/r/libs
# alternatively directly from GitHub
devtools::install_github('jupyter/declarativewidgets', subdir = 'kernel-r/declarativewidgets')
Note

On all Jupyter versions, you will need to restart your notebook server if it was running during the enable/activate step. Also, note that you can run jupyter --paths to get a sense of where the extension files will be installed.

Uninstall It

In Jupyter 4.2.x
# Remove all parts of the extension from the active conda / venv / python env
# See jupyter declarativewidgets quick-remove --help for other options (e.g., --user)
jupyter declarativewidgets quick-remove --sys-prefix
# The above command is equivalent to this sequence of commands:
# jupyter bundler disable --py declarativewidgets --sys-prefix
# jupyter nbextension disable --py declarativewidgets --sys-prefix
# jupyter nbextension uninstall --py declarativewidgets --sys-prefix
# jupyter serverextension disable --py declarativewidgets --sys-prefix

# Remove the python package
pip uninstall jupyter_declarativewidgets
In Jupyter 4.0.x and 4.1.x
# Disable extensions, but no way to remove frontend assets in this version
jupyter declarativewidgets deactivate

# Remove the python package
pip uninstall jupyter_declarativewidgets

Documentation

The latest documentation can be found here.

Documentation is also available from within the notebook. To see the documentation add a cell with

%%HTML
<urth-help/>

Develop

This repository is setup for a Dockerized development environment. On a Mac, do this one-time setup if you don't have a local Docker environment yet.

brew update

# make sure we have node and npm for frontend preprocessing
brew install npm node

# make sure you're on Docker >= 1.7
brew install docker-machine docker
docker-machine create -d virtualbox dev
eval "$(docker-machine env dev)"

Clone this repository in a local directory that docker can volume mount:

# make a directory under ~ to put source
mkdir -p ~/projects
cd !$

# clone this repo
git clone https://github.com/jupyter/declarativewidgets.git

Run the notebook server in a docker container:

cd declarativewidgets

# one time only setup needed to create docker image
make init

# run notebook server in container
make dev

The final make command starts a local Docker container with the critical pieces of the source tree mounted where they need to be to get picked up by the notebook server in the container. Most code changes on your Mac will have immediate effect within the container.

To see the Jupyter instance with extensions working:

  1. Run docker-machine ls and note the IP of the dev machine.
  2. Visit http://THAT_IP:8888 in your browser
Develop Against Python 2.7

You can run a development environment against python 2.7 by adding an environment variable to your make calls.

# Run a development environment against 2.7
PYTHON=python2 make dev

Build & Package

Run make sdist to create a pip installable archive file in the dist directory. To test the package, run 'make server'. This command will run a docker container and pip install the package. It is useful to validate the packaging and installation. You should be able to install that tarball using pip anywhere you please with one caveat: the setup.py assumes you are installing to profile_default. There's no easy way to determine that you want to install against a different user at pip install time.

Test

On a Mac, make test will execute the browser, python and scala tests.

$ make test
Installing and starting Selenium server for local browsers
Selenium server running on port 50625
Web server running on port 2000 and serving from /Users/youruser/declarativewidgets
chrome 45                Beginning tests via http://localhost:2000/generated-index.html?cli_browser_id=0
chrome 45                Tests passed
Test run ended with great success

chrome 45 (102/0/0)

Running python tests...
............................
----------------------------------------------------------------------
Ran 28 tests in 0.006s

Running scala tests...
...
[info] Run completed in 8 seconds, 137 milliseconds.
[info] Total number of tests run: 78
[info] Suites: completed 7, aborted 0
[info] Tests: succeeded 78, failed 0, canceled 0, ignored 0, pending 0
[info] All tests passed.
[success] Total time: 58 s, completed Sep 22, 2015 7:31:12 PM

The browser tests are written using the Web Component Tester framework. The framework is customized for Polymer and also exposes the following utilities:

Tests are located in the test directory of each Polymer element in elements/.

Debugging Web Component Tester Test Failures

Here are some steps that are useful for debugging test failures:

  1. Execute web component tester in persistant mode from the root directory:
make testdev
  1. Add a debugger; line to the test you want to debug.

  2. Open a browser window and explicitly load the following url (Note: it is the same url that the test tool uses but all parameters have been removed from the end):

    http://localhost:2000/generated-index.html

  3. Open the developer tools for the browser and refresh. The tests should execute and then stop at the debugger; line. The code can now be debugged by stepping through it in the developer tools debugger.

Testing Against Python 2.7

You can run a tests against python 2.7 by adding an environment variable to your make calls.

# Run unit tests against 2.7
PYTHON=python2 make test

Element Documentation

Public elements and API are documented using Polymer suggested guidelines. Documentation can be run locally with the make docs target:

$ make docs
Moving static doc site content
Running hydrolysis to generate doc json
Running polybuild on docs.html
...
Serving docs at http://127.0.0.1:4001

Load the specified url in your browser to explore the documentation.

Other Topics

Initializing the Declarative Widgets extension

Before using the features provided by the Declarative Widgets extension in a notebook, the extension must first be initialized. The initialization process loads all dependencies and performs other required environment setup. Initialization is accomplished through a kernel specific API. Examples for each of the supported kernels is provided below. The initialization cell must precede the first cell in the notebook that makes use of Declarative Widgets features.

Python Initialization

import declarativewidgets as declwidgets

declwidgets.init()

Scala Initialization

// modify to IP and Port of this notebook server
%addjar http://localhost:8888/nbextensions/declarativewidgets/declarativewidgets.jar

import declarativewidgets._

initWidgets

R Initialization

library("declarativewidgets")
initWidgets()

Including a Web Component in a Notebook

The Declarative Widgets framework provides a mechanism to easily install and import a web component into a notebook. This mechanism is built on top of bower packages which are the current standard for publishing web components. Use the urth-core-import element upgraded link tag to include a web component element in a notebook.

%%html
<link rel='import' href='urth_components/paper-slider/paper-slider.html'
        is='urth-core-import' package='PolymerElements/paper-slider'>
<paper-slider></paper-slider>

The above code will first attempt to load paper-slider.html. If that fails, the specified package will be downloaded and installed on the server with bower install. The link href will then be requested again to load paper-slider.html and the related tag (paper-slider in this example) will render as is defined by the element.

To display some minimal details about the package loading in the developer console, specify the debug parameter.

Custom JavaScript API execution

Since Declarative Widgets initialization and import of web components is performed asynchronously, an elements upgraded JavaScript API may not be accessible upon execution of the cell. In order to ensure that the required API is available, make use of Urth.whenReady(function). This API will invoke the specified function only after prerequisites have been satisfied. The example code below demonstrates how to safely access the API of the custom urth-core-channel element:

%%html
<urth-core-channel name="mine" id="mychannel"></urth-core-channel>
%%javascript
var channel = document.getElementById('mychannel');

Urth.whenReady(function() {
    channel.set('myvar', 'myvalue');
});

More Repositories

1

jupyter

Jupyter metapackage for installation, docs and chat
Python
14,886
star
2

notebook

Jupyter Interactive Notebook
Jupyter Notebook
11,528
star
3

docker-stacks

Ready-to-run Docker images containing Jupyter applications
Python
7,890
star
4

nbdime

Tools for diffing and merging of Jupyter notebooks.
TypeScript
2,649
star
5

nbviewer

nbconvert as a web service: Render Jupyter Notebooks as static web pages
Python
2,204
star
6

nbconvert

Jupyter Notebook Conversion
Python
1,707
star
7

nbgrader

A system for assigning and grading notebooks
Python
1,274
star
8

dashboards

[RETIRED] See Voilà as a supported replacement
Jupyter Notebook
984
star
9

colaboratory

[deprecated] Jupyter CoLaboratory, goto google colab now
JavaScript
740
star
10

tmpnb

Creates temporary Jupyter Notebook servers using Docker containers. [DEPRECATED - See BinderHub project]
JavaScript
528
star
11

jupyter-drive

Google drive for jupyter notebooks
TypeScript
418
star
12

qtconsole

Jupyter Qt Console
Python
407
star
13

jupyter_client

Jupyter protocol client APIs
Python
379
star
14

terminado

Terminals served by tornado websockets
Python
366
star
15

atom-notebook

[Deprecated] Jupyter Notebook, but inside Atom.
JavaScript
306
star
16

help

✨ Need some help or have some questions? Please visit our Discourse page.
291
star
17

nbformat

Reference implementation of the Jupyter Notebook format
Python
259
star
18

jupyter_console

Jupyter Terminal Console
Python
249
star
19

jupyter_core

Core Jupyter functionality
Python
195
star
20

docker-notebook

Docker containers for the IPython notebook (+SciPy Stack)
Shell
188
star
21

jupyter-sphinx

Sphinx extension for rendering of Jupyter interactive widgets.
Python
186
star
22

dashboards_server

[RETIRED] Server that runs and renders Jupyter notebooks as interactive dashboards
JavaScript
181
star
23

jupyter.github.io

Project Jupyter's home on the World Wide Web
HTML
177
star
24

nbconvert-examples

Examples that illustrate how nbconvert can be used
Jupyter Notebook
164
star
25

kernel_gateway_demos

Demos associated with the kernel gateway incubator project
Jupyter Notebook
152
star
26

nbclient

A client library for executing notebooks. Formally nbconvert's ExecutePreprocessor
Python
149
star
27

enhancement-proposals

Enhancement proposals for the Jupyter Ecosystem
Python
115
star
28

papyri

Python
84
star
29

roadmap

Master roadmap for Project Jupyter
84
star
30

governance

The governance process and model for Project Jupyter
Python
82
star
31

design

Design related materials for Project Jupyter
HTML
80
star
32

dashboards_bundlers

[RETIRED] Converts a notebook to a dashboard and deploys it / downloads it
Python
79
star
33

docker-demo-images

Demo images for use in try.jupyter.org and tmpnb.org
Jupyter Notebook
75
star
34

scipy-advanced-tutorial

Advance Tutorial For SciPy
JavaScript
75
star
35

nbclassic

Jupyter Notebook as a Jupyter Server extension
JavaScript
74
star
36

nb2kg

Python
73
star
37

services

This repository is deprecated. It has been moved to https://github.com/jupyterlab/jupyterlab as a sub-package
TypeScript
70
star
38

accessibility

A repository for ongoing work around making Jupyter's software accessible and inclusive
Python
65
star
39

jupyter_kernel_test

A tool for testing Jupyter kernels
Python
62
star
40

jupyter-packaging

Tools to help build and install Jupyter Python packages
Python
62
star
41

nbmanager

View and stop running IPython notebook servers
Python
51
star
42

telemetry

Configurable event-logging for Jupyter applications and extensions.
Python
50
star
43

ngcm-tutorial

Materials for the IPython/Jupyter workshop at the NGCM Summer Academy, at Southampton University, Boldrewood campus.
Jupyter Notebook
46
star
44

jupyter-js-notebook

JupyterLab notebook
TypeScript
46
star
45

debugger

Research and explorations for an interactive debugger for Jupyter
41
star
46

echo_kernel

A simple example kernel for Jupyter
Python
39
star
47

ipython-py3k

**DO NOT USE THIS REPOSITORY AT ALL** This repo has been merged into the main IPython one that now contains Python 3 support. This is kept only as a reference to developers.
Python
34
star
48

jsplugins

JavaScript Plugins for the IPython Notebook
32
star
49

jupyterhub-2016-workshop

Materials for an online mini-workshop around JupyterHub use cases, held July 22nd, 2016
31
star
50

dashboards_setup

[RETIRED] Recipes for setting up components related to the incubating dashboards effort
Jupyter Notebook
28
star
51

testpath

Test utilities for Python code working with files and commands
Python
27
star
52

strata-sv-2015-tutorial

Strata Silicon Valley 2015 Tutorial
Python
24
star
53

jupyter-js-plugins

TypeScript
23
star
54

surveys

Surveys and datasets collected by Project Jupyter
Jupyter Notebook
23
star
55

jupyter-sphinx-theme

A Sphinx theme for Jupyter and IPython documentation
HTML
22
star
56

jvm-repr

API for converting JVM objects to representations by MIME type, for the Jupyter ecosystem.
Java
22
star
57

notebook-research

Research on the usage of Jupyter notebooks
Jupyter Notebook
20
star
58

security

19
star
59

tutorial-dashboards-declarativewidgets

Materials for the PyData Carolinas 2016 tutorial, Turning Jupyter Notebooks into Data Applications
Jupyter Notebook
19
star
60

tmpnb-deploy

Deploying tmpnb nodes
Python
18
star
61

jupyterlab_json

This repository is deprecated. The extension has moved to https://github.com/jupyterlab/jupyter-renderers
JavaScript
16
star
62

kernels

Kernel testing and listing infrastructure
Python
16
star
63

mozfest15-training

Notebooks for Jupyter training session at Mozfest 2015
Jupyter Notebook
13
star
64

newsletter

A repo for collecting content for the Jupyter Newsletter
Jupyter Notebook
13
star
65

jupyterlab_geojson

This repository is deprecated. The extension has moved to https://github.com/jupyterlab/jupyter-renderers
JavaScript
13
star
66

tmpnb-redirector

Simple HTTP redirector for tmpnb nodes
Python
12
star
67

nature-demo

Materials for the November 2014 Nature Article
Jupyter Notebook
12
star
68

extension-builder

This repository is deprecated.
TypeScript
12
star
69

jupyter_events

Configurable event system for Jupyter applications and extensions.
Python
11
star
70

phosphor-notebook

Phosphor-based jupyter notebook
TypeScript
11
star
71

ipython-components

third-party javascript dependencies of IPython
JavaScript
11
star
72

try.jupyter.org

Try Jupyter!
HTML
10
star
73

jupyter-js-ui

TypeScript
10
star
74

jupyter-js-output-area

DEPRECATED: Javascript APIs for Jupyter output areas
TypeScript
10
star
75

cookiecutter-docker-stacks

Cookiecutter for community-maintained Jupyter Docker images
Python
10
star
76

ideas

A place for the Jupyter community to connect on ideas
9
star
77

kernel_gateway_bundlers

Converts a notebook to a kernel gateway microservice bundle for download
Python
8
star
78

jupyter_markdown

Documentation and tests related to Jupyter's Markdown syntax
Jupyter Notebook
8
star
79

try-jupyter

A JupyterLite deployment to try JupyterLab, Jupyter Notebook and IPython in the browser
Jupyter Notebook
8
star
80

talks

A collection of talks about Jupyter and IPython projects
Jupyter Notebook
8
star
81

jvm-magics

A plugin system for magic function implementations across JVM kernels.
Java
7
star
82

cdn.jupyter.org

Assets and layout for cdn.jupyter.org
Python
7
star
83

jupyter-js-utils

JavaScript utilities for the Jupyter frontend
TypeScript
6
star
84

jupyter_logger

Allows you to log Jupyter notebook user events anonymously.
TypeScript
6
star
85

jupyter-js-filebrowser

DEPRECATED: This code was copied into https://github.com/jupyter/jupyter-js-ui
TypeScript
5
star
86

notebook_shim

A shim layer for notebook traits and config
Python
5
star
87

jupyter-sprints

Resources for running a sprint
HTML
5
star
88

nbcache

Notebook Caching layer in Docker
5
star
89

docs-team-compass

Documentation Work Group Discussions
HTML
5
star
90

jupyter-js-input-area

DEPRECATED: Javascript APIs for Jupyter input areas
TypeScript
5
star
91

sphinxcontrib_github_alt

Github roles for Sphinx docs
Python
5
star
92

jupyterhub-carina

[RETIRED] JupyterHub integration with Carina
Python
5
star
93

win-tornado-terminals

Windows terminal backend for tornado
Python
5
star
94

jupyterlab-fasta

DEPRECATED: Moved to https://github.com/jupyterlab/jupyter-renderers. A JupyterLab Fasta viewer
TypeScript
5
star
95

spreadsheet

A spreadsheet component for phosphor
JavaScript
5
star
96

jupyter-js-editor

DEPRECATED: This code was copied into https://github.com/jupyter/jupyter-js-notebook
TypeScript
4
star
97

jupyter-communitycalls

📣 Resources for planning and hosting the Jupyter Community Calls
4
star
98

distinguished-contributors

Jupyter Distinguished Contributors
4
star
99

project-mgt

4
star
100

showcase

[RETIRED] A spot to try demos of one or more incubating Jupyter projects in Binder
Makefile
4
star