Tigergraph 绑定:IT 基础设施分析演示#

使用PyGraphistry内置的Tigergraph绑定:

  • 配置数据库连接

  • 调用动态端点以获取用户定义的端点

  • 调用解释模式查询

  • 可视化结果

导入和连接#

[12]:
import graphistry

# !pip install graphistry -q

# To specify Graphistry account & server, use:
# graphistry.register(api=3, username='...', password='...', protocol='https', server='hub.graphistry.com')
# For more options, see https://github.com/graphistry/pygraphistry#configure
[13]:
g = graphistry.tigergraph(
    protocol='http', server='www.acme.org',
    user='tigergraph', pwd='tigergraph',
    db='Storage', #optional
    #web_port = 14240, api_port = 9000, verbose=True
)

动态用户定义的GSQL端点:调用、分析和绘图#

[14]:
g2 = g.gsql_endpoint(
    'StorageImpact', {'vertexType': 'Service', 'input': 61921, 'input.type': 'Pool'},
    #{'edges': '@@edgeList', 'nodes': '@@nodeList'}
)

print('# edges:', len(g2._edges))

g2.plot()
# edges: 241
[14]:

即时GSQL解释查询:调用、分析及绘图#

[15]:
g3 = g.gsql("""
  INTERPRET QUERY () FOR GRAPH Storage {

    OrAccum<BOOL> @@stop;
    ListAccum<EDGE> @@edgeList;
    SetAccum<vertex> @@set;

    @@set += to_vertex("61921", "Pool");

    Start = @@set;

    while Start.size() > 0 and @@stop == false do

      Start = select t from Start:s-(:e)-:t
      where e.goUpper == TRUE
      accum @@edgeList += e
      having t.type != "Service";
    end;

    print @@edgeList;
  }
    """,
  #{'edges': '@@edgeList', 'nodes': '@@nodeList'} # can skip by default
)

print('# edges:', len(g3._edges))

g3.plot()
# edges: 241
[15]:
[ ]: