Skip to content

Commit

Permalink
renamed rel2graph->data2neo
Browse files Browse the repository at this point in the history
  • Loading branch information
jkminder committed May 12, 2024
1 parent bee51bb commit 16ca83b
Show file tree
Hide file tree
Showing 62 changed files with 223 additions and 223 deletions.
38 changes: 19 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
[![Tests Neo4j 5.13](https://github.com/sg-dev/rel2graph/actions/workflows/tests_neo4j5.yaml/badge.svg)](https://github.com/sg-dev/rel2graph/actions/workflows/tests_neo4j5.yaml)
[![Python Versions](https://img.shields.io/badge/python-3.8%20%7C%C2%A03.9%C2%A0%7C%C2%A03.10%C2%A0%7C%203.11%C2%A0%7C%203.12-orange)](https://github.com/sg-dev/rel2graph/actions/workflows)
[![Tests Neo4j 5.13](https://github.com/sg-dev/Data2Neo/actions/workflows/tests_neo4j5.yaml/badge.svg)](https://github.com/sg-dev/Data2Neo/actions/workflows/tests_neo4j5.yaml)
[![Python Versions](https://img.shields.io/badge/python-3.8%20%7C%C2%A03.9%C2%A0%7C%C2%A03.10%C2%A0%7C%203.11%C2%A0%7C%203.12-orange)](https://github.com/sg-dev/Data2Neo/actions/workflows)

---
<p align="center">
<img src="docs/source/assets/images/rel2graph_banner.png" alt="rel2graph banner"/>
<img src="docs/source/assets/images/Data2Neo_banner.png" alt="Data2Neo banner"/>
</p>

---
**Rel2graph** is a library that simplifies the convertion of data in relational format to a graph knowledge database. It reliefs you of the cumbersome manual work of writing the conversion code and let's you focus on the conversion schema and data processing.
**Data2Neo** is a library that simplifies the convertion of data in relational format to a graph knowledge database. It reliefs you of the cumbersome manual work of writing the conversion code and let's you focus on the conversion schema and data processing.

The library is built specifically for converting data into a [neo4j](https://neo4j.com/) graph (minimum version 5.2). The library further supports extensive customization capabilities to clean and remodel data. As neo4j python client it uses the native [neo4j python client](https://neo4j.com/docs/getting-started/languages-guides/neo4j-python/).


- [Latest Releases](https://github.com/sg-dev/rel2graph/tags)
- [Documentation](https://rel2graph.jkminder.ch)
- [Latest Releases](https://github.com/sg-dev/Data2Neo/tags)
- [Documentation](https://Data2Neo.jkminder.ch)

This library has been developed at the [Chair of Systems Design at ETH Zürich](https://www.sg.ethz.ch).

## Installation
If you have setup a private ssh key for your github, copy-paste the command below to install the latest version ([v1.3.3][latest_tag]):
```
pip install git+ssh://[email protected]/sg-dev/rel2graph@v1.3.3
pip install git+ssh://[email protected]/sg-dev/Data2Neo@v1.3.3
```

If you don't have ssh set up, download the latest wheel [here][latest_wheel] and install the wheel with:
Expand All @@ -32,7 +32,7 @@ If you have cloned the repository you can also build it locally with
```
pip install **path-to-repository**
```
The rel2graph library supports Python 3.8+.
The Data2Neo library supports Python 3.8+.

## Quick Start
A quick example for converting data in a [Pandas](https://pandas.pydata.org) dataframe into a graph. The full example code can be found under [examples](/examples). For more details, please checkout the [full documentation][wiki]. We first define a *convertion schema* in a YAML style config file. In this config file we specify, which entites are converted into which nodes and which relationships.
Expand All @@ -56,17 +56,17 @@ ENTITY("Person"):
RELATIONSHIP(person, "likes", MATCH("Species", Name=Person.FavoriteFlower)):
- Since = "4ever"
```
The library itself has 2 basic elements, that are required for the conversion: the `Converter` that handles the conversion itself and an `Iterator` that iterates over the relational data. The iterator can be implemented for arbitrary data in relational format. Rel2graph currently has preimplemented iterators under:
- `rel2graph.relational_modules.sqlite` for [SQLite](https://www.sqlite.org/index.html) databases
- `rel2graph.relational_modules.pandas` for [Pandas](https://pandas.pydata.org) dataframes
The library itself has 2 basic elements, that are required for the conversion: the `Converter` that handles the conversion itself and an `Iterator` that iterates over the relational data. The iterator can be implemented for arbitrary data in relational format. Data2Neo currently has preimplemented iterators under:
- `Data2Neo.relational_modules.sqlite` for [SQLite](https://www.sqlite.org/index.html) databases
- `Data2Neo.relational_modules.pandas` for [Pandas](https://pandas.pydata.org) dataframes

We will use the `PandasDataFrameIterator` from `rel2graph.relational_modules.pandas`. Further we will use the `IteratorIterator` that can wrap multiple iterators to handle multiple dataframes. Since a pandas dataframe has no type/table name associated, we need to specify the name when creating a `PandasDataFrameIterator`. We also define define a custom function `append` that can be refered to in the schema file and that appends a string to the attribute value. For an entity with `Flower["petal_width"] = 5`, the outputed node will have the attribute `petal_width = "5 milimeters"`.
We will use the `PandasDataFrameIterator` from `Data2Neo.relational_modules.pandas`. Further we will use the `IteratorIterator` that can wrap multiple iterators to handle multiple dataframes. Since a pandas dataframe has no type/table name associated, we need to specify the name when creating a `PandasDataFrameIterator`. We also define define a custom function `append` that can be refered to in the schema file and that appends a string to the attribute value. For an entity with `Flower["petal_width"] = 5`, the outputed node will have the attribute `petal_width = "5 milimeters"`.
```python
import neo4j
import pandas as pd
from rel2graph.relational_modules.pandas import PandasDataFrameIterator
from rel2graph import IteratorIterator, Converter, Attribute, register_attribute_postprocessor
from rel2graph.utils import load_file
from Data2Neo.relational_modules.pandas import PandasDataFrameIterator
from Data2Neo import IteratorIterator, Converter, Attribute, register_attribute_postprocessor
from Data2Neo.utils import load_file
# Setup the neo4j uri and credentials
uri = "bolt:localhost:7687"
Expand All @@ -92,9 +92,9 @@ converter = Converter(load_file("schema.yaml"), iterator, uri, auth)
converter()
```
# Known issues
If you encounter a bug or an unexplainable behavior, please check the [known issues](https://github.com/sg-dev/rel2graph/labels/bug) list. If your issue is not found, submit a new one.
If you encounter a bug or an unexplainable behavior, please check the [known issues](https://github.com/sg-dev/Data2Neo/labels/bug) list. If your issue is not found, submit a new one.

[latest_version]: v1.3.3
[latest_tag]: https://github.com/sg-dev/rel2graph/releases/tag/v1.3.3
[latest_wheel]: https://github.com/sg-dev/rel2graph/releases/download/v1.3.3/rel2graph-1.3.3-py3-none-any.whl
[wiki]: https://rel2graph.jkminder.ch/index.html
[latest_tag]: https://github.com/sg-dev/Data2Neo/releases/tag/v1.3.3
[latest_wheel]: https://github.com/sg-dev/Data2Neo/releases/download/v1.3.3/Data2Neo-1.3.3-py3-none-any.whl
[wiki]: https://Data2Neo.jkminder.ch/index.html
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# -*- coding: utf-8 -*-

"""
Factory submodule of rel2graph. This module keeps track off all factories.
Factory submodule of data2neo. This module keeps track off all factories.
authors: Julian Minder
"""
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class SchemaConfigException(ValueError):

class SchemaConfigParser:
"""
Parses the schema config file into rel2graph instructions that can directly be converted into factories and their arguments. Uses ply to
Parses the schema config file into data2neo instructions that can directly be converted into factories and their arguments. Uses ply to
parse and lex the grammar.
All t_{name} methods/attributes of the class are used by lex to parser the document into tokens. All p_{name} functions define the grammar for
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ class Node(PropertyDict, Subgraph):
All positional arguments passed to the constructor are interpreted
as labels and all keyword arguments as properties::
>>> from rel2graph.neo4j import Node
>>> from data2neo.neo4j import Node
>>> a = Node("Person", name="Alice")
"""
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion rel2graph/utils.py → data2neo/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# -*- coding: utf-8 -*-

"""
Utility functions for working with rel2graph.
Utility functions for working with data2neo.
authors: Julian Minder
"""
Expand Down
2 changes: 1 addition & 1 deletion docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
rel2graph
data2neo
sphinx
sphinx_autodoc_typehints
sphinx_rtd_theme
Expand Down
14 changes: 7 additions & 7 deletions docs/source/api/core.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,54 +8,54 @@ The main api and classes provided by the library.
Converter
~~~~~~~~~

.. autoclass:: rel2graph.Converter
.. autoclass:: data2neo.Converter
:members:
:show-inheritance:
:special-members: __call__

Resource
~~~~~~~~

.. autoclass:: rel2graph.Resource
.. autoclass:: data2neo.Resource
:members:
:show-inheritance:
:special-members: __getitem__,__setitem__,__repr__

ResourceIterator
~~~~~~~~~~~~~~~~

.. autoclass:: rel2graph.ResourceIterator
.. autoclass:: data2neo.ResourceIterator
:members:
:show-inheritance:
:special-members: __iter__,__len__,__next__

IteratorIterator
~~~~~~~~~~~~~~~~

.. autoclass:: rel2graph.IteratorIterator
.. autoclass:: data2neo.IteratorIterator
:members:
:show-inheritance:

Attribute
~~~~~~~~~

.. autoclass:: rel2graph.Attribute
.. autoclass:: data2neo.Attribute
:members:
:noindex:
:show-inheritance:

SubgraphFactoryWrapper
~~~~~~~~~~~~~~~~~~~~~~

.. autoclass:: rel2graph.SubgraphFactoryWrapper
.. autoclass:: data2neo.SubgraphFactoryWrapper
:members:
:noindex:
:show-inheritance:

AttributeFactoryWrapper
~~~~~~~~~~~~~~~~~~~~~~~

.. autoclass:: rel2graph.AttributeFactoryWrapper
.. autoclass:: data2neo.AttributeFactoryWrapper
:members:
:noindex:
:show-inheritance:
18 changes: 9 additions & 9 deletions docs/source/api/neo4j.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,35 @@ Neo4j Integration

These functions abstract complexity of interacting with Neo4j. Instead of writing Cypher queries, you can use Python objects to create, merge and match nodes and relationships.

.. autofunction:: rel2graph.neo4j.create
.. autofunction:: data2neo.neo4j.create

.. autofunction:: rel2graph.neo4j.merge
.. autofunction:: data2neo.neo4j.merge

.. autofunction:: rel2graph.neo4j.push
.. autofunction:: data2neo.neo4j.push

.. autofunction:: rel2graph.neo4j.pull
.. autofunction:: data2neo.neo4j.pull

.. autofunction:: rel2graph.neo4j.match_nodes
.. autofunction:: data2neo.neo4j.match_nodes

.. autofunction:: rel2graph.neo4j.match_relationships
.. autofunction:: data2neo.neo4j.match_relationships

Subgraph
~~~~~~~~

.. autoclass:: rel2graph.neo4j.Subgraph
.. autoclass:: data2neo.neo4j.Subgraph
:members:

Node
~~~~

.. autoclass:: rel2graph.neo4j.Node
.. autoclass:: data2neo.neo4j.Node
:members:
:show-inheritance:


Relationship
~~~~~~~~~~~~

.. autoclass:: rel2graph.neo4j.Relationship
.. autoclass:: data2neo.neo4j.Relationship
:members:
:show-inheritance:
12 changes: 6 additions & 6 deletions docs/source/api/relational_modules.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,41 +8,41 @@ They implement the abstract classes of the main interface.
SQLite
======

Implements the :py:class:`Resource <rel2graph.Resource>` and :py:class:`ResourceIterator <rel2graph.ResourceIterator>` for sqlite based on `sqlite3 <https://docs.python.org/3/library/sqlite3.html>`_.
Implements the :py:class:`Resource <data2neo.Resource>` and :py:class:`ResourceIterator <data2neo.ResourceIterator>` for sqlite based on `sqlite3 <https://docs.python.org/3/library/sqlite3.html>`_.


SQLiteResource
~~~~~~~~~~~~~~

.. autoclass:: rel2graph.relational_modules.sqlite.SQLiteResource
.. autoclass:: data2neo.relational_modules.sqlite.SQLiteResource
:members:
:show-inheritance:


SQLiteIterator
~~~~~~~~~~~~~~~~~~

.. autoclass:: rel2graph.relational_modules.sqlite.SQLiteIterator
.. autoclass:: data2neo.relational_modules.sqlite.SQLiteIterator
:members:
:show-inheritance:

======
Pandas
======

Implements the :py:class:`Resource <rel2graph.Resource>` and :py:class:`ResourceIterator <rel2graph.ResourceIterator>` for `pandas <https://pandas.pydata.org/>`_.
Implements the :py:class:`Resource <data2neo.Resource>` and :py:class:`ResourceIterator <data2neo.ResourceIterator>` for `pandas <https://pandas.pydata.org/>`_.

PandasSeriesResource
~~~~~~~~~~~~~~~~~~~~

.. autoclass:: rel2graph.relational_modules.pandas.PandasSeriesResource
.. autoclass:: data2neo.relational_modules.pandas.PandasSeriesResource
:members:
:show-inheritance:


PandasDataFrameIterator
~~~~~~~~~~~~~~~~~~~~~~~

.. autoclass:: rel2graph.relational_modules.pandas.PandasDataFrameIterator
.. autoclass:: data2neo.relational_modules.pandas.PandasDataFrameIterator
:members:
:show-inheritance:
4 changes: 2 additions & 2 deletions docs/source/api/utils.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Utils
-----------------

General utility functions for working with rel2graph.
General utility functions for working with Data2Neo.


.. autofunction:: rel2graph.utils.load_file
.. autofunction:: data2neo.utils.load_file
8 changes: 4 additions & 4 deletions docs/source/common_modules.rst
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
Common modules
==============

The rel2graph library comes with some predefined wrappers. To use them you must import them from the ``rel2graph.common_modules`` module. The following wrappers are available:
The data2neo library comes with some predefined wrappers. To use them you must import them from the ``data2neo.common_modules`` module. The following wrappers are available:


general
-------
.. code-block:: python
import rel2graph.common_modules
import data2neo.common_modules
**MERGE_RELATIONSHIPS**
~~~~~~~~~~~~~~~~~~~~~~~
Expand Down Expand Up @@ -37,7 +37,7 @@ types
--------
.. code-block:: python
import rel2graph.common_modules.types
import data2neo.common_modules.types
**INT**
Expand Down Expand Up @@ -65,7 +65,7 @@ datetime
--------
.. code-block:: python
import rel2graph.common_modules.datetime
import data2neo.common_modules.datetime
**DATETIME**
Expand Down
4 changes: 2 additions & 2 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

# -- Project information -----------------------------------------------------

project = 'rel2graph'
project = 'data2neo'
copyright = '2024, Julian Minder'
author = 'Julian Minder'

Expand Down Expand Up @@ -76,7 +76,7 @@
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']

html_logo = "./assets/images/rel2graph_banner.png"
html_logo = "./assets/images/data2neo_banner.png"
html_theme_options = {
'logo_only': True,
'display_version': False,
Expand Down
6 changes: 3 additions & 3 deletions docs/source/conversion_schema.rst
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,8 @@ Assuming you have defined the attributewrappers ``ATTRWRAPPER1`` and ``ATTRWRAPP
Note that the library does no semantic checking of your schema. If you apply an attribute wrapper to a node or a relationship, the outcome is undefined and might result in unexpected behaviour/exceptions during runtime.

.. |Resource| replace:: :py:class:`Resource <rel2graph.Resource>`
.. |Converter| replace:: :py:class:`Converter <rel2graph.Converter>`
.. |ResourceIterator| replace:: :py:class:`ResourceIterator <rel2graph.ResourceIterator>`
.. |Resource| replace:: :py:class:`Resource <data2neo.Resource>`
.. |Converter| replace:: :py:class:`Converter <data2neo.Converter>`
.. |ResourceIterator| replace:: :py:class:`ResourceIterator <data2neo.ResourceIterator>`
.. _neo4j: https://neo4j.com/
.. _py2neo: https://py2neo.org/2021.1/index.html
Loading

0 comments on commit 16ca83b

Please sign in to comment.