1

I have deployed the Janusgraph using Helm in Google cloud Containers, following the below documentation:

https://cloud.google.com/architecture/running-janusgraph-with-bigtable,

I'm able to fire the gremline query using Google Cloud Shell.

Snapshot of GoogleCLoud Shell

Now I want to access the Janusgraph using Python, I tried below line of code but it's unable to connect to Janusgraph inside GCP container.

from gremlin_python import statics
from gremlin_python.structure.graph import Graph
from gremlin_python.process.graph_traversal import __
from gremlin_python.process.strategies import *
from gremlin_python.driver.driver_remote_connection import DriverRemoteConnection

graph = Graph()
g = graph.traversal().withRemote(DriverRemoteConnection('gs://127.0.0.1:8182/gremlin','g'))
value = g.V().has('name','hercules').values('age')
print(value)

here's the output I'm getting

[['V'], ['has', 'name', 'hercules'], ['values', 'age']]

Whereas the output should be -

30

Is there someone tried to access Janusgraph using Python inside GCP.

Archie
  • 71
  • 8

1 Answers1

1

You need to end the query with a terminal step such as next or toList. What you are seeing is the query bytecode printed as the query was never submitted to the server due to the missing terminal step. So you need something like this:

value = g.V().has('name','hercules').values('age').next()
print(value)
Kelvin Lawrence
  • 14,674
  • 2
  • 16
  • 38
  • Is there any way to connect to Janusgraph inside GCP, I'm a little confused with the IP I am using. – Archie Jan 10 '23 at 09:43
  • That looks like the Python event loop was already running. There is a way to adjust the way the connection is created but I would suggest asking a separate connection for that as it is different from the original problem where the `next()` was missing. As part of that follow up question, please show the code being used to create the DriverRemoteConnection. In fact please see if this existing answer helps first https://stackoverflow.com/questions/73146563/gremlin-python-cannot-run-the-event-loop – Kelvin Lawrence Jan 10 '23 at 18:31
  • when we create the connection with Janusgraph and python inside GCP, which IP do we use `graph.traversal().withRemote(DriverRemoteConnection('gs://127.0.0.1:8182/gremlin','g'))` , is it the one that we see on Cloud shell? – Archie Jan 11 '23 at 04:40
  • Unfortunately I know the TinkerPop stack a lot better than I know the specific GCP dependencies. Perhaps try each and see which works? Are you getting an error? Again I recommend you make this a new question as I believe my answer above resolves the problem you reported where the terminal step was missing from your query. – Kelvin Lawrence Jan 11 '23 at 16:41