GithubHelp home page GithubHelp logo

python-gryaml's Introduction

gryaml

image

Represent Neo4j graph data as YAML.

Features

  • Creates nodes and relationships in a Neo4j graph database from YAML using PyYAML-specific tags.
  • Operates at a whole-file level, as it uses custom YAML tags to deserialize the data to live objects.
  • Developed for loading data for integration testing.
  • Requires a running Neo4j instance and instantiates actual database entities, rather than just generating abstract/unbound py2neo.Node and py2neo.Relationship objects. This is due to py2neo version 1.6 not supporting node labels with abstract nodes. This might be changed if we are able to migrate off of 1.6 in the near future.

Versions

Python

Tested with both Python 2.7 and 3.6.

Neo4j

Should work with anything >= 2.0. Tested with 3.3.5. Running the tests requires 2.3 as it uses the DETACH DELETE feature to drop the database.

py2neo

Currently supports 1.6 and 2.0.

pyyaml

Tested with PyYAML v3.13.

Testing

Running the tests requires an installed, running Neo4j instance. Pass the URL through the environment variable NEO4J_URI.

Future

  • Make nodes just dicts with 'labels' and 'properties' keys? Maybe make rels dicts with 'head', 'tail', 'type' and 'properties' keys too?
  • Add a context manager to register with PyYAML, create graph database connection and then cleanup.
  • Support locating nodes with a Cypher query as part of creating a relationship.
  • Add gryaml-dump CLI tool to render database (or query result) as YAML.
  • Test/support ruamel.yaml.
  • Add ability to update & display schema.
  • Later py2neo. Dependent mainly on supporting later versions in py2neo_compat.
  • Documentation more complete & published to ReadTheDocs.

python-gryaml's People

Contributors

wcooley avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

python-gryaml's Issues

Write some documentation

While this code works for loading -- I've been using it extensively at work -- the lack of documentation probably makes it hard for anyone else to use.

Custom PyYAML representers

Implement custom PyYAML representers for nodes, relationships, et al. so that nodes and relationships can be dumped directly, rather than having to be manually created.

Split from #3.

Load entities by query

Recently I used this to create a new static structure in my database -- several new nodes with their relationships linking them. But when it came time to create relationships to nodes that already existed in my database, I had to resort to doing so manually.

I'd like to be able to specify a Cypher query for nodes as a YAML type, the anchor of which can then be used as an alias in defining relationships.

e.g.:

- &node-darth-vader !!python/object/apply:gryaml.node
  - labels:
    - person

- &node-luke-skywalker !!python/object/apply:gryaml.node_query
  - cypher: MATCH (p:person{name:"Luke Skywalker"}) RETURN p

- !!python/object/apply:gryaml.rel
 - *node-darth_vader
 - father_of
 - *node-luke-skywalker

Load schema indexes & constraints

It would be nice to be able to represent and load schema indexes & constraints:

- !!python/object/apply:gryaml.index
  label: person
  property: person_id

- !!python/object/apply:gryaml.constraint
  label: person
  property: person_id
  assert: unique

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.