JupyterRelayHub

class pywwt.jupyter_relay.JupyterRelayHub(kernel=None, key_prefix='pywwt_')[source]

Bases: object

pywwt’s WWT Kernel Data Relay client.

This is a singleton, per-process object, because Jupyter kernel-server connections are per-process.

Methods Summary

get_static_files_url()

Get a partial URL where static files bundled with pywwt can be obtained.

serve_file(path[, extension, key])

Request that a single specific file be published.

serve_tree(path[, key])

Request that a directory tree of files be published.

Methods Documentation

get_static_files_url()[source]

Get a partial URL where static files bundled with pywwt can be obtained.

Returns
urlstr

A partial URL.

Notes

The returned URL will not be an absolute URL. It will end with a trailing slash. In order to be turned into a retrievable URL, it must be combined with the public-facing URL of the running Jupyter server in the JavaScript frontend – the kernel does not have that information.

The static files are stored in the pywwt/web_static subdirectory of the distributed pywwt package.

Unlike user data, the static files are served with a predictable KDR key based on the version of pywwt, since identical versions should be serving identical data.

serve_file(path, extension='', key=None)[source]

Request that a single specific file be published.

Parameters
pathstr

A local filesystem path, pointing at a non-directory

extensionstr, defaults to ""

A file extension to append to the exposed URL

keystr or None (the default)

An optional “key” to uniquify the resulting service URL

Returns
urlstr

A partial URL where the file will be published

serve_tree(path, key=None)[source]

Request that a directory tree of files be published.

Parameters
pathstr

A local filesystem path, pointing at a directory

keystr or None (the default)

An optional “key” to uniquify the resulting service URL

Returns
urlstr

A partial URL, ending in a trailing slash, below which the file data will be made accessible.

Notes

The returned URL will not be an absolute URL. It will end with a trailing slash. In order to be turned into a retrievable URL, it must be combined with the public-facing URL of the running Jupyter server in the JavaScript frontend – the kernel does not have that information.

If key is unspecified, a stable-but-opaque KDR key is used. Currently it’s a cryptographic hash of the input path.