Bulbs API for executing Gremlin scripts on Rexster.
Gremlin comes in several variations:
- Gremlin-Groovy (the original)
Use the standard Bulbs Gremlin interface to execute Gremlin-Groovy scrips on Rexster.
>>> from bulbs.rexster import Graph >>> g = Graph() >>> script = g.scripts.get('get_movie_recommendations') >>> params = dict(user_id=3) >>> vertices = g.gremlin.query(script, params) >>> vertex = vertices.next()
Here, “get_movie_recommendations” is a Gremln-Groovy script in your local Groovy library.
Loading Custom Functions¶
You can add a custom Groovy file to the scripts index like this:
>>> from bulbs.rexster import Graph >>> g = Graph() >>> file_path = "/home/james/code/myGremlinScripts.groovy" >>> g.scripts.update(file_path)
Bulbs will parse the Groovy file and store each function in a dict, with its function name as the key. If one of the newly-loaded functions has the same name as an existing function, it will override the existing function with your custom script.
If you make changes to the Groovy file while the object is loaded, you can refresh the loaded scripts like this: