neomodel


Nameneomodel JSON
Version 5.4.0 PyPI version JSON
download
home_pageNone
SummaryAn object mapper for the neo4j graph database.
upload_time2024-11-07 09:09:55
maintainerNone
docs_urlNone
authorNone
requires_python>=3.8
licenseMIT
keywords graph neo4j orm ogm mapper
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ![neomodel](https://raw.githubusercontent.com/neo4j-contrib/neomodel/master/doc/source/_static/neomodel-300.png)

An Object Graph Mapper (OGM) for the [neo4j](https://neo4j.com/) graph
database, built on the awesome
[neo4j_driver](https://github.com/neo4j/neo4j-python-driver)

If you need assistance with neomodel, please create an issue on the
GitHub repo found at <https://github.com/neo4j-contrib/neomodel/>.

-   Familiar class based model definitions with proper inheritance.
-   Powerful query API.
-   Schema enforcement through cardinality restrictions.
-   Full transaction support.
-   Thread safe.
-   Pre/post save/delete hooks.
-   Django integration via
    [django_neomodel](https://github.com/neo4j-contrib/django-neomodel)

[![Reliability Rating](https://sonarcloud.io/api/project_badges/measure?project=neo4j-contrib_neomodel&metric=reliability_rating)](https://sonarcloud.io/summary/new_code?id=neo4j-contrib_neomodel)
[![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=neo4j-contrib_neomodel&metric=security_rating)](https://sonarcloud.io/summary/new_code?id=neo4j-contrib_neomodel)
[![Documentation Status](https://readthedocs.org/projects/neomodel/badge/?version=latest)](https://neomodel.readthedocs.io/en/latest/?badge=latest)

# Requirements

**For neomodel releases 5.x :**

-   Python 3.8+
-   Neo4j 5.x, 4.4 (LTS)

**For neomodel releases 4.x :**

-   Python 3.7 -\> 3.10
-   Neo4j 4.x (including 4.4 LTS for neomodel version 4.0.10)

# Documentation

Available on
[readthedocs](http://neomodel.readthedocs.org).

# New in 5.4.0

This version adds many new features, expanding neomodel's querying capabilities. Those features were kindly contributed back by the [OpenStudyBuilder team](https://openstudybuilder.com/). A VERY special thanks to @tonioo for the integration work.

There are too many new capabilities here, so I advise you to start by looking at the full summary example in the [Getting Started guide](https://neomodel.readthedocs.io/en/latest/getting_started.html#full-example). It will then point you to the various relevant sections.

We also validated support for [Python 3.13](https://docs.python.org/3/whatsnew/3.13.html).

# New in 5.3.0

neomodel now supports asynchronous programming, thanks to the [Neo4j driver async API](https://neo4j.com/docs/api/python-driver/current/async_api.html). The [documentation](http://neomodel.readthedocs.org) has been updated accordingly, with an updated getting started section, and some specific documentation for the async API.

# Breaking changes in 5.3.0

- config.AUTO_INSTALL_LABELS has been removed. Please use the `neomodel_install_labels` script instead. _Note : this is because of the addition of async, but also because it might lead to uncontrolled creation of indexes/constraints. The script makes you more in control of said creation._
- The Database class has been moved into neomodel.sync_.core - and a new AsyncDatabase introduced into neomodel.async_.core
- Based on Python version [status](https://devguide.python.org/versions/),
neomodel will be dropping support for Python 3.7 in an upcoming release
(5.3 or later). _This does not mean neomodel will stop working on Python 3.7, but
it will no longer be tested against it_
- Some standalone methods have been refactored into the Database() class. Check the [documentation](http://neomodel.readthedocs.org) for a full list.

# Installation

Install from pypi (recommended):

    $ pip install neomodel ($ source dev # To install all things needed in a Python3 venv)

    # Neomodel has some optional dependencies (including Shapely), to install these use:

    $ pip install neomodel['extras']

To install from github:

    $ pip install git+git://github.com/neo4j-contrib/neomodel.git@HEAD#egg=neomodel-dev

# Performance comparison

You can find some performance tests made using Locust [in this repo](https://github.com/mariusconjeaud/neomodel-locust).

Two learnings from this :

* The wrapping of the driver made by neomodel is very thin performance-wise : it does not add a lot of overhead ;
* When used in a concurrent fashion, async neomodel is faster than concurrent sync neomodel, and a lot of faster than serial queries.

# Contributing

Ideas, bugs, tests and pull requests always welcome. Please use
GitHub\'s Issues page to track these.

If you are interested in developing `neomodel` further, pick a subject
from the Issues page and open a Pull Request (PR) for it. If you are
adding a feature that is not captured in that list yet, consider if the
work for it could also contribute towards delivering any of the existing
issues too.

## Running the test suite

Make sure you have a Neo4j database version 4 or higher to run the tests
on.:

    $ export NEO4J_BOLT_URL=bolt://<username>:<password>@localhost:7687 # check your username and password

Ensure `dbms.security.auth_enabled=true` in your database configuration
file. Setup a virtual environment, install neomodel for development and
run the test suite: :

    $ pip install -r requirements-dev.txt
    $ pytest

The tests in \"test_connection.py\" will fail locally if you don\'t
specify the following environment variables:

    $ export AURA_TEST_DB_USER=username
    $ export AURA_TEST_DB_PASSWORD=password
    $ export AURA_TEST_DB_HOSTNAME=url

If you are running a neo4j database for the first time the test suite
will set the password to \'test\'. If the database is already populated,
the test suite will abort with an error message and ask you to re-run it
with the `--resetdb` switch. This is a safeguard to ensure that the test
suite does not accidentally wipe out a database if you happen to not
have restarted your Neo4j server to point to a (usually named)
`debug.db` database.

If you have `docker-compose` installed, you can run the test suite
against all supported Python interpreters and neo4j versions: :

    # in the project's root folder:
    $ sh ./tests-with-docker-compose.sh

## Developing with async

### Transpiling async -> sync

We use [this great library](https://github.com/python-trio/unasync) to automatically transpile async code into its sync version.

In other words, when contributing to neomodel, only update the `async` code in `neomodel/async_`, then run : :

    bin/make-unasync
    isort .
    black .

Note that you can also use the pre-commit hooks for this.

### Specific async/sync code
This transpiling script mainly does two things :

- It removes the await keywords, and the Async prefixes in class names
- It does some specific replacements, like `adb`->`db`, `mark_async_test`->`mark_sync_test`

It might be that your code should only be run for `async`, or `sync` ; or you want different stubs to be run for `async` vs `sync`.
You can use the following utility function for this - taken from the official [Neo4j python driver code](https://github.com/neo4j/neo4j-python-driver) :

    # neomodel/async_/core.py
    from neomodel._async_compat.util import AsyncUtil

    # AsyncUtil.is_async_code is always True
    if AsyncUtil.is_async_code:
        # Specific async code
        # This one gets run when in async mode
        assert await Coffee.nodes.check_contains(2)
    else:
        # Specific sync code
        # This one gest run when in sync mode
        assert 2 in Coffee.nodes

You can check [test_match_api](test/async_/test_match_api.py) for some good examples, and how it's transpiled into sync.


            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "neomodel",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "Marius Conjeaud <marius.conjeaud@outlook.com>, Athanasios Anastasiou <athanastasiou@gmail.com>",
    "keywords": "graph, neo4j, ORM, OGM, mapper",
    "author": null,
    "author_email": "Robin Edwards <robin.ge@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/96/8d/e746f694b6bb8da11773df3b11c865e75396e83d6b91d844e4788dd8e486/neomodel-5.4.0.tar.gz",
    "platform": null,
    "description": "![neomodel](https://raw.githubusercontent.com/neo4j-contrib/neomodel/master/doc/source/_static/neomodel-300.png)\n\nAn Object Graph Mapper (OGM) for the [neo4j](https://neo4j.com/) graph\ndatabase, built on the awesome\n[neo4j_driver](https://github.com/neo4j/neo4j-python-driver)\n\nIf you need assistance with neomodel, please create an issue on the\nGitHub repo found at <https://github.com/neo4j-contrib/neomodel/>.\n\n-   Familiar class based model definitions with proper inheritance.\n-   Powerful query API.\n-   Schema enforcement through cardinality restrictions.\n-   Full transaction support.\n-   Thread safe.\n-   Pre/post save/delete hooks.\n-   Django integration via\n    [django_neomodel](https://github.com/neo4j-contrib/django-neomodel)\n\n[![Reliability Rating](https://sonarcloud.io/api/project_badges/measure?project=neo4j-contrib_neomodel&metric=reliability_rating)](https://sonarcloud.io/summary/new_code?id=neo4j-contrib_neomodel)\n[![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=neo4j-contrib_neomodel&metric=security_rating)](https://sonarcloud.io/summary/new_code?id=neo4j-contrib_neomodel)\n[![Documentation Status](https://readthedocs.org/projects/neomodel/badge/?version=latest)](https://neomodel.readthedocs.io/en/latest/?badge=latest)\n\n# Requirements\n\n**For neomodel releases 5.x :**\n\n-   Python 3.8+\n-   Neo4j 5.x, 4.4 (LTS)\n\n**For neomodel releases 4.x :**\n\n-   Python 3.7 -\\> 3.10\n-   Neo4j 4.x (including 4.4 LTS for neomodel version 4.0.10)\n\n# Documentation\n\nAvailable on\n[readthedocs](http://neomodel.readthedocs.org).\n\n# New in 5.4.0\n\nThis version adds many new features, expanding neomodel's querying capabilities. Those features were kindly contributed back by the [OpenStudyBuilder team](https://openstudybuilder.com/). A VERY special thanks to @tonioo for the integration work.\n\nThere are too many new capabilities here, so I advise you to start by looking at the full summary example in the [Getting Started guide](https://neomodel.readthedocs.io/en/latest/getting_started.html#full-example). It will then point you to the various relevant sections.\n\nWe also validated support for [Python 3.13](https://docs.python.org/3/whatsnew/3.13.html).\n\n# New in 5.3.0\n\nneomodel now supports asynchronous programming, thanks to the [Neo4j driver async API](https://neo4j.com/docs/api/python-driver/current/async_api.html). The [documentation](http://neomodel.readthedocs.org) has been updated accordingly, with an updated getting started section, and some specific documentation for the async API.\n\n# Breaking changes in 5.3.0\n\n- config.AUTO_INSTALL_LABELS has been removed. Please use the `neomodel_install_labels` script instead. _Note : this is because of the addition of async, but also because it might lead to uncontrolled creation of indexes/constraints. The script makes you more in control of said creation._\n- The Database class has been moved into neomodel.sync_.core - and a new AsyncDatabase introduced into neomodel.async_.core\n- Based on Python version [status](https://devguide.python.org/versions/),\nneomodel will be dropping support for Python 3.7 in an upcoming release\n(5.3 or later). _This does not mean neomodel will stop working on Python 3.7, but\nit will no longer be tested against it_\n- Some standalone methods have been refactored into the Database() class. Check the [documentation](http://neomodel.readthedocs.org) for a full list.\n\n# Installation\n\nInstall from pypi (recommended):\n\n    $ pip install neomodel ($ source dev # To install all things needed in a Python3 venv)\n\n    # Neomodel has some optional dependencies (including Shapely), to install these use:\n\n    $ pip install neomodel['extras']\n\nTo install from github:\n\n    $ pip install git+git://github.com/neo4j-contrib/neomodel.git@HEAD#egg=neomodel-dev\n\n# Performance comparison\n\nYou can find some performance tests made using Locust [in this repo](https://github.com/mariusconjeaud/neomodel-locust).\n\nTwo learnings from this :\n\n* The wrapping of the driver made by neomodel is very thin performance-wise : it does not add a lot of overhead ;\n* When used in a concurrent fashion, async neomodel is faster than concurrent sync neomodel, and a lot of faster than serial queries.\n\n# Contributing\n\nIdeas, bugs, tests and pull requests always welcome. Please use\nGitHub\\'s Issues page to track these.\n\nIf you are interested in developing `neomodel` further, pick a subject\nfrom the Issues page and open a Pull Request (PR) for it. If you are\nadding a feature that is not captured in that list yet, consider if the\nwork for it could also contribute towards delivering any of the existing\nissues too.\n\n## Running the test suite\n\nMake sure you have a Neo4j database version 4 or higher to run the tests\non.:\n\n    $ export NEO4J_BOLT_URL=bolt://<username>:<password>@localhost:7687 # check your username and password\n\nEnsure `dbms.security.auth_enabled=true` in your database configuration\nfile. Setup a virtual environment, install neomodel for development and\nrun the test suite: :\n\n    $ pip install -r requirements-dev.txt\n    $ pytest\n\nThe tests in \\\"test_connection.py\\\" will fail locally if you don\\'t\nspecify the following environment variables:\n\n    $ export AURA_TEST_DB_USER=username\n    $ export AURA_TEST_DB_PASSWORD=password\n    $ export AURA_TEST_DB_HOSTNAME=url\n\nIf you are running a neo4j database for the first time the test suite\nwill set the password to \\'test\\'. If the database is already populated,\nthe test suite will abort with an error message and ask you to re-run it\nwith the `--resetdb` switch. This is a safeguard to ensure that the test\nsuite does not accidentally wipe out a database if you happen to not\nhave restarted your Neo4j server to point to a (usually named)\n`debug.db` database.\n\nIf you have `docker-compose` installed, you can run the test suite\nagainst all supported Python interpreters and neo4j versions: :\n\n    # in the project's root folder:\n    $ sh ./tests-with-docker-compose.sh\n\n## Developing with async\n\n### Transpiling async -> sync\n\nWe use [this great library](https://github.com/python-trio/unasync) to automatically transpile async code into its sync version.\n\nIn other words, when contributing to neomodel, only update the `async` code in `neomodel/async_`, then run : :\n\n    bin/make-unasync\n    isort .\n    black .\n\nNote that you can also use the pre-commit hooks for this.\n\n### Specific async/sync code\nThis transpiling script mainly does two things :\n\n- It removes the await keywords, and the Async prefixes in class names\n- It does some specific replacements, like `adb`->`db`, `mark_async_test`->`mark_sync_test`\n\nIt might be that your code should only be run for `async`, or `sync` ; or you want different stubs to be run for `async` vs `sync`.\nYou can use the following utility function for this - taken from the official [Neo4j python driver code](https://github.com/neo4j/neo4j-python-driver) :\n\n    # neomodel/async_/core.py\n    from neomodel._async_compat.util import AsyncUtil\n\n    # AsyncUtil.is_async_code is always True\n    if AsyncUtil.is_async_code:\n        # Specific async code\n        # This one gets run when in async mode\n        assert await Coffee.nodes.check_contains(2)\n    else:\n        # Specific sync code\n        # This one gest run when in sync mode\n        assert 2 in Coffee.nodes\n\nYou can check [test_match_api](test/async_/test_match_api.py) for some good examples, and how it's transpiled into sync.\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "An object mapper for the neo4j graph database.",
    "version": "5.4.0",
    "project_urls": {
        "changelog": "https://github.com/neo4j-contrib/neomodel/releases",
        "documentation": "https://neomodel.readthedocs.io/en/latest/",
        "repository": "http://github.com/neo4j-contrib/neomodel"
    },
    "split_keywords": [
        "graph",
        " neo4j",
        " orm",
        " ogm",
        " mapper"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "344d37fa5890a8e45cf009f5f6a8708b0aa8b90fb455865533e688d472255e4a",
                "md5": "2fc963f46b376fea6b0999e4cb1f8a9e",
                "sha256": "98569c55d72fb88d9339df1d2a55396bb493350c5eebefc230c0a0b759dd4f7a"
            },
            "downloads": -1,
            "filename": "neomodel-5.4.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "2fc963f46b376fea6b0999e4cb1f8a9e",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 216918,
            "upload_time": "2024-11-07T09:09:53",
            "upload_time_iso_8601": "2024-11-07T09:09:53.487528Z",
            "url": "https://files.pythonhosted.org/packages/34/4d/37fa5890a8e45cf009f5f6a8708b0aa8b90fb455865533e688d472255e4a/neomodel-5.4.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "968de746f694b6bb8da11773df3b11c865e75396e83d6b91d844e4788dd8e486",
                "md5": "df83222aa5b1194220eee79ccc5c6458",
                "sha256": "6d30df8f226ac73fcf2653d0e3e3bcd3fdfda28b45c5b833a3d09f47ebb03649"
            },
            "downloads": -1,
            "filename": "neomodel-5.4.0.tar.gz",
            "has_sig": false,
            "md5_digest": "df83222aa5b1194220eee79ccc5c6458",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 182453,
            "upload_time": "2024-11-07T09:09:55",
            "upload_time_iso_8601": "2024-11-07T09:09:55.173034Z",
            "url": "https://files.pythonhosted.org/packages/96/8d/e746f694b6bb8da11773df3b11c865e75396e83d6b91d844e4788dd8e486/neomodel-5.4.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-11-07 09:09:55",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "neo4j-contrib",
    "github_project": "neomodel",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "neomodel"
}
        
Elapsed time: 1.26733s