2

In the gremlin console one can easily create an in-memory TinkerGraph to play with (or load one of the sample graphs):

gremlin> graph = TinkerGraph.open() 
gremlin> g = graph.traversal()

Is is possible to expose this graph / its traversal source to a GLV (such as gremlin-python)?

I am really surprised that this seems not to be a thing. Using a in-memory TinkerGraph easily in a GLV would:

  • allow users to experiment with gremlin in the context of their language of choice,
  • be great for analytics (e.g. performing queries on a in-memory copy of a subgraph from some larger graph that resides on a remote database)
  • be great for testing (generating graphs on the fly to run tests against)
Sascha
  • 219
  • 4
  • 12

1 Answers1

3

You can only access TinkerGraph (or any other graph) with Python if hosted in Gremlin Server. The reason isn't too surprising. Gremlin Language Variants are meant to be lightweight which means they aren't complete implementations of the Gremlin Virtual Machine (GVM). Without a complete GVM (which performance actual traversal execution) you can't have a graph implementation, like TinkerGraph, to instantiate. This is why we have Gremlin Server to host the GVM in the JVM for gremlin-python to talk to over bytecode. So, at least you get the benefit of Gremlin in your native language of Python but you just don't get as integrated an experience as Java.

I'd agree that it would be great to have a TinkerGraph (or other Python graph systems) working in Python but that would be a lot of work as you would have to build a GVM for Python.

stephen mallette
  • 45,298
  • 5
  • 67
  • 135
  • Instead of building a GVM for python (or any other language variant), writing wrappers around the java implementation using language bridges such as [py4j](https://www.py4j.org/) might an alternative? – Sascha Feb 17 '19 at 16:57
  • eh...i suppose. we do have some jython bindings that we test against, but personally i'd rather not rely on those bridges as part of something TinkerPop maintained within its project. i sorta don't even like that we do jython testing. i suppose you could build those sorts of things for yourself though if writing wrappers is simple enough. – stephen mallette Feb 17 '19 at 20:30
  • I agree with your sentiment towards jython (especially since it is still python 2 based and CPython 2.7 reaches EOL next year); py4j on the other hand is also used by PySpark as far as I know. Another option I am currently considering is wrapping up gremlin server (starting, stopping, configuration) into a nice python package for better usability. – Sascha Feb 17 '19 at 20:40