libvis package

Submodules

libvis.VisVars module

class libvis.VisVars.VisHooks(value)[source]

Bases: libvis.VisVars.VisVars

name = 'VisVar'
on_receive(func)[source]
set_serializer(ser)[source]
class libvis.VisVars.VisObject(value)[source]

Bases: libvis.VisVars.VisVars

name = 'VisVar'
class libvis.VisVars.VisVars(*args, **kwargs)[source]

Bases: legimens.Object.Object

name = 'VisVar'

libvis.VisWorker module

class libvis.VisWorker.Vis(ws_port=7700, vis_port=7000, nb_name=None, debug=False, allow_remote=False)[source]

Bases: object

configure_logging(level, sink=<_io.TextIOWrapper name='<stderr>' mode='w' encoding='UTF-8'>)[source]

Sets up logging verbosity.

Parameters
  • level (str) – ERROR, WARNING, INFO, DEBUG, TRACE

  • sink – stream or file for logs

show()[source]

Open libvis dashboard in browser.

start()[source]

Start visualization process.

Main entry point of legimens. Called upon initialization of this class.

  1. Starts an http server with dashboard app on vis_port.

  2. Starts the legimens app using Vis.app.run().

Raises

Exception – Something went wrong when starting http or websocket server in legimens.

start_http(addr=None, port=None)[source]

Start the http server on addr and port.

stop()[source]
stop_http()[source]

Stops the http threaded server.

use(type_, serializer)[source]

Add a serializer to libvis.interface.IFC().

watch(obj, key, serializer=None)[source]

Sets libvis to watch an object.

Parameters
  • obj – the object to watch, has to be serializable.

  • key (str) – name of the object variable.

  • serializer (callable) – optional function that converts objects of type(obj) to serializable.

For sending updates we can use existing channel created for vis.vars, but this would introduce overhead. Hence, a new channel is created by creating a libvis.VisVars.VisObject() of type legimens.Object(). It is a wrapper that has single body attribute. Legimens will send serialized legimens.Object() every vis.app._watch_poll_delay seconds.

Returns ref of the proxy VisObject.

libvis.http_server module

Very simple HTTP server in python. Usage:

./dummy-web-server.py [<port>]
Send a HEAD request::

curl -I http://localhost

Send a POST request::

curl -d “foo=bar&bin=baz” http://localhost

class libvis.http_server.Server(request, client_address, server)[source]

Bases: http.server.BaseHTTPRequestHandler

do_GET()[source]
do_HEAD()[source]
libvis.http_server.create_server(server_class=<class 'http.server.HTTPServer'>, handler_class=<class 'libvis.http_server.Server'>, addr='', port=80)[source]
libvis.http_server.get_path(path)[source]
libvis.http_server.read_file(fname)[source]
libvis.http_server.run(server_class=<class 'http.server.HTTPServer'>, handler_class=<class 'libvis.http_server.Server'>, port=80)[source]
libvis.http_server.start_server(port)[source]

libvis.interface module

class libvis.interface.NumpyEncoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)[source]

Bases: json.encoder.JSONEncoder

default(obj)[source]

Implement this method in a subclass such that it returns a serializable object for o, or calls the base implementation (to raise a TypeError).

For example, to support arbitrary iterators, you could implement default like this:

def default(self, o):
    try:
        iterable = iter(o)
    except TypeError:
        pass
    else:
        return list(iterable)
    # Let the base class default method raise the TypeError
    return JSONEncoder.default(self, o)
libvis.interface.add_serializer(type, ser)[source]
libvis.interface.infer_type(val)[source]
libvis.interface.is_bokeh(*args, **kwargs)[source]
libvis.interface.is_mpl(*args, **kwargs)[source]
libvis.interface.is_numpy(*args, **kwargs)[source]
libvis.interface.ndarray_val(val)[source]
libvis.interface.numpy_to_image(val)[source]
libvis.interface.preprocess_value(val)[source]
libvis.interface.reset_IFC()[source]

Reinitialize global value of IFC

Should I have global IFC or local to Vis obj? For:

Different Vis instances might share set up visualization so no need to configure them separately.

Against:

Different Vis may serve different purposes, so there might be a need to configure them

differently.

libvis.interface.serialize_to_vis(value)[source]
libvis.interface.vismodule_val(val)[source]

libvis.main module

Module contents