当前位置:网站首页>Example explanation: move graph explorer to jupyterlab
Example explanation: move graph explorer to jupyterlab
2022-07-01 18:53:00 【InfoQ】

One 、 Prepare before use
1. Huawei cloud account
2. OBS Object storage service
3. GES Figure Engine Services
4. Get call GES Business API Required parameters
Two 、 Use GES4Jupyter Connect GES service

import moxing as mox
mox.file.copy('obs://obs-aigallery-zc/GES/ges4jupyter/beta/ges4jupyter.py', 'ges4jupyter.py')
mox.file.copy('obs://obs-aigallery-zc/GES/ges4jupyter/beta/ges4jupyter.html', 'ges4jupyter.html')

from ges4jupyter import GESConfig, GES4Jupyter, read_csv_config
eip = ''
project_id = ''
graph_name = ''
iam_url = ''
user_name = ''
password = ''
domain_name = ''
project_name = ''
port = 80
eip, project_id, graph_name, iam_url, user_name, password, domain_name, project_name, port = read_csv_config('cn_north_4_graph.csv')
config = GESConfig(eip, project_id, graph_name,
iam_url = iam_url,
user_name = user_name,
password = password,
domain_name = domain_name,
project_name = project_name,
port = port)
ges_util = GES4Jupyter(config, True);
- Is used to construct API Parameters of :eip,projectId,graph_name, port These four parameters are involved in the construction of the business face request url.eip And graph_name The two parameters are easy to obtain in drawing creation ,port The parameter defaults to 80, When safe mode is turned on, it is 443, About projectId, Refer to the official website of the graph engine - Get the project id, Get items from the graph console according to the region to which the graph belongs id.
- Used when requesting API Pre acquisition token Parameters of :iam_url, user_name, password, domain_name,project_name,GES4Jupyter These four parameters will be used to get token, And then in use api To authenticate , For relevant parameters, please refer to : Huawei graphics engine documentation - Business API Authentication and call GES Service business API Acquisition of relevant parameters

print(' Start creating point index :')
job_id = ges_util.build_vertex_index()
job_result = ges_util.get_job(job_id)
if 'errorCode' not in job_result:
for i in range(100):
if job_result['status'] == 'success':
break
else:
time.sleep(1)
job_result = ges_util.get_job(job_id)
print(' Point index creation completed ')
print(' Start creating edge index :')
job_id = ges_util.build_edge_index()
job_result = ges_util.get_job(job_id)
if 'errorCode' not in job_result:
for i in range(100):
if job_result['status'] == 'success':
break
else:
time.sleep(1)
job_result = ges_util.get_job(job_id)
print(' Edge index creation completed ')
ges_util.cypher_query("call dbms.parameter('needNodeIndex', false)");
ges_util.cypher_query("call dbms.parameter('needEdgeIndex', false)");

3、 ... and 、 Use GES4Jupyter Call the business interface and visualize it
cypher_result = ges_util.cypher_query("match (n)-[r]->(m) return n,r,m limit 10",formats=['row','graph']);
ges_util.format_cypher_result(cypher_result)


gremlin_result = ges_util.gremlin_query("g.V().outE().bothV().path().limit(2)");
ges_util.format_gremlin_result(gremlin_result)

result = ges_util.path_query({
"repeat": [
{
"operator": "bothV",
"vertex_filter": {
"property_filter": {
"leftvalue": {
"id": ""
},
"predicate": "NOTIN",
"rightvalue": {
"value": [" Beijing "]
}
}
}
}
],
"until": [
{
"vertex_filter": {
"property_filter": {
"leftvalue": {
"id": ""
},
"predicate": "=",
"rightvalue": {
"value": [" mesozoic-cenozoic "]
}
}
}
}
],
"times": 5,
"queryType": "Tree",
"vertices": [" Beijing case 2"]
})
ges_util.format_path_query(result)

Four 、 There are more cases available on the official website of the graph engine GES4Jupyter Hands on experience

边栏推荐
- Must see, time series analysis
- Halcon图片标定,使得后续图片处理过后变成与模板图片一样
- Search 2D matrix 2
- Li Kou daily question - Day 32 -589 N × Preorder traversal of tree
- Unity learning fourth week
- Popular science: what does it mean to enter the kernel state?
- Memo - about C # generating barcode
- The R language cartools package divides the data, the scale function scales the data, the KNN function of the class package constructs the k-nearest neighbor classifier, and the table function calcula
- 力扣每日一题-第32天-589.N×树的前序遍历
- Lumiprobe Lumizol RNA 提取试剂解决方案
猜你喜欢
Livedata postvalue will "lose" data
Leetcode-160相交链表
搭建一個通用監控告警平臺,架構上需要有哪些設計
Viewing the whole ecology of Tiktok from a macro perspective
How to find customers for investment attraction in industrial parks
docker 部署mysql8.0
研究了11种实时聊天软件,我发现都具备这些功能…
[source code analysis] model parallel distributed training Megatron (5) -- pipestream flush
Lumiprobe 双功能交联剂丨Sulfo-Cyanine5 双-NHS 酯
力扣每日一题-第32天-589.N×树的前序遍历
随机推荐
golang 错误处理
Li Kou daily question - Day 32 -589 N × Preorder traversal of tree
Leetcode-128 最长连续序列
R语言使用epiDisplay包的aggregate函数将数值变量基于因子变量拆分为不同的子集,计算每个子集的汇总统计信息
LeetCode-21合并两个有序链表
Find all missing numbers in the array
Lumiprobe biomolecular quantification - qudye Protein Quantification Kit
Database foundation: select basic query statement
540. Single element in ordered array / 1684 Count the number of consistent strings
[Chongqing Guangdong education] basic psychology reference materials of Tianjin Normal University
How to manage 1000 anchors by one person?
Privacy sandbox is finally coming
关于企业中台规划和 IT 架构微服务转型
GAMES202作业0-环境搭建过程&解决遇到的问题
Create your own NFT collections and publish a Web3 application to show them (Introduction)
How to realize the applet in its own app to realize continuous live broadcast
docker 部署mysql8.0
How to realize the bottom layer of read-write lock in go question bank 16
AppGallery Connect场景化开发实战—图片存储分享
Image acquisition and playback of coaxpress high speed camera based on pxie interface