pyley
Python client for an open-source graph database Cayley https://github.com/google/cayley.
Cayley is an open-source graph inspired by the graph database behind Freebase and Google’s Knowledge Graph. Its goal is to be a part of the developer’s toolbox where Linked Data and graph-shaped data (semantic webs, social networks, etc) in general are concerned.
Install via pip
You can install pyley using:
$ pip install pyley
Sample
Import pyley:
from pyley import CayleyClient, GraphObject
# Create cayley client
# this creates client with default parameters `http://localhost:64210/api/v1/query/gizmo`
client = CayleyClient()
# or specify `url` and `version` parameters
client = CayleyClient("http://localhost:64210", "v1")
g = GraphObject()
# Query all vertices in the graph, limit to the first 5 vertices found.
g.Vertex().GetLimit(5)
# Start with only one vertex, the literal name "Humphrey Bogart", and retrieve all of them.
query = g.Vertex("Humphrey Bogart").All();
response = client.Send(query)
# response.result contains JSON data and response.r contains raw response
print response.result
# `g` and `V` are synonyms for `graph` and `Vertex` respectively, as they are quite common.
query = g.V("Humphrey Bogart").All()
response = client.Send(query)
# "Humphrey Bogart" is a name, but not an entity.
# Let's find the entities with this name in our dataset.
# Follow links that are pointing In to our "Humphrey Bogart" node with the predicate "name".
query = g.V("Humphrey Bogart").In("<name>").All()
response = client.Send(query)
# Notice that "name" is a generic predicate in our dataset.
# Starting with a movie gives a similar effect.
query = g.V("Casablanca").In("name").All()
response = client.Send(query)
# Relatedly, we can ask the reverse; all ids with the name "Casablanca"
query = g.V().Has("name", "Casablanca").All()
response = client.Send(query)
# Let's get the list of actors in the film
query = g.V().Has("name", "Casablanca") \
.Out("/film/film/starring") \
.Out("/film/performance/actor") \
.Out("name") \
.All()
response = client.Send(query)
# But this is starting to get long.
# Let's use a morphism -- a pre-defined path stored in a variable -- as our linkage
film_to_actor = g.Morphism().Out("/film/film/starring").Out("/film/performance/actor")
query = g.V() \
.Has("name", "Casablanca") \
.Follow(film_to_actor) \
.Out("name") \
.All()
response = client.Send(query)
# Add data programatically to the JSON result list. Can be any JSON type.
query = g.Emit({'name': "John Doe", 'age': 41, 'isActor': True})
response = client.Send(query)
Bugs
If you encounter a bug, performance issue, or malfunction, please add an Issues with steps on how to reproduce the problem or feel to free to open a pull request.
TODO
Improve Gizmo implementation (Basic steps implemented at the moment)
Add more tests
Add more documentation
Open Source Projects in Use
requests by @kennethreitz
License
@ziλasal & @abdullahselek
Metadata
Release files for pyley 0.2.2.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pyley-0.2.2.2-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details for pyley-0.2.2.2-py2.py3-none-any.whl |
Release files / pyley-0.2.2.2-py2.py3-none-any.whl
| Download URL | pyley-0.2.2.2-py2.py3-none-any.whl |
|---|---|
| Size | 7.0 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
b293351d753a3c88586baebaed5dfeb48978d4115e520e0a4839312f7506cc6c
|
|
BLAKE2b-256 checksum How to use checksums |
54841313d25fdfef77a1ef73c31ba7d095a1cf91bb94ef494e294d829e8d4349
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3
|
Security for pyley 0.2.2.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.