简体   繁体   中英

How to connect Janusgraph deployed in GCP with Python runtime?

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.

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM