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.

1 Answer 1

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)
Sign up to request clarification or add additional context in comments.

4 Comments

Is there any way to connect to Janusgraph inside GCP, I'm a little confused with the IP I am using.
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 stackoverflow.com/questions/73146563/…
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?
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.