问题标签 [gremlinpython]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
93 浏览

gremlin - Python Gremlin 中的顶点未更新

在 Neptune 工作台上使用 python gremlin,我有两个功能:

第一个添加一个带有一组属性的 Vertex,并返回对遍历操作的引用

第二个添加到该遍历操作。

出于某种原因,第一个函数的操作被持久化到数据库中,但第二个操作没有。为什么是这样?

下面是两个函数:

0 投票
1 回答
258 浏览

google-cloud-platform - Gremlin 客户端通过基于 URL 的负载均衡器连接到 Gremlin / JanusGraph 服务器

由于安全策略,我有一个 JanusGraph 服务器集群(在内部 Kubernetes 网络中运行),外部 Gremlin 客户端可以通过以下网络路由访问它们:

客户端 --> 全局负载均衡器(基于 URL) --> 第三方防火墙 --> 内部负载均衡器 --> 图形服务器

全局负载均衡器暴露的端点类似于https://myhost.com/mypath1/mypath2/

curl这种方法适用于基于 HTTP(S) 的请求,因为在向上述全局负载均衡器端点发出命令时,我能够从 gremlin 服务器接收响应。

但是,我还有 2 个其他 gremlin 客户端使用模式:

  1. 使用gremlin.sh控制台
  2. 使用gremlin-python客户端(或更一般地说,WebSocket 客户端)

因此我的问题是:

  1. 在客户端remote.yaml使用的文件中gremlin.sh,如何在hostsport参数中指定全局负载均衡器端点?

    • 我尝试了一些组合(例如hosts= ['myhost.com']/['myhost.com/mypath1/mypath2'], port= 8182/443),但它们都不起作用
  2. gremlin-python客户端,我使用的是基于 WebSocket 的连接。如何使用上述端点指定 websocket 连接字符串?

    • 我尝试了各种连接字符串(例如ws(s)://myhost.com/mypath1/mypath2/gremlin),但它们也不起作用
0 投票
1 回答
92 浏览

gremlin - Gremlin-python:选择所有与 lt/gt 相关的数值属性的节点对

我的图表有以下边:

节点 1,2,3classId分别具有属性 1,2 和 3。

我想编写一个查询来返回所有对 (m,n) 使得 m.classId < n.classId。以下是我迄今为止最接近的尝试:

不幸的是,lte期望一个数字 whileselect('nid') 是一个遍历。我已经尝试了 .where 和 is_ 遍历的各种输入变体,但没有任何乐趣。

0 投票
1 回答
87 浏览

tinkerpop - 在 Gremlinpython 中验证迭代边缘插入

尝试迭代地添加顶点和边。它似乎有效,没有错误,但我希望验证边缘是否也正确添加。

下面的循环至少插入节点,如最后打印的列表长度所示,但边缘要么 1)未插入,要么 2)将它们收集到列表中的方式不正确。

任何帮助深表感谢!

预期成绩:

编辑:我在 edge01 循环中更改了这一点:

但是结果还是0。

0 投票
1 回答
88 浏览

gremlin - 可重用的遍历组件并不总是与 gremlin 一起使用

我正在尝试通过将遍历组件放入函数中,使用 gremlin python 为我的遍历创建可重用组件,但我遇到了一些遍历组件无法正常工作的问题。

作为设置,我正在使用 docker 容器运行 gremlin 服务器,并将配置文件从github repo加载到现代图中

我的测试 python 代码如下所示:

我可以成功地将values步骤移动到一个函数中,但是当我尝试对步骤执行相同的操作时,range它返回一个空列表而不是第 2 到第 4 项。有人知道我在做什么错吗?

0 投票
1 回答
439 浏览

transactions - 如何使用 gremlinpython 回滚 gremlin 事务?

我是 gremlin 的新手,我正在尝试使用 python 库 gremlinpython 连接到 Janus Graph,并且需要知道是否可以回滚事务。

我发现单次遍历等同于单次事务(tinkerPop docs),遍历是在连接到 gremlin 服务器后创建的: g = traversal().withRemote(...) 并且所有带有 g 的操作都在一个事务中执行。

但是我找不到如果任何操作发生错误会发生什么。是否可以回滚使用 g 进行的所有操作?gremlin 服务器允许做 smth likeg.tx().rollback()g.tx().commit()- 回滚或批准事务,但是否可以使用 gremlinpython 来做到这一点?

0 投票
1 回答
186 浏览

graph - Graph / Gremlinpython:Upsert 2个顶点和从一个到另一个的边

我尝试添加(如果它们不存在)2个顶点并在单个查询中添加从第一个到另一个的边。它看起来像:

但是作为fold()障碍物,它删除了我放在第一个顶点上的标签“a”。我的解决方法如下:

我能做得更好吗?这……丑?


好的,store解决方案有效 :) 但我对最后一个合并的第一部分有疑问。我这样做了:

它工作正常,感谢 Kelvin Lawrence :)

0 投票
1 回答
169 浏览

gremlin - gremlin python子图总是空的

我使用 gremlin python 连接 gremlin 服务器,如下所示:

但是当我使用子图时(在这里引用http://tinkerpop.apache.org/docs/current/reference/#subgraph-step):

结果总是像这样是空的:[{}]

我哪里错了?如何使用 gremlin-python 获取子图?

0 投票
1 回答
75 浏览

google-cloud-platform - JanusGraph 大规模数据摄取

我们正在使用 python 在 Kubernetes (GCP) 上的 Janusgraph 中摄取数据。我们正在做多线程、节点链接、索引,但我们仍然能够在 60 分钟内从 bigquery 中提取 100k(节点)记录。

Kubernetes 规范 - 1 个 Pod,具有 25 个 vCPU 和 150 GiB RAM ids.block-size = 1000 万线程池 - 16 个节点池 - 16 个堆大小 - 4 gb

问题:

  1. 我们可以采取任何其他方法来提高摄取性能,从而减少总体时间。

  2. 我们可以通过 Python 驱动程序使用 Janusgraph 一次创建多少个多个连接。目前我们能够创建 30 个线程(连接),但是当我们增加线程数时,连接要么卡住,要么性能下降。

任何细节/帮助将不胜感激

Gremlin 查询:gV().hasLabel("http://purl.uniprot.org/core/Helix_Annotation").has("id", "http://purl.uniprot.org/uniprot/P06931#SIPC5C5063B7561AB45") .has("node_id", "http://purl.uniprot.org/uniprot/P06931#SIPC5C5063B7561AB45").has("rdf_type", "http://purl.uniprot.org/uniprot/").has( "http://purl.uniprot.org/core/range", "http://purl.uniprot.org/range/22571007582875950tt125tt127").fold().coalesce(unfold(), addV("http:// purl.uniprot.org/core/Helix_Annotation").property("id", "http://purl.uniprot.org/uniprot/P06931#SIPC5C5063B7561AB45").property("node_id", "http://purl. uniprot.org/uniprot/P06931#SIPC5C5063B7561AB45").property("rdf_type", "http://purl.uniprot.org/uniprot/").property("http://purl.uniprot.org/core/range", "http://purl.uniprot.org/range/22571007582875950tt125tt127")).V().hasLabel("http://www.w3.org/1999/ 02/22-rdf-syntax-ns#Statement").has("id", "http://purl.uniprot.org/uniprot/#_kb.P06931_up.annotation_FA85AD309172A9A7").has("node_id", "http ://purl.uniprot.org/uniprot/#_kb.P06931_up.annotation_FA85AD309172A9A7").has("rdf_type", "http://purl.uniprot.org/uniprot/").has("http://purl .uniprot.org/core/attribution", "http://purl.uniprot.org/uniprot/P06931#attribution-AE0E09C5B47CC2714C9061D3806995B4").fold().coalesce(unfold(), addV("http://www. w3.org/1999/02/22-rdf-syntax-ns#Statement").property("id", "http://purl.uniprot.org/uniprot/#_kb.P06931_up.annotation_FA85AD309172A9A7")。属性(“node_id”,“http://purl.uniprot.org/uniprot/#_kb.P06931_up.annotation_FA85AD309172A9A7”).property(“rdf_type”,“http://purl.uniprot.org/uniprot/”)。属性(“http://purl.uniprot.org/core/attribution”,“http://purl.uniprot.org/uniprot/P06931#attribution-AE0E09C5B47CC2714C9061D3806995B4”))

0 投票
1 回答
310 浏览

python - 适用于 Python 的 Gremlin 返回遍历命令列表而不是数据

我正在尝试使用带有 Python 3.7 的 AWS Lambda 函数来访问我的 Neptune DB。对于一个非常简单的测试,我的 lambda 中有以下代码。

在尝试了许多不同的遍历之后,我从 print 语句中得到的唯一值是 [['V', 'student'], ['values', 'name']]我想要执行的命令的类似列表表示,而不是数据本身(如 Jeffrey)。

我错过了一些明显的错误吗?我尝试使用 toList 指定我想要的结果,但这没有帮助。谢谢!