Difference between revisions of "Pyjanusgraph"
Jump to navigation
Jump to search
(12 intermediate revisions by the same user not shown) | |||
Line 6: | Line 6: | ||
|title=Python janusgraph utility library | |title=Python janusgraph utility library | ||
|url=https://github.com/BITPlan/pyjanusgraph | |url=https://github.com/BITPlan/pyjanusgraph | ||
− | |version=0.0. | + | |version=0.0.1a2 |
|date=2020/04/12 | |date=2020/04/12 | ||
|storemode=property | |storemode=property | ||
}} | }} | ||
+ | |||
+ | = Motivation = | ||
+ | [https://janusgraph.org/ JanusGraph] is the first {{Link|target=Tinkerpop|title=Apache Tinkerpop}} graph database i could work with {{Link|target=Gremlin_python|title=Gremlin Python}}. | ||
+ | |||
+ | pyjanusgraph shall make it easier to work with JanusGraph from Python | ||
+ | |||
+ | = Installation = | ||
+ | <source lang='bash'> | ||
+ | pip install pyjanusgraph | ||
+ | </source> | ||
+ | |||
+ | = Usage = | ||
+ | First start your janusgraph server e.g. by using the docker command: | ||
+ | <source lang='bash'> | ||
+ | docker run --name jg -it -p 8182:8182 --mount source=/$HOME/graphdata,target=/graphdata,type=bind janusgraph/janusgraph | ||
+ | </source> | ||
+ | == RemoteGremlin == | ||
+ | The [https://pyjanusgraph.readthedocs.io/en/latest/tp.html#tp.gremlin.RemoteGremlin RemoteGremlin] class provides a simplified | ||
+ | API to work with a remote Gremlin Server connection to JanusGraph. Optionally you may share data with an e.g docker based | ||
+ | Server by setting up a sharepoint. See [https://github.com/BITPlan/pyjanusgraph/issues/1 Issue #1] | ||
+ | === accessing a remote graph === | ||
+ | <source lang='python'> | ||
+ | from tp.gremlin import RemoteGremlin | ||
+ | import os | ||
+ | rg = RemoteGremlin() | ||
+ | g=rg.open() | ||
+ | vList = g.V().toList() | ||
+ | print ("found %d vertices" % (len(vList))) | ||
+ | rg.close() | ||
+ | </source> | ||
+ | === sharing data === | ||
+ | <source lang='python'> | ||
+ | from tp.gremlin import RemoteGremlin | ||
+ | import os | ||
+ | rg = RemoteGremlin() | ||
+ | rg.setSharepoint(os.path.expanduser("~/graphdata"), "/graphdata/") | ||
+ | g=rg.open() | ||
+ | graphmlFile = "air-routes-small.xml"; | ||
+ | shared = rg.share(graphmlPath) | ||
+ | g.io(shared).read().iterate() | ||
+ | vCount = g.V().count().next() | ||
+ | print ("%s has %d vertices" % (shared, vCount)) | ||
+ | rg.close() | ||
+ | </source> | ||
+ | |||
+ | == TinkerPopAble == | ||
+ | see See [https://github.com/BITPlan/pyjanusgraph/issues/2 Issue #2] | ||
+ | == Example Projects == | ||
+ | * https://github.com/WolfgangFahl/jhuregionmapper | ||
+ | |||
= Links = | = Links = | ||
* https://janusgraph.org/ | * https://janusgraph.org/ | ||
+ | * [https://stackoverflow.com/questions/tagged/janusgraph Stackoverflow questions for janusgraph] | ||
[[Category:Gremlin]] | [[Category:Gremlin]] |
Latest revision as of 11:17, 13 April 2020
OsProject
OsProject | |
---|---|
edit | |
id | pyjanusgraph |
state | |
owner | BITPlan |
title | Python janusgraph utility library |
url | https://github.com/BITPlan/pyjanusgraph |
version | 0.0.1a2 |
description | |
date | 2020/04/12 |
since | |
until |
Motivation
JanusGraph is the first Apache Tinkerpop graph database i could work with Gremlin Python.
pyjanusgraph shall make it easier to work with JanusGraph from Python
Installation
pip install pyjanusgraph
Usage
First start your janusgraph server e.g. by using the docker command:
docker run --name jg -it -p 8182:8182 --mount source=/$HOME/graphdata,target=/graphdata,type=bind janusgraph/janusgraph
RemoteGremlin
The RemoteGremlin class provides a simplified API to work with a remote Gremlin Server connection to JanusGraph. Optionally you may share data with an e.g docker based Server by setting up a sharepoint. See Issue #1
accessing a remote graph
from tp.gremlin import RemoteGremlin
import os
rg = RemoteGremlin()
g=rg.open()
vList = g.V().toList()
print ("found %d vertices" % (len(vList)))
rg.close()
sharing data
from tp.gremlin import RemoteGremlin
import os
rg = RemoteGremlin()
rg.setSharepoint(os.path.expanduser("~/graphdata"), "/graphdata/")
g=rg.open()
graphmlFile = "air-routes-small.xml";
shared = rg.share(graphmlPath)
g.io(shared).read().iterate()
vCount = g.V().count().next()
print ("%s has %d vertices" % (shared, vCount))
rg.close()
TinkerPopAble
see See Issue #2