Using Gremlin in Groovy outside Gremlin console - in a Beaker or other Groovy notebook?

27 views
Skip to first unread message

Russell Jurney

unread,
Jan 22, 2018, 12:12:55 PM1/22/18
to gremli...@googlegroups.com
How do you setup a Groovy/Gremlin session from outside the Gremlin console script?

I am writing a book on property graph analytics using Gremlin and I need to setup a gremlin console inside some kind of Groovy notebook. Beaker notebooks look like the way to go. I assume setting up Gremlin access here will be the same as with any other Java/Groovy repl, but I can't find instructions for doing that. I've looked at reverse engineering the Gremlin script but thought I would ask before doing so.

Is there a recipe for using Gremlin in a vanilla Groovy repl?

Thanks,

Stephen Mallette

unread,
Jan 22, 2018, 12:28:33 PM1/22/18
to Gremlin-users
Beaker looks interesting. We don't have any instructions for manually setting up generic REPLs so you're not missing anything hidden away somewhere. I gave a quick look at the Beaker FAQ and it seems like you just need to get Gremlin jars on the Beaker classpath so that Beaker has access to them. You would minimally want the jar files that are in the /lib of the Gremlin Console distribution.  You would additionally want the jars of the graph database you were planning to use. I assume with groovy you would need to instruct Beaker to import the classes you wanted to use - I would assume those are just standard groovy import statements, but I couldn't find confirmation on that. If you're interested in seeing exactly what the Gremlin Console imports you can look at this:


If you do get Gremlin up and running in Beaker and can share the steps with us on the list, that would be great - perhaps we could turn that into some official docs in TinkerPop.

HTH,

Stephen


--
You received this message because you are subscribed to the Google Groups "Gremlin-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gremlin-users/CANSvDjrkonKE%2B6sEJr_VUg1MVP6n13pdNTPP%2BpZRHPq9kw2O3Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Russell Jurney

unread,
Jan 22, 2018, 5:49:18 PM1/22/18
to gremli...@googlegroups.com
Thanks for the info. I will try to get it working and let you know. The other option would be the groovy kernel for Jupyter notebooks. Probably the same process either way.

Russ

On Mon, Jan 22, 2018 at 9:28 AM Stephen Mallette <spmal...@gmail.com> wrote:
Beaker looks interesting. We don't have any instructions for manually setting up generic REPLs so you're not missing anything hidden away somewhere. I gave a quick look at the Beaker FAQ and it seems like you just need to get Gremlin jars on the Beaker classpath so that Beaker has access to them. You would minimally want the jar files that are in the /lib of the Gremlin Console distribution.  You would additionally want the jars of the graph database you were planning to use. I assume with groovy you would need to instruct Beaker to import the classes you wanted to use - I would assume those are just standard groovy import statements, but I couldn't find confirmation on that. If you're interested in seeing exactly what the Gremlin Console imports you can look at this:


If you do get Gremlin up and running in Beaker and can share the steps with us on the list, that would be great - perhaps we could turn that into some official docs in TinkerPop.

HTH,

Stephen


On Mon, Jan 22, 2018 at 12:12 PM, Russell Jurney <russell...@gmail.com> wrote:
How do you setup a Groovy/Gremlin session from outside the Gremlin console script?

I am writing a book on property graph analytics using Gremlin and I need to setup a gremlin console inside some kind of Groovy notebook. Beaker notebooks look like the way to go. I assume setting up Gremlin access here will be the same as with any other Java/Groovy repl, but I can't find instructions for doing that. I've looked at reverse engineering the Gremlin script but thought I would ask before doing so.

Is there a recipe for using Gremlin in a vanilla Groovy repl?

Thanks,

--
You received this message because you are subscribed to the Google Groups "Gremlin-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-user...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Gremlin-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gremlin-users/CAA-H43_-rs7NoK-ZPk3goVWqmk%3DWNMe28cnO86vKatToKQVAOA%40mail.gmail.com.

For more options, visit https://groups.google.com/d/optout.
--

Russell Jurney

unread,
Jan 22, 2018, 5:55:36 PM1/22/18
to gremli...@googlegroups.com
Would Rexster be good to look at? It can send gremlin queries, can't it?

Stephen Mallette

unread,
Jan 23, 2018, 6:28:04 AM1/23/18
to Gremlin-users
There is no more "Rexster" - in TinkerPop 3 Gremlin's friendly pup has been recast as Gremlin Server. Like Rexster of TinkerPop 2, Gremlin Server is basically a remote query processor - it accepts queries from remote clients and returns results. Based on what I understand you're trying to do, I don't think it would be helpful in this case. Using it however does give you the greatest flexibility in what you point your notebook at. Beaker would need no graph database jars in the path - just the TinkerPop ones - and the code would work against both embedded and remote graph systems. You would just change the host you were connected to (and likely authentication configuration) which would mean you could use your own locally running Gremlin Server (with TinkerGraph, JanusGraph, whatever - hosted within it) or a remote graph system like DSE Graph, Amazon Neptune, CosmosDB, etc. Remote traversals do have some limitations to consider, but I just thought that I'd point out the option to go this route.

On Mon, Jan 22, 2018 at 5:55 PM, Russell Jurney <russell...@gmail.com> wrote:
Would Rexster be good to look at? It can send gremlin queries, can't it?

On Mon, Jan 22, 2018 at 2:49 PM Russell Jurney <russell...@gmail.com> wrote:
Thanks for the info. I will try to get it working and let you know. The other option would be the groovy kernel for Jupyter notebooks. Probably the same process either way.

Russ
On Mon, Jan 22, 2018 at 9:28 AM Stephen Mallette <spmal...@gmail.com> wrote:
Beaker looks interesting. We don't have any instructions for manually setting up generic REPLs so you're not missing anything hidden away somewhere. I gave a quick look at the Beaker FAQ and it seems like you just need to get Gremlin jars on the Beaker classpath so that Beaker has access to them. You would minimally want the jar files that are in the /lib of the Gremlin Console distribution.  You would additionally want the jars of the graph database you were planning to use. I assume with groovy you would need to instruct Beaker to import the classes you wanted to use - I would assume those are just standard groovy import statements, but I couldn't find confirmation on that. If you're interested in seeing exactly what the Gremlin Console imports you can look at this:


If you do get Gremlin up and running in Beaker and can share the steps with us on the list, that would be great - perhaps we could turn that into some official docs in TinkerPop.

HTH,

Stephen


On Mon, Jan 22, 2018 at 12:12 PM, Russell Jurney <russell...@gmail.com> wrote:
How do you setup a Groovy/Gremlin session from outside the Gremlin console script?

I am writing a book on property graph analytics using Gremlin and I need to setup a gremlin console inside some kind of Groovy notebook. Beaker notebooks look like the way to go. I assume setting up Gremlin access here will be the same as with any other Java/Groovy repl, but I can't find instructions for doing that. I've looked at reverse engineering the Gremlin script but thought I would ask before doing so.

Is there a recipe for using Gremlin in a vanilla Groovy repl?

Thanks,

--
You received this message because you are subscribed to the Google Groups "Gremlin-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-users+unsubscribe@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Gremlin-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-users+unsubscribe@googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "Gremlin-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gremlin-users/CANSvDjrzjs1uEQ%2BoY8sRhRiSQcqrcGLKY-zGc0qhQvJiK%3DDXuw%40mail.gmail.com.

Russell Jurney

unread,
Jan 23, 2018, 5:25:39 PM1/23/18
to gremli...@googlegroups.com
Oh, sorry - I meant the Rexter code might be a good guide as to which imports are required, since it would have needed to setup a session as well.

Stephen Mallette

unread,
Jan 23, 2018, 5:33:10 PM1/23/18
to Gremlin-users
Again, no more "Rexster" - it's Gremlin Server now. And Gremlin Server uses the CoreImports same as the Console...all that stuff is more centralized in TinkerPop 3.x. Gremlin Server does Include some additional imports but they aren't really relevant:


Though, it does bring up the added point that any plugins installed to your console may have their own import definitions (similar to the above) so you might need to look at those to get an exact replica of your environment if you have a load of plugins (like say for spark-gremlin).

Russell Jurney

unread,
Jan 24, 2018, 1:52:38 PM1/24/18
to gremli...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages