pyrlang.notebook module

class pyrlang.notebook.notebook.Notebook(options: dict)

Bases: pyrlang.gen_server.GenServer

Implements a flow for performing remote calculations from Erlang on Python node, while storing the results on Python side until they are ready. Each call result is stored in notebook history and a value index is returned to the caller. This index can be used as an argument in subsequent calls.

history_ = None

Recent calculation results indexed by integers or names.

history_ids_ = None

Log of recent value ids in their creation order. Values, which were deleted because of history size limit, are also deleted here.

history_limit_ = None

History dict will be trimmed when its length is greater than this limit to save memory. Attempt to refer to a trimmed value will create value_not_found exception, also propagated to Erlang side.

nb_batch(batch: List[tuple], param: Dict[term.atom.Atom, any])

Take a remote call from Erlang to execute batch of Python calls.

nb_call(param: dict)

Remote call from py.erl: Calls function defined in args, stores the result in history.

Parameters:param -- contains path: list of strings where first one is to be imported and remaining are used to find the function; args: list of arguments for the callable; kwargs; immediate: will return the value instead of the value ref if this is True, also will not update the history.
Returns:Index for stored history value.
nb_retrieve(value_id)

Remote call from py.erl: Retrieves a historical value by index.

value_id_ = None

Next id to be used as result index.

pyrlang.notebook.notebook.new_context(options: dict) → term.pid.Pid

Create a new remote-call notebook context. Node_name argument will be automatically prepended to args by Rex.