Gremlin Development in an IDE

1,669 views
Skip to first unread message

Chris Diehl

unread,
Jul 19, 2011, 1:21:25 PM7/19/11
to Gremlin-users
Marko et al,

I clearly need to start using an IDE to debug my Gremlin scripts.
Beyond a certain level of complexity, it becomes tedious to track bugs
down. Are any of you using Eclipse for Gremlin development? I'd
appreciate any suggestions you all may have...

Thanks! Chris

Marko Rodriguez

unread,
Jul 19, 2011, 1:32:54 PM7/19/11
to gremli...@googlegroups.com
Hey,
Are you coding in a plain text file? Icky.

I code in IntelliJ. Given that Gremlin "is just" Groovy, you get syntax highlighting, dot completion, warnings for potentially (meta-programming) non-existant methods, etc. See slide 234 here:

I'm sure Eclipse gives you analogous Groovy support as IntelliJ.

Hope that helps,
Marko.

Peter Neubauer

unread,
Jul 19, 2011, 1:34:03 PM7/19/11
to gremli...@googlegroups.com

Maybe start with some Groovy plugin för Eclipse?

/peter

Sent from my phone.

Marcello de Sales

unread,
Jul 19, 2011, 1:40:10 PM7/19/11
to gremli...@googlegroups.com
I would recommend the SpringSource STS, which gives nice support to Groovy since they keep it up-to-date supporting Grails apps... I was using vi :) first time I was trying Gremlin out and went directly to STS...

thanks
Marcello

Russell Jurney

unread,
Jul 19, 2011, 4:33:51 PM7/19/11
to gremli...@googlegroups.com
I get by with exhaustive unit tests.

Russell Jurney
twitter.com/rjurney
russell...@gmail.com
datasyndrome.com

Marko Rodriguez

unread,
Jul 19, 2011, 4:35:24 PM7/19/11
to gremli...@googlegroups.com
I concur.

In the end, code is mostly test cases and documentation.

Marko.

http://markorodriguez.com

Russell Jurney

unread,
Jul 19, 2011, 6:59:59 PM7/19/11
to gremli...@googlegroups.com
I actually started writing tests first this week.

Chris Diehl

unread,
Jul 20, 2011, 10:45:28 AM7/20/11
to Gremlin-users
Thanks guys for the pointers. Hope to try and set something up this
week.

Is there a way in the Gremlin interactive session to tell it not to
print any of the return values to the screen? Would be nice to be able
to load a script and just let it crank.

And yes, my only workflow to date with Gremlin scripts is editing them
in a text editor and loading them in the interactive session. ;-) Need
to step up my game...

Chris

On Jul 19, 3:59 pm, Russell Jurney <russell.jur...@gmail.com> wrote:
> I actually started writing tests first this week.
>
> Russell Jurney
> twitter.com/rjurney
> russell.jur...@gmail.com
> datasyndrome.com
>
> On Jul 19, 2011, at 1:35 PM, Marko Rodriguez <okramma...@gmail.com> wrote:
>
>
>
>
>
>
>
> > I concur.
>
> > In the end, code is mostly test cases and documentation.
>
> > Marko.
>
> >http://markorodriguez.com
>
> > On Jul 19, 2011, at 2:33 PM, Russell Jurney wrote:
>
> >> I get by with exhaustive unit tests.
>
> >> Russell Jurney
> >> twitter.com/rjurney
> >> russell.jur...@gmail.com
> >> datasyndrome.com

Marko Rodriguez

unread,
Jul 20, 2011, 10:54:49 AM7/20/11
to gremli...@googlegroups.com
Yo,

Is there a way in the Gremlin interactive session to tell it not to
print any of the return values to the screen? Would be nice to be able
to load a script and just let it crank.



And yes, my only workflow to date with Gremlin scripts is editing them
in a text editor and loading them in the interactive session. ;-) Need
to step up my game...

Hatas gonna hate.

MTV Raps,
Marko.


Chris Diehl

unread,
Jul 20, 2011, 9:33:07 PM7/20/11
to Gremlin-users
Ok cool. Next question is the following. What do I need to add to the
beginning of my script to make the Groovy compiler properly compile my
Gremlin code?

Think I've got Eclipse set up properly with the plug-in.

Chris

On Jul 20, 7:54 am, Marko Rodriguez <okramma...@gmail.com> wrote:
> Yo,
>
> > Is there a way in the Gremlin interactive session to tell it not to
> > print any of the return values to the screen? Would be nice to be able
> > to load a script and just let it crank.
>
> $ ./gremlin.sh -e myscript.grm
>
> https://github.com/tinkerpop/gremlin/wiki/Using-Gremlin-from-the-Comm...(second section)

James Thornton

unread,
Jul 20, 2011, 9:40:48 PM7/20/11
to gremli...@googlegroups.com
Is Gremlin in your classpath?

Chris Diehl

unread,
Jul 20, 2011, 10:30:23 PM7/20/11
to Gremlin-users
Very likely not.

On Jul 20, 6:40 pm, James Thornton <james.thorn...@gmail.com> wrote:
> Is Gremlin in your classpath?

Kenneth Miller

unread,
Dec 7, 2014, 10:26:50 PM12/7/14
to gremli...@googlegroups.com
Would there possibly be some up to date maven configuration that would allow you to use Gremlin with whatever version of java is applicable in eclipse easily, and have the groovy plugin do the rest of the appropriate completion and stuff?

Venkata Phani Kumar Mangipudi

unread,
Nov 6, 2015, 6:25:21 AM11/6/15
to Gremlin-users
Hi

I am in the same problem after nearly 4 years! After-all, everyone has a starting point, and this is mine with Tinkerpop3 and gremlin. By the way I am starting off with graphs (real gremlin queries) straight with Titan 1.0.0 :-)

Is there any IDE now for writing and executing the gremlin queries? 
The intelliJ set-up mean, I can write in the IDE, but to execute on a remote gremlin-server, not sure if that works!

My need is ==> my developers write gremlin queries execute them against a remote gremlin-server. Executing the gremlin scripts on production / near-production environment works. 
And I can't expect my developers to run near-production graph cluster on their development machines.  

I was exploring the GroovyConsole, but not sure how this can be used as an IDE for gremlin queries, when tried to run the 2.4.1 version of groovyConsole, it fails stating some security exceptions!

I am sure, after 4 years means, smart people like you would have already found better ways :)
Can anyone please help me here!

Thanks and Regards,
Phani

Stephen Mallette

unread,
Nov 6, 2015, 6:34:05 AM11/6/15
to Gremlin-users
I'm not sure I understand exactly what you're after.  I wll say that Intellij should work better as an IDE for Gremlin in TP3, in the sense that you can now get good auto-complete support given that there is lessened dependence on Groovy.  There is no way to remote execute to Gremlin Server from the IDE that I know of.  I'm not sure why you would set up your dev environment that way though.  Wouldn't you just write unit tests against some small test graph.  Look at the patterns we use in TinkerPop where all of the thousands of test we have execute against a handful of "small" graphs.

To me, the best tool for developing gremlin remains the Gremlin Console.  I typically have that open when building complex traversals and copy/paste back and forth with the IDE as needed.

--
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/671b3980-28bf-46ef-bc67-befcc5522b9d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jason Plurad

unread,
Nov 6, 2015, 9:30:49 AM11/6/15
to Gremlin-users
What security exceptions were you seeing?

Venkata Phani Kumar Mangipudi

unread,
Nov 9, 2015, 1:18:11 AM11/9/15
to Gremlin-users
Thank you Stephen for your inputs,

But, in Gremlin console, ( I am using in Windows)
1. I am not able to move up, down on my commands, command history is not maintained
2.  Though, the Ctrl+R enables me to search for previous commands, it doesn't allow me to modify them
3. The above two leads me to retype my query every time => this seems to be very primitive / I am missing something really simple! 

Coming to your suggestion on the Unit testing, yes, I agree that I need to get myself molded into the graph thinking. Could you please point me to the documentation of the patterns you have mentioned, so that I can get myself familiarized with those and start incorporating them in my implementation. 

Few questions related to using intelliJ for gremlin development:
a) I am wondering, if there is any documentation like "Beginners guide to gremlin/groovy coding in intellij"
b) can I run the queries if not on a remote graph, on a local graph running on some port? basically I want to avoid the need to build source code before confirming the gremlin I wrote compiles / produces the results that I wanted! ==> source code building eats lot of development time, especially for database queries. 
I can understand that experts can write graph traversals out of their wit, but newcomers will find it difficult to get their query right and would typically do multiple rounds before perfection. This could eat their complete day at the end. hence wanted to figure out the optimum way for on-boarding freshmen to gremlin development!

Apologies for bothering with too many questions at once, I am just getting started and want to get things right in the first place. 

Thanks and Best Regards,
Phani

Venkata Phani Kumar Mangipudi

unread,
Nov 9, 2015, 3:50:13 AM11/9/15
to Gremlin-users
C:\Phani\titan\bin>groovyConsole.bat
java.lang.ExceptionInInitializerError
        at org.codehaus.groovy.runtime.InvokerHelper.<clinit>(InvokerHelper.java:62)
        at org.codehaus.groovy.runtime.callsite.CallSiteArray.createCallStaticSite(CallSiteArray.java:72)
        at org.codehaus.groovy.runtime.callsite.CallSiteArray.createCallSite(CallSiteArray.java:159)
        at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:110)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:122)
        at groovy.ui.Console.<clinit>(Console.groovy:79)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:483)
        at org.codehaus.groovy.tools.GroovyStarter.rootLoader(GroovyStarter.java:106)
        at org.codehaus.groovy.tools.GroovyStarter.main(GroovyStarter.java:128)
Caused by: java.lang.SecurityException: Prohibited package name: java.util.concurrent
        at java.lang.ClassLoader.preDefineClass(ClassLoader.java:659)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:758)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
        at java.net.URLClassLoader.defineClass(URLClassLoader.java:455)
        at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:367)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
        at org.codehaus.groovy.tools.RootLoader.oldFindClass(RootLoader.java:172)
        at org.codehaus.groovy.tools.RootLoader.loadClass(RootLoader.java:144)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        at java.lang.Class.getDeclaredFields0(Native Method)
        at java.lang.Class.privateGetDeclaredFields(Class.java:2575)
        at java.lang.Class.getDeclaredFields(Class.java:1908)
        at org.codehaus.groovy.reflection.CachedClass$1$1.run(CachedClass.java:50)
        at java.security.AccessController.doPrivileged(Native Method)
        at org.codehaus.groovy.reflection.CachedClass$1.initValue(CachedClass.java:47)
        at org.codehaus.groovy.reflection.CachedClass$1.initValue(CachedClass.java:45)
        at org.codehaus.groovy.util.LazyReference.getLocked(LazyReference.java:46)
        at org.codehaus.groovy.util.LazyReference.get(LazyReference.java:33)
        at org.codehaus.groovy.reflection.CachedClass.getFields(CachedClass.java:261)
        at groovy.lang.MetaClassImpl.addFields(MetaClassImpl.java:2374)
        at groovy.lang.MetaClassImpl.inheritFields(MetaClassImpl.java:2369)
        at groovy.lang.MetaClassImpl.setupProperties(MetaClassImpl.java:2256)
        at groovy.lang.MetaClassImpl.addProperties(MetaClassImpl.java:3299)
        at groovy.lang.MetaClassImpl.initialize(MetaClassImpl.java:3263)
        at org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl.<init>(MetaClassRegistryImpl.java:119)
        at org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl.<init>(MetaClassRegistryImpl.java:71)
        at groovy.lang.GroovySystem.<clinit>(GroovySystem.java:33)
        ... 13 more

C:\Phani\titan\bin>

Stephen Mallette

unread,
Nov 10, 2015, 6:16:01 AM11/10/15
to Gremlin-users
But, in Gremlin console, ( I am using in Windows)
1. I am not able to move up, down on my commands, command history is not maintained

I think Jason is looking into this issue for Titan packaging of Gremlin Console but I believe it is already solved for the standard TinkerPop packaging.  You can fix up the .bat yourself if you check-out Jason's comment on this issue:


Coming to your suggestion on the Unit testing, yes, I agree that I need to get myself molded into the graph thinking. Could you please point me to the documentation of the patterns you have mentioned, so that I can get myself familiarized with those and start incorporating them in my implementation. 

There's no such documentation - just the test cases.  Ours are a bit advanced compared to what you need but perhaps you can discern the pattern from our base test class:


Actually, as I write this I'm thinking that there's no reason you couldn't depend on this class for your own test suite.  I haven't thought it all through but it seems that it would work. You basically just create tests that extend the AbstractGremlinTest.  You then list them in a custom suite that extends from this:


Next you create a GraphProvider implementation that generates your graph - in your case, I'd guess that you would fire up an in-memory Titan implementation:


Finally, create a "test" that uses your custom suite:

 
a) I am wondering, if there is any documentation like "Beginners guide to gremlin/groovy coding in intellij"

not aware of anything like that
 
b) can I run the queries if not on a remote graph, on a local graph running on some port? basically I want to avoid the need to build source code before confirming the gremlin I wrote compiles / produces the results that I wanted! ==> source code building eats lot of development time, especially for database queries. 

If you want to save time on build, then get your Gremlin Console working.  That's precisely why I keep it open with intellij.  You can paste code in there to execute to see if it works, tweak it then paste it back to intellij.  Or, I would ask the question why it takes so long to build your code and run tests.  Running a single test should not be terribly costly - if it is then there is something wrong in how you've designed your test suite.  Unit tests should be fast and easy to run.  When we have tests that are painful to run in TinkerPop we figure out why and make changes.  
 
I can understand that experts can write graph traversals out of their wit, but newcomers will find it difficult to get their query right and would typically do multiple rounds before perfection. This could eat their complete day at the end. hence wanted to figure out the optimum way for on-boarding freshmen to gremlin development!

In my opinion, that is what the Gremlin Console is for.  The development cycle isn't any faster than that.  Type code, hit enter and get success/failure on the spot. 


Venkata Phani Kumar Mangipudi

unread,
Nov 10, 2015, 1:10:59 PM11/10/15
to Gremlin-users
Thank you very much Stephen for your detailed and in-depth suggestions. 

With the help of Json's comment, I am now able to fix the gremlin console issue. I am able to navigate through arrow keys. It is a great time saver.

I'll spend time through the testcases built for gremlin testing and mold my testcases accordingly. Thank you very much for all the pointers. 

Thanks and Regards,
Phani

Todd Leo

unread,
Mar 9, 2016, 10:30:17 PM3/9/16
to Gremlin-users
Hi Stephan,

Is there a way for Gremlin in TP3 or Titan 1.0, to load gremlin through groovy, as described in TP2 Gremlin document ?

If is possible, it would be nice to use an IDE to edit and debug gremlin code.

Stephen Mallette

unread,
Mar 10, 2016, 5:26:24 AM3/10/16
to Gremlin-users
Most of Gremlin is just Java in TP3 so intellij support should just work when you add TinkerPop libraries. You only do a SugarLoader.load() (like Gremlin.load() in 2.x) to get some syntactic sugar that groovy allows:


chakravarthy garimella

unread,
Mar 15, 2019, 5:00:54 PM3/15/19
to Gremlin-users
we can use groovy development tools 3.3.0 plugin for Eclipse/STS
Reply all
Reply to author
Forward
0 new messages