JanusGraph & Python

Exemple Python application architecture

JanusGraph server

Usage: bin/janusgraph.sh [options] {start|stop|status|clean}
  • the host and port to serve on
  • the script engines enabled
  • the serializers to make available
  • the different Graphinstances to expose

Connecting via the gremlin console

./bin/gremlin.sh gremlin > :remote connect tinkerpop.server conf/remote.yaml session     ==> Configured localhost/127.0.01:8181gremlin > :remote console
==> All scripts will now be sent to Gremlin Server
gremlin > graph
==> standardjanusgraph[cassandrathrift:[]]
gremlin > g 
==>graphtraversalsource[standardjanusgraph[cassandrathrift:[]], standard]
gremlin > GraphOfTheGodsFactory.load(graph)
gremlin> g.V().count()
gremlin> saturn = g.V().has('name', 'saturn').next()
gremlin> g.V(saturn).in('father').in('father').values('name')

Connecting with Python

# This will download a set of jar files in ./ext/gremlin-python
./bin/gremlin-server.sh -i org.apache.tinkerpop gremlin-python 3.2.6
# Install gremlin-python from PyPi
pip install gremlinpython==3.2.6
Example usage of Gremlin Python language variant
  • Traversal should be explicitly terminated by calling an action method among next(), nextTraverser() , toList(), toSet(), iterate().
  • as, in, and, or, is, not, from, global are reserved keywords in Python and you should a postfix notation. For instance: g.V().as('a').in_().as_('b').select('a','b').
  • You will need to explicitly import static enums into the scope to use anonymous traversal like out().
Gremlin variant architecture

JanusGraph specific features

john = g.V().has('name', textContainsFuzzy('John Doe'))

Useful links




Entrepreneur d'intérêt Général

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

The building of BubbleQ

Behold that cost of operating your platform on cloud

Building a Live Search Experience with StimulusReflex and Ruby on Rails

Cellframe Bi-weekly Development Report #3

Error: building client: unable to obtain access token: running Azure CLI: exit status 1: ERROR…

5 Best WordPress Pagination Plugins

Building a responsive card system

[DS-for dummies] Graph algorithms you should know (2)

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Benoît Guigal

Benoît Guigal

Entrepreneur d'intérêt Général

More from Medium

Parts of the Python Build System

conversion between JSON data and Python data.

How to install Python locally

Python Data Anonymization & Masking Guide