简体   繁体   English

如何将部署在 GCP 中的 Janusgraph 与 Python 运行时连接起来?

[英]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:我按照以下文档在 Google 云容器中使用 Helm 部署了 Janusgraph:

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

I'm able to fire the gremline query using Google Cloud Shell.我可以使用 Google Cloud Shell 触发 gremline 查询。

Snapshot of GoogleCLoud Shell谷歌云的快照 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.现在我想使用 Python 访问 Janusgraph,我尝试了下面的代码行,但它无法连接到 GCP 容器内的 Janusgraph。

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这是我得到的 output

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

Whereas the output should be -而 output 应该是 -

30

Is there someone tried to access Janusgraph using Python inside GCP.是否有人试图在 GCP 中使用 Python 访问 Janusgraph。

You need to end the query with a terminal step such as next or toList .您需要使用诸如nexttoList类的终端步骤来结束查询。 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)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何将 VSCode 连接到 GCP 实例 - How to connect VSCode to GCP instances 如何将气流 [docker] 连接到 GCP? - How to connect airflow[docker] to GCP? 如何为一组用户部署部署在 Docker 和 GCP 上的 React webapp - How to deploy React webapp deployed on Docker and GCP only for a set of users 如何从本地连接到 GCP Memorystore redis? - How to connect to GCP Memorystore redis from local? ssh 如何连接到 GCP 上的主节点? - how does ssh connect to master node on GCP? 如何将 aws vpc 和 gcp bigquery 与 vpn 连接? - How to connect aws vpc and gcp bigquery with vpn? 在云运行时重命名 python function def function GCP - Rename python function def in runtime for cloud function GCP 如何远程连接到 GCP ML Engine/AWS Sagemaker 托管笔记本? - How to remotely connect to GCP ML Engine/AWS Sagemaker managed notebooks? 如何使用 Python SDK 将 GCP 存储桶添加到 Firestore? - How to add GCP bucket to the Firestore with Python SDK? 部署时如何解决 GCP Cloud Function (Gen2) 缺少端口的问题? - How to fix missing port issue with GCP Cloud Function (Gen2) when deployed?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM