davebshow / ipython-gremlin

http://ipython-gremlin.readthedocs.org/en/latest/
MIT License
42 stars 8 forks source link

Restrict namespace bindings #3

Closed CermakM closed 2 years ago

CermakM commented 5 years ago

Restrict namespace bindings to prevent [eval] error and to lower serialization overhead.

This PR introduces new magic commands which allow handling of the IPython namespace such that minimal amount of unnecessary bindings is sent over to gremlin. (see issue #1)

New magic commands:

%clean_bindings
%register_binding
%register_namespace
%remove_binding
%get_bindings

Also, config.py has been modified, the default behaviour does pass the namespace by default, however, sanitization of the namespace has been improved. This behaviour can be configured by use_local_namespace config variable.

Example (given that loading local namespace is disabled):

%load_ext gremlin  # as usual
g = ...  # gremlin graph object
vertex_id = '123456'  # vertex id to be passed as binding to the gremlin
%gremlin.register_binding vertex_id