Skip to content

Commit f8e2350

Browse files
Merge pull request #789 from neo4j-contrib/rc/5.3.0
Release 5.3.0
2 parents 4bd6302 + 0aeac32 commit f8e2350

File tree

118 files changed

+12414
-2363
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

118 files changed

+12414
-2363
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ development.env
1515
.ropeproject
1616
\#*\#
1717
.eggs
18-
bin
1918
lib
2019
.vscode
2120
pyvenv.cfg

.pre-commit-config.yaml

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
repos:
2-
- repo: https://github.com/psf/black
3-
rev: 22.3.0
4-
hooks:
5-
- id: black
62
- repo: https://github.com/PyCQA/isort
73
rev: 5.11.5
84
hooks:
95
- id: isort
10-
# - repo: local
11-
# hooks:
12-
# - id: pylint
13-
# name: pylint
14-
# entry: pylint neomodel/
15-
# language: system
16-
# always_run: true
17-
# pass_filenames: false
6+
args: ["--profile", "black"]
7+
- repo: https://github.com/psf/black
8+
rev: 23.3.0
9+
hooks:
10+
- id: black
11+
- repo: local
12+
hooks:
13+
- id: unasync
14+
name: unasync
15+
entry: bin/make-unasync
16+
language: python
17+
files: "^(neomodel/async_|test/async_)/.*"
18+
additional_dependencies: [unasync, isort, black]

Changelog

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
Version 5.3.0 2024-04
2+
* Add async support
3+
* Breaking change : config.AUTO_INSTALL_LABELS has been removed. Please use the neomodel_install_labels script instead
4+
* Bumps neo4j (driver) to 5.19.0
5+
* Various improvement : functools wrap to TransactionProxy, fix node equality check, q filter for IN in arrays, fix inflate on db_property. Thanks to @giosava94, @OlehChyhyryn, @icapora, @j-krose
6+
17
Version 5.2.1 2023-12
28
* Add options to inspection script to skip heavy operations - rel props or cardinality inspection #767
39
* Fixes database version parsing issues

README.md

Lines changed: 58 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -34,24 +34,21 @@ GitHub repo found at <https://github.com/neo4j-contrib/neomodel/>.
3434

3535
# Documentation
3636

37-
(Needs an update, but) Available on
37+
Available on
3838
[readthedocs](http://neomodel.readthedocs.org).
3939

40-
# Upcoming breaking changes notice - \>=5.3
40+
# New in 5.3.0
4141

42-
Based on Python version [status](https://devguide.python.org/versions/),
43-
neomodel will be dropping support for Python 3.7 in an upcoming release
44-
(5.3 or later). This does not mean neomodel will stop working on Python 3.7, but
45-
it will no longer be tested against it. Instead, we will try to add
46-
support for Python 3.12.
42+
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.
4743

48-
Another source of upcoming breaking changes is the addition async support to
49-
neomodel. No date is set yet, but the work has progressed a lot in the past weeks ;
50-
and it will be part of a major release (potentially 6.0 to avoid misunderstandings).
51-
You can see the progress in [this branch](https://github.com/neo4j-contrib/neomodel/tree/task/async).
44+
# Breaking change in 5.3.0
5245

53-
Finally, we are looking at refactoring some standalone methods into the
54-
Database() class. More to come on that later.
46+
- 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._
47+
- Based on Python version [status](https://devguide.python.org/versions/),
48+
neomodel will be dropping support for Python 3.7 in an upcoming release
49+
(5.3 or later). _This does not mean neomodel will stop working on Python 3.7, but
50+
it will no longer be tested against it_
51+
- Some standalone methods have been refactored into the Database() class. Check the [documentation](http://neomodel.readthedocs.org) for a full list.
5552

5653
# Installation
5754

@@ -67,6 +64,15 @@ To install from github:
6764

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

67+
# Performance comparison
68+
69+
You can find some performance tests made using Locust [in this repo](https://github.com/mariusconjeaud/neomodel-locust).
70+
71+
Two learnings from this :
72+
73+
* The wrapping of the driver made by neomodel is very thin performance-wise : it does not add a lot of overhead ;
74+
* When used in a concurrent fashion, async neomodel is faster than concurrent sync neomodel, and a lot of faster than serial queries.
75+
7076
# Contributing
7177

7278
Ideas, bugs, tests and pull requests always welcome. Please use
@@ -112,3 +118,42 @@ against all supported Python interpreters and neo4j versions: :
112118

113119
# in the project's root folder:
114120
$ sh ./tests-with-docker-compose.sh
121+
122+
## Developing with async
123+
124+
### Transpiling async -> sync
125+
126+
We use [this great library](https://github.com/python-trio/unasync) to automatically transpile async code into its sync version.
127+
128+
In other words, when contributing to neomodel, only update the `async` code in `neomodel/async_`, then run : :
129+
130+
bin/make-unasync
131+
isort .
132+
black .
133+
134+
Note that you can also use the pre-commit hooks for this.
135+
136+
### Specific async/sync code
137+
This transpiling script mainly does two things :
138+
139+
- It removes the await keywords, and the Async prefixes in class names
140+
- It does some specific replacements, like `adb`->`db`, `mark_async_test`->`mark_sync_test`
141+
142+
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`.
143+
You can use the following utility function for this - taken from the official [Neo4j python driver code](https://github.com/neo4j/neo4j-python-driver) :
144+
145+
# neomodel/async_/core.py
146+
from neomodel._async_compat.util import AsyncUtil
147+
148+
# AsyncUtil.is_async_code is always True
149+
if AsyncUtil.is_async_code:
150+
# Specific async code
151+
# This one gets run when in async mode
152+
assert await Coffee.nodes.check_contains(2)
153+
else:
154+
# Specific sync code
155+
# This one gest run when in sync mode
156+
assert 2 in Coffee.nodes
157+
158+
You can check [test_match_api](test/async_/test_match_api.py) for some good examples, and how it's transpiled into sync.
159+

0 commit comments

Comments
 (0)