Skip to content

Commit

Permalink
pydeck: Add CDN-hosted bundle for standalone HTML rendering (#4003)
Browse files Browse the repository at this point in the history
  • Loading branch information
ajduberstein committed Jan 3, 2020
1 parent a8abe30 commit 1134cad
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 14 deletions.
13 changes: 2 additions & 11 deletions bindings/python/pydeck/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,19 +116,9 @@ git clone https://github.com/uber/deck.gl/
cd deck.gl
# Build the entire deck.gl project
yarn bootstrap

# Optional but recommended: Run a hot reloading development server
cd modules/jupyter-widget
yarn watch
```

If running a non-default URL for webpack's dev server, change the URL in the `PYDECK_DEV_SERVER` environment variable,
e.g., `export PYDECK_DEV_SERVER=http://localhost:8081`.

Elsewhere, run:

```bash
export PYDECK_DEV_SERVER=http://localhost:8080
cd deck.gl/bindings/python/pydeck

# Create a virtual environment
Expand All @@ -140,7 +130,7 @@ pip install -r requirements-dev.txt
pip install -e .
```

To enable develop with Jupyter Lab, run:
Jupyter Lab is the recommended environment for development testing with pydeck. To enable development with Jupyter Lab, run:

```bash
# Execute in deck.gl/modules/jupyter-widget directory
Expand All @@ -149,6 +139,7 @@ jupyter labextension install . --no-build
jupyter lab build
```


### Tests

Tests are handled by pytest. In the top-level pydeck directory, you can type:
Expand Down
5 changes: 2 additions & 3 deletions bindings/python/pydeck/pydeck/io/html.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
TEMPLATES_PATH = os.path.join(os.path.dirname(__file__), './templates/')
j2_env = jinja2.Environment(loader=jinja2.FileSystemLoader(TEMPLATES_PATH),
trim_blocks=True)

CDN_URL = 'https://cdn.jsdelivr.net/npm/@deck.gl/jupyter-widget@^8.0.0/dist/index.js'

def render_json_to_html(json_input, mapbox_key=None, tooltip=True):
js = j2_env.get_template('index.j2')
Expand All @@ -20,8 +20,7 @@ def render_json_to_html(json_input, mapbox_key=None, tooltip=True):
html_str = js.render(
mapbox_key=mapbox_key,
json_input=json_input,
# TODO change before publication to the NPM-hosted module
deckgl_jupyter_widget_bundle='',
deckgl_jupyter_widget_bundle=CDN_URL,
tooltip=tooltip
)
return html_str
Expand Down

0 comments on commit 1134cad

Please sign in to comment.