You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Changelog
+6Lines changed: 6 additions & 0 deletions
Original file line number
Diff line number
Diff 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
+
1
7
Version 5.2.1 2023-12
2
8
* Add options to inspection script to skip heavy operations - rel props or cardinality inspection #767
Copy file name to clipboardExpand all lines: README.md
+58-13Lines changed: 58 additions & 13 deletions
Original file line number
Diff line number
Diff line change
@@ -34,24 +34,21 @@ GitHub repo found at <https://github.com/neo4j-contrib/neomodel/>.
34
34
35
35
# Documentation
36
36
37
-
(Needs an update, but) Available on
37
+
Available on
38
38
[readthedocs](http://neomodel.readthedocs.org).
39
39
40
-
# Upcoming breaking changes notice - \>=5.3
40
+
# New in 5.3.0
41
41
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.
47
43
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
52
45
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.
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
+
70
76
# Contributing
71
77
72
78
Ideas, bugs, tests and pull requests always welcome. Please use
@@ -112,3 +118,42 @@ against all supported Python interpreters and neo4j versions: :
112
118
113
119
# in the project's root folder:
114
120
$ 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.
0 commit comments